Repository navigation
fix(models): declare every decoder leaf for issue #4174 (#4174) - #4245
Merged
Merged
Conversation
This was referenced Nov 17, 2026
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
…4846) Section A of #4769, each item fixed at its test double/oracle/expectation. No library behaviour was changed. Fixed: - test_exl3_workspace_release / test_offload_base_modules_restored: give the ModuleLooper doubles the state loop() now reads (_inflight_layer, _dangling_threads, Device-SMI handles, and a real model for the success path). Before: AttributeError while handling the injected failure; after: 7 passed. - test_local_model_paths: the fake loaded models are SimpleNamespace doubles with log_kv_cache_estimate, matching GPTQModel.load. Before: AttributeError on a bare object(); after: 29 passed. - test_diffusion_gemma_support: the hand-built DiffusionGemmaQModel double now carries quantize_config.activation_mode. Before: AttributeError; after: the post-quantize sync test passes. - test_tenstorrent_support: window starts follow the current iter_calibration_windows spacing (0, 18, 37, 56). Before: the stale [0, 14, 28, 42] oracle. - test_model::test_dequantize_model_awq: the fixture packs the real AWQ GEMM [0, 2, 4, 6, 1, 3, 5, 7] interleave instead of natural order, which is what dequantize_model reverses. Before: 95/128 elements differed. - test_fallback: the sym=True oracle uses zero = 2 ** (bits - 1) for every strategy, not an asymmetric zero point. Before: 32/32 zero mismatches. - test_gsq_method_adapters: FP8 pack_calibrated keeps the checkpoint bias in FP32 on purpose; assert that dtype and value instead of FP16. - test_serialization: offload_to_disk_path is deliberately absent from the checkpoint meta (#4327); assert its absence instead of its presence. - test_norm_lifecycle: quantize() now materializes the model and keeps the v2 runtime zero layout (#4380/#4426/#4063); assert no meta/inference parameters and validate_tuning_model(model.model) instead of the stale reload-only guard. - test_vptq_memory_4391: the legacy reference allocates >= 2 full-size temporaries on torch 2.15, not exactly 3; pin that it is worse than the chunked path instead of an exact torch-version-dependent count. - test_jamba_support: the module tree declares mamba.x_proj (#4245); update the simple list and the dense-mixer assertions. - test_marlin_jit: with desc_act=False and one group, g_idx is all zeros, not arange(in_features). - test_dynamic::test_skip_module: replace brittle paris/king keyword matching on greedy output with a coherence check on the continuation. - test_allspark_awq_cuda: install the checkpoint tensors as buffers, as a real load does, instead of Parameters that _kernel_bias caches as a second parameter (which leaked _bias_value into state_dict). - test_bits_new: select the bit width with parameterized.expand([2, 3, 4, 8]) instead of the BITS environment variable (AGENTS.md: behaviour comes from config/API, not env). - test_checkpoint_method_compatibility: use group_size=128 for the native AWQ GEMV/LLM-AWQ formats (GEMV accepts 64/128, LLM-AWQ only 128) and widen the fixture to hidden_size=128 for LLM-AWQ, whose in_features must divide 128. Gate the ~30-minute subprocess matrix behind the new opt-in checkpoint_recovery marker (same mechanism as gptq_cuda_e2e) so the file no longer always times out in a 600 s slot. Target cases test_format_checkpoint_recovery[awq-gemv], [awq-llm-awq] and both eora variants pass with -m checkpoint_recovery. Skipped because this host is CUDA sm_80, not ROCm: - every ROCm/gfx1201-only item belongs to #4770 and was not touched. Deferred: - tests/test_quant_batch.py::test_diff_batch: an FP32-calibration + dequantized-weight rewrite OOMs here (GPU 5 has ~14 GiB free while a shared 83 GiB process holds the card), so it was not shipped unverified. - test_bits_new was exercised for bits=2 against a 15M local model only; the 1B eval of the other widths does not fit the 600 s slot here. Environment-only failures seen while validating (not changed): - test_serialization.py::test_gptq_v1_serialization and test_save_keeps_live_model_inference: flash_attn_2_cuda undefined symbol. - test_diffusion_gemma_support.py::test_diffusion_gemma_generic_defusion_preserves_forward: defuser 0.0.25 is older than the required 0.0.31. - test_jamba_support.py::test_tiny_jamba_gptq_quantization_smoke: mamba-ssm is not installed. Validation (CUDA_VISIBLE_DEVICES=5, sm_80): - 13 touched files in one run: 380 passed, 110 skipped, 4 failed (the three environment-only causes above). - test_model.py -k dequantize_model: 12 passed, 1 skipped. - test_marlin_jit.py::test_marlin_cuda_smoke_build_and_forward: 1 passed. - test_dynamic.py::TestDynamic::test_skip_module: 1 passed (flash-attn auto-enable disabled locally because the host extension has an undefined symbol; the committed test still hits that environment failure). - test_checkpoint_method_compatibility.py default: 4 passed, 95 skipped; -m checkpoint_recovery targeted AWQ GEMV/LLM-AWQ cases: 4 passed. - test_bits_new.py::Test::test_quant_and_eora_0 (bits=2, 15M model): 1 passed.
5 tasks done
1 of 2 tasks
Qubitium
pushed a commit
that referenced
this pull request
Nov 19, 2026
#4245 declared every decoder leaf, which makes `mamba.x_proj` a quantization target. The tiny-model smoke test still asserted it stays a dense `nn.Linear`, so it failed on main. `conv1d` and `dt_proj` remain dense; only `x_proj` moves. Red: assert isinstance(modules["model.layers.0.mamba.x_proj"], torch.nn.Linear) fails on ddf11fc. Green: test_jamba_support.py 6 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4174
TL;DR
Model definitions could silently leave checkpoint-owned decoder weights in the source dtype because the plan tests only proved that declared specs resolved; a
Linear/Conv/expert leaf that the tree never mentioned was invisible. This PR fixes the affected trees, adds the missing pre-head norms and Phi-3 remote-code split, and adds an always-run registry sweep that fails when any decoder leaf is neither declared nor tagged:!/:?(including 3-D expert parameters). Net: 22 files, +927/-36.Root causes and before/after
definitions/voxtral.pydeclaredlanguage_model.model.layers; 5.22 buildsmodel.language_model.layersmixer.experts.#,mixer.shared_expertsor router entries,dynamic_expert_indexunset,layer_modules_strict=Falsebailing_moeattention.query_key_value/attention.densedropped by #4080; remote code still uses themfeed_forward:moelacked the""dense fallback; MoE is every other layerGemma4TextExpertsparameter and Defuser has no gemma4 entryexperts,router.proj) -> 0; generic Defuser pass splits all 8 expertsPhi3MLPclass path bypasses Defuser's native registration, leaving fusedmlp.gate_up_projunder a strict gate/up treeafter_defuser_conversionsplits into gate/uppre_lm_head_norm_module="lm_head"ran the head on its own input;mamba.conv1dand shared transformer subtree undeclaredmodel.final_layernormmamba.dt_projandmamba.conv1dundeclaredmamba.conv1dundeclared; no pre-head normmodel.final_layernormmodel.norm/model.H_module.final_norm/model.norm_frotary_embeddingpointed at nonexistentmodel.rotary_emb;self_attn.conv1dundeclaredblock_sparse_moe.gateundeclared:!The durable test
tests/module_tree/test_registry_leaf_coverage.pybuilds every locally constructibleMODEL_MAPentry onmeta, runs_convert_model_with_defuser, resolvesextract_layers_node(), and inventories everySUPPORTS_MODULE_TYPESleaf plus direct expert parameters (2-D and 3-D). It fails with the leaf path and layer count whenModulePlan.find()misses and no ancestor carries:!/:?.Fail-before on parent
7c7d70439(same test file, target subset):12 failed, 5 passed, 118 deselected— the 12 arebailing_hybrid,falcon_h1,gemma4,gemma4_text,jamba,kimi_linear,llama4,llama4_text,nemotron_h,voxtral,zamba,zamba2.Pass-after on this branch:
114 passed, 16 skipped, 5 xfailedon CUDA and ROCm. Skips are configs that need network (e.g.bailing_moe,grinmoe) or optional deps; xfails are reviewed, documented cases (mllamacross-attention TODO,unlimited_ocr,granitemoehybridoutside this issue's ownership, andglm4vonly while installed Defuser < 0.0.31).Flow
Old: only declared specs entered the plan, so an undeclared leaf never reached a warning.
flowchart TD A["MODEL_MAP entry"] --> B["simple_layer_modules"] B --> C["declared spec list"] C --> D["create_named_modules"] D -->|"match"| E["quantize"] D -->|"miss"| F["warning or strict error"] G["layer Linear/Conv/expert leaf"] --> H{"declared?"} H -->|"no"| I["silently stays in source dtype"] H -->|"yes"| C style I fill:#f8d7da,stroke:#b02a37New: the registry test independently inventories the real layer tree.
flowchart TD A["MODEL_MAP model_type"] --> B["AutoConfig.for_model"] B --> C{"local config?"} C -->|"no"| S["skip: needs network"] C -->|"yes"| D["loader.from_config on meta"] D --> E["_convert_model_with_defuser"] E --> F["get_layers_with_prefixes"] F --> G["ModulePlan.from_tree"] G --> H["leaf inventory: Linear/Conv/Embedding/expert"] H --> I["declared: exact spec or tagged ancestor"] I -->|"covered"| J["pass"] I -->|"uncovered"| K["fail: path + layer count"] style S fill:#fff3cd,stroke:#997404 style K fill:#f8d7da,stroke:#b02a37Phi-3 remote-code conversion:
flowchart LR A["remote Phi3ForCausalLM"] --> B["_convert_model_with_defuser"] B --> C{"Defuser split Phi3MLP?"} C -->|"native class"| D["gate_proj / up_proj"] C -->|"remote class"| E["Phi3QModel.after_defuser_conversion"] E --> F["chunk gate_up_proj on dim 0"] F --> D D --> G["ModulePlan resolves gate/up/down"] style E fill:#fff3cd,stroke:#997404The committed reference page is
docs/module-tree-leaf-coverage.md; it is linked fromREADME.md.Tests run
CPU only,
meta-device construction; no GPU used (never the RTX 5090). Thread capsOMP_NUM_THREADS=4 MKL_NUM_THREADS=4 OPENBLAS_NUM_THREADS=4 NUMEXPR_NUM_THREADS=4./opt/venvs/cu130t/bin/python -m pytest tests/module_tree/test_issue_4174_model_trees.py tests/module_tree/test_registry_leaf_coverage.py tests/module_tree/test_registered_module_plans.py tests/module_tree/test_nemotron_h_model_tree.py tests/module_tree/test_jamba_model_tree_consumption.py tests/module_tree/test_kimi_linear_native_tree.py tests/module_tree/test_gemma_olmo_family_plan_coverage.py tests/test_bailing_hybrid_support.py tests/test_zamba_support.py tests/test_zamba2_support.py tests/test_gemma4_support.py tests/test_falcon_h1_support.py tests/test_hrm_text_support.py -q-> 626 passed, 16 skipped, 5 xfailed./opt/venvs/rocm101t/bin/python, CPU) -> 114 passed, 16 skipped, 5 xfailed.7c7d70439with the same registry file, target subset -> 12 failed, 5 passed.ruff check gptqmodel docs/eora tests setup.py-> All checks passed.Residual risk / out of scope
:!(unchanged BF16 behavior) instead of undeclared. Quantizing those shared blocks is a separate behavioral change and is not done here.mllamacross-attention remains FP (known TODO in the issue); the registry test records it as an explicit xfail.unlimited_ocrandgranitemoehybridare xfailed because their definitions are outside this issue's file ownership.glm4vpasses on Defuser >= 0.0.31; the local venv has 0.0.29, so it is xfailed only for that version.bailing_moeandgrinmoeconfigs are remote-code only; the registry sweep skips them (no network) and their layouts are pinned by local synthetic module tests.