Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/FareedKhan-dev/train-llm-from-scratch
/ functions
Functions
604 in github.com/FareedKhan-dev/train-llm-from-scratch
⨍
Functions
604
◇
Types & classes
40
Function
test_dpo_matches_the_formula_and_label_smoothing_hedges
()
tests/test_post_training_losses.py:22
Function
test_encode_pair_moves_trailing_spaces_and_scores_boundary_merges
()
tests/test_benchmarks.py:45
Function
test_ent_coef_subtracts_the_mean_policy_entropy
()
tests/test_ppo_entropy.py:36
Function
test_environment_variables_are_expanded
(tmp_path: Path, monkeypatch: pytest.MonkeyPatch)
tests/test_config.py:95
Function
test_every_shipped_config_loads
(folder: str, name: str)
tests/test_config.py:33
Function
test_every_stage_trains_and_hands_over_its_checkpoint
(arch: str, data: Path, tmp_path: Path)
tests/test_pipeline_e2e.py:76
Function
test_extract_answer
(text: str, expected: float | None)
tests/test_answer_parsing.py:36
Function
test_fast_training_learns_the_same_merges_as_the_textbook_algorithm
()
tests/test_tokenizer.py:69
Function
test_flops_match_the_model_formula
(extra: dict)
tests/test_model_report.py:20
Function
test_forward_embedding_works_with_several_blocks
Regression: it used to feed 4x-wide MLP activations into the next block and crash.
tests/test_classic_model.py:26
Function
test_forward_shapes_and_loss
(name: str)
tests/test_modern_model.py:47
Function
test_forward_shapes_loss_and_causality
()
tests/test_classic_model.py:15
Function
test_generate_options
()
tests/test_classic_model.py:42
Function
test_generation_can_run_past_the_context_window
()
tests/test_modern_model.py:252
Function
test_gqa_equals_mha_with_shared_heads
GQA with 2 KV heads == MHA whose 4 KV heads are copies (heads 0,1 share KV 0; 2,3 share KV 1).
tests/test_modern_model.py:143
Function
test_gradient_checkpointing_gives_the_same_gradients
(name: str)
tests/test_modern_model.py:230
Function
test_greedy_speculative_decoding_equals_greedy_target_decoding
()
tests/test_inference.py:30
Function
test_group_advantages_std_and_dr_grpo
()
tests/test_post_training_losses.py:55
Function
test_grpo_default_is_unchanged_and_clip_higher_widens_the_range
()
tests/test_post_training_losses.py:94
Function
test_gspo_uses_one_ratio_per_answer
()
tests/test_post_training_losses.py:111
Function
test_indistinguishable_pairs_do_not_crash
()
tests/test_preference_truncation.py:61
Function
test_int8_linear_is_accurate_and_four_times_smaller
()
tests/test_inference.py:84
Function
test_ipo_is_zero_at_its_target_gap
()
tests/test_post_training_losses.py:35
Function
test_kv_cache_matches_full_forward
Prefill 7 tokens, then decode one token at a time: logits must equal a full pass.
tests/test_modern_model.py:75
Function
test_lambada_scores_greedy_accuracy_and_perplexity
()
tests/test_benchmarks.py:100
Function
test_late_difference_is_kept_by_shortening_the_prompt
()
tests/test_preference_truncation.py:54
Function
test_legacy_checkpoint_dims_are_read_from_config
Checkpoints from scripts/train_transformer.py store their sizes under ``config``.
tests/test_checkpoint_io.py:107
Function
test_legacy_trainer_resumes_from_prefixed_checkpoint
(tmp_path: str)
tests/test_checkpoint_io.py:136
Function
test_loglik_is_the_sum_over_the_continuation_tokens
()
tests/test_benchmarks.py:53
Function
test_long_inputs_keep_their_last_tokens
()
tests/test_benchmarks.py:74
Function
test_long_prompt_and_long_answers_split_the_window
()
tests/test_preference_truncation.py:43
Function
test_long_prompt_keeps_both_full_answers
()
tests/test_preference_truncation.py:31
Function
test_lora_learns_and_keeps_the_base_frozen
()
tests/test_lora.py:52
Function
test_lora_starts_as_the_identity_and_trains_few_params
(make)
tests/test_lora.py:24
Function
test_loss_aggregation_modes
()
tests/test_post_training_losses.py:63
Function
test_max_tokens_is_exact
(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, max_tokens: int)
tests/test_data_tools.py:33
Function
test_merge_gives_the_same_outputs
(make)
tests/test_lora.py:37
Function
test_min_p_scales_with_the_top_probability
()
tests/test_sampling.py:26
Function
test_missing_backend_falls_back_to_cpu_with_a_warning
(monkeypatch: pytest.MonkeyPatch)
tests/test_device.py:19
Function
test_missing_data_explains_how_to_make_it
(monkeypatch: pytest.MonkeyPatch, tmp_path: Path)
tests/test_student_track.py:78
Function
test_missing_parameters_fail_loudly
(cfg: SFTConfig)
tests/test_checkpoint_io.py:129
Function
test_mla_caches_much_less_than_mha
()
tests/test_modern_model.py:161
Function
test_modern_checkpoints_round_trip
(tmp_path: str)
tests/test_factory.py:38
Function
test_moe_loss_includes_aux_in_training_only_and_active_params_are_smaller
()
tests/test_modern_model.py:180
Function
test_moe_routes_tokens_and_balancing_loss_trains_the_router
()
tests/test_modern_model.py:168
Function
test_muon_adamw_groups_match_torch_adamw
()
tests/test_optim.py:44
Function
test_muon_groups_keep_embeddings_and_head_on_adamw
()
tests/test_optim.py:58
Function
test_muon_matches_pytorch_reference
()
tests/test_optim.py:25
Function
test_newton_schulz_flattens_the_singular_values
()
tests/test_optim.py:13
Function
test_no_budget_keeps_every_token_and_a_bad_budget_is_an_error
(tmp_path: Path, monkeypatch: pytest.MonkeyPa
tests/test_data_tools.py:43
Function
test_num_tokens_divides_the_summed_loss
()
tests/test_sft_accumulation.py:53
Function
test_old_prefixed_checkpoints_still_load
Files written before the fix carry ``module._orig_mod.`` keys; they must load as-is.
tests/test_checkpoint_io.py:82
Function
test_parameter_count_of_the_readme_13m_model
()
tests/test_model_report.py:15
Function
test_post_training_adds_the_moe_balancing_loss
()
tests/test_modern_model.py:204
Function
test_post_training_wrappers_accept_the_modern_model
()
tests/test_modern_model.py:266
Function
test_presets_are_consistent
()
tests/test_student_track.py:84
Function
test_pretrain_base_resume_continues_and_extends
(tmp_path: Path, monkeypatch: pytest.MonkeyPatch)
tests/test_resume_data_order.py:131
Function
test_quantized_models_give_nearly_the_same_logits
(arch: str)
tests/test_inference.py:97
Function
test_random_pairs_always_fit_and_share_the_prompt
()
tests/test_preference_truncation.py:68
Function
test_ranks_read_disjoint_slices_of_one_shuffle
(tmp_path: Path)
tests/test_resume_data_order.py:62
Function
test_reward_checkpoint_loads_for_chat_and_as_reward_model
(cfg: SFTConfig, tmp_path: str)
tests/test_checkpoint_io.py:93
Function
test_rl_rollouts_use_the_kv_cache_and_sample_the_same_tokens
()
tests/test_modern_model.py:283
Function
test_rmsnorm_matches_torch
()
tests/test_modern_model.py:134
Function
test_rope_is_a_rotation_of_each_pair
Pair (x[i], x[i + d/2]) at position m is rotated by the angle m * theta_i.
tests/test_modern_model.py:118
Function
test_rope_scores_depend_only_on_relative_position
()
tests/test_modern_model.py:104
Function
test_round_trip_is_lossless
(tok: BPETokenizer, text: str)
tests/test_tokenizer.py:26
Function
test_round_up_pads_to_64
()
tests/test_student_track.py:92
Function
test_sampling_keeps_the_target_distribution_whatever_the_draft
()
tests/test_inference.py:68
Function
test_schedules_hit_their_anchor_points
()
tests/test_optim.py:85
Function
test_set_overrides_any_config_value
(monkeypatch: pytest.MonkeyPatch, tiny_data: dict[str, str])
tests/test_student_track.py:64
Function
test_short_pairs_are_encoded_exactly_like_a_full_conversation
()
tests/test_preference_truncation.py:22
Function
test_simpo_is_reference_free_and_length_normalized
()
tests/test_post_training_losses.py:45
Function
test_skipped_groups_do_not_shrink_the_update
--filter_groups masks whole answers; every averaging mode must ignore them, not count zeros.
tests/test_post_training_losses.py:71
Function
test_skipping_continues_the_order_across_epochs
(tmp_path: Path)
tests/test_resume_data_order.py:54
Function
test_sliding_window_limits_what_a_token_sees
With one block and window w, position t only depends on tokens t-w+1 .. t.
tests/test_modern_model.py:90
Function
test_smoke_configs_never_overwrite_real_checkpoints
()
tests/test_config.py:40
Function
test_smoke_shrinks_every_stage
()
tests/test_config.py:101
Function
test_special_tokens
(tok: BPETokenizer)
tests/test_tokenizer.py:75
Function
test_specs_round_trip_and_safe_decode
(tok: BPETokenizer, tmp_path)
tests/test_tokenizer.py:82
Function
test_speculative_decoding_respects_the_trained_window
Each model only sees its last `window` tokens; inside the window the result is exact.
tests/test_inference.py:38
Function
test_strip_wrapper_prefixes_handles_any_nesting
()
tests/test_checkpoint_io.py:42
Function
test_temperature_and_greedy
()
tests/test_sampling.py:32
Function
test_the_entropy_bonus_reaches_the_gradient
()
tests/test_ppo_entropy.py:49
Function
test_the_meta_device_builds_big_models_without_memory
()
tests/test_model_report.py:28
Function
test_the_router_learns_from_the_language_modeling_loss
(top_k: int)
tests/test_modern_model.py:194
Function
test_the_tasks_are_pinned_and_hellaswag_is_not_downloaded
()
tests/test_benchmarks.py:108
Function
test_tied_embeddings_share_one_matrix
()
tests/test_modern_model.py:223
Function
test_top_k_keeps_the_k_most_likely
()
tests/test_sampling.py:17
Function
test_top_p_keeps_the_smallest_set_reaching_p
()
tests/test_sampling.py:21
Function
test_train_then_generate
(monkeypatch: pytest.MonkeyPatch, tiny_data: dict[str, str], arch: list[str])
tests/test_student_track.py:52
Function
test_train_transformer_resume_continues_the_data
(tmp_path: Path, monkeypatch: pytest.MonkeyPatch)
tests/test_resume_data_order.py:99
Function
test_training_is_deterministic
()
tests/test_tokenizer.py:43
Function
test_training_learns_frequent_pieces_first
(tok: BPETokenizer)
tests/test_tokenizer.py:30
Function
test_unknown_keys_fail_with_a_suggestion
(tmp_path: Path)
tests/test_config.py:51
Function
test_unwrap_model_removes_compile_and_data_parallel
(cfg: SFTConfig)
tests/test_checkpoint_io.py:62
Function
test_vocab_must_hold_the_bytes
()
tests/test_tokenizer.py:94
Function
test_wrong_answers_are_not_marked_correct
()
tests/test_answer_parsing.py:40
Function
test_wrong_values_name_the_field_and_the_file
(tmp_path: Path)
tests/test_config.py:56
Function
tiny_data
(tmp_path_factory: pytest.TempPathFactory)
tests/test_student_track.py:28
Method
to_dict
(self)
src/models/modern/config.py:114
← previous
next →
501–600 of 604, ranked by callers