← Back to Pull requests

cleanup(models): remove dead code from the model definitions #2843

Open
unknown opened this pull request with 348 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 30, 2026 23:12 UTC
Author

Removes code in python/tokenspeed/runtime/models/ that nothing calls or reads: 27 files, +8 −550, no behavior change. Each item was checked by a repository-wide search (including string lookups) and by scanning every constructor, load_weights and self.model(...) call site.

| Removed | Why it is dead |
| --- | --- |
| pad_input_ids on 11 models (+ the imports it alone used) | no caller anywhere |
| Qwen3_5ForCausalLM.load_weights, Qwen3_5MoeModel.load_weights (~160 lines) | the loader calls only the top-level model; no wrapper or subclass delegates to them |
| default_bitsandbytes_target_modules and bitsandbytes_stacked_params_mapping | no reader |
| fall_back_to_pt_during_load = False ×6 | the loader reads it from the top-level model with default False |
| model=, _model_override and resolve_model overrides (DeepSeek-V3, GLM-5, LongCat) | no caller passes model=; the overrides equal BaseCausalLM.resolve_model |
| start_layer and end_layer (Kimi-K2.5, Qwen3-ASR) and the hasattr(self.model, "start_layer") filters in five loaders | no backbone defines start_layer, so the filters never run |
| Kimi-K2.5 mm_projector, get_image_feature | no reader; its image encoder is vision.embed_media |
| DeepSeek-V3 input_layer_norm_fn, cli_factor, padding_id (also GLM-5, LongCat) | no reader |
| GPT-OSS _WeightCreator (+3 maybe_materialize calls), get_attention_sliding_window_size method, is_nextn | never instantiated, called, or passed |
| registry "failed to be inspected" raise, \| str value type | unreachable: every listed architecture resolves first |
| FLASHForCausalLM alias | not in EntryClass, no reference |
| is_mtp, inner-NextN input_embeds, vocab_size, vl_config, window_size, is_multimodal, pass-through __init__s, ExtensibleLM.step | never passed or never read |

The 8 added lines are the collapses those removals leave behind (e.g. the NextN if input_embeds is None branch becomes hidden_states = self.embed_tokens(input_ids)). Kept on purpose: the QuantMixtralForCausalLM remap in model_loader/utils.py, since a plugin may register that architecture.

Validation (GB200)

  • All 66 runtime test files that import a touched module, on this branch and on its base 96c45352b: identical results. The 3 failures on both (test_mla_lora_scale::test_runtime_scale_matches_the_folded_weights_up_to_bf16_rounding, test_k3_moe_tail_tier::test_model_prepares_routed_workspace_at_serving_limit, test_modelopt_mixed_config::test_attention_dp_lm_head_uses_mixed_quantization) are pre-existing. The Inkling engine tests failed on the base only because two runs launched engines on one node at once; run alone they pass on both (15 of 15).

  • pre-commit run --all-files clean.
  • Diff: 348 lines (+261 / -87) across 4 files Reviewer: claude[bot] Review duration: 18m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.47) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 348 lines diff across 4 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.350
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #2843"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.1% · Safe to merge
    27.1%