Skip to content

fix: regressions from #4620 (CPTC HF refusal, LFM3/DeepSeek-V2 ports, optional vision deps) - #5978

Merged
Qubitium merged 4 commits into
mainfrom
fix/pr4620-regressions
Nov 22, 2026
Merged

Qubitium merged 4 commits into
mainfrom
fix/pr4620-regressions

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Follow-up to #4620. An audit of main at d2dfb9385 against base 0071b1aa0 found four blocking regressions plus medium import/packaging/doc fallout.

Blocking

  1. CPTC HF interop — Port every supported model onto the Transformers 5.23 ABI; never patch Transformers #4620 deleted gptqmodel/utils/hf_cptc.py and its registration but did not add cptc to REFUSED_HF_QUANT_METHODS, so plain Transformers silently decoded CPTC weights as another layout. tests/test_bnb_hf_refusal_4664.py failed 12/12 on head and passed on base.
  2. LFM3 AWQ numerics — LFM3QModel.awq_get_modules_for_scaling folded an attention layer's operator_norm into q/k/v. Compensating that fold rewrites the non-quantized gate_proj, and the AWQ round trip moved by 0.43 max-abs (test_lfm3_local_port.py: 13 failed / 23 passed). Only ffn_norm is neutral on attention layers; conv layers keep both.
  3. DeepSeek-V2 root materialization — shell_module_materialize(..., module_path="") raised ValueError: Provided module is the root for checkpoints without layer-wise shards (test_deepseek_v2_local_port.py: 8 failed / 78 passed).
  4. The PR's own policy test was red — tests/test_transformers_unpatched.py failed because the [PERF] #5291 (fix of #5268) incomplete: the global-state writer wraps whole dense from_pretrained calls (weight I/O), not the 14 ms dtype window - an optimize()d decode step stalls 23-36 s during a concurrent dense GPTQModel.load #5304/[BUG] GPTQModel.load fails when another thread runs a transformers construction (user from_pretrained or requantize(norm) teacher): class-wide no_tie_weights untie lm_head, unguarded default_dtype_before -> false 'corrupted state' #5421 construction guard replaces five Transformers entry points while the docs claimed zero patches. Documented the single pass-through exception and allow-listed exactly those five; the test now passes.

Medium

  • Optional vision deps: kimi_k25, lfm3_vl, unlimited_ocr and nemotron_omni imported torchvision-backed processors at module import (26 failures in test_native_processor_resolution.py); backend="pil" could not resolve without torchvision; _LazyMapping.__len__ returned 0. Now lazy imports, on-demand PIL sibling resolution, and real mapping semantics. Registry suite with vision extras blocked: 28 failed → 0 failed (283 passed / 27 skipped); with extras: 300 passed / 10 skipped.
  • Registry generator: the committed tree only matched a torchvision-present generation. The generator now uses _class_to_module and reconstructs the video-processor table; reproduction is byte-identical either way.
  • Packaging: gptqmodel_ext/ttbfp sources, exllamav3/CREDITS.md and nn_modules/LICENSE were missing from wheel/sdist; the Tenstorrent manifest pinned defuser==0.0.32 below the >=0.0.33 floor, omitted tiktoken, and pinned logbar/pypcre below their floors.
  • Docs: removed the export(..., "hf") API (gone), the deleted normalize_hf_config_compat/remote-shim text, the rocm_llc claims, the gptqmodel['vllm'] extra hint; fixed the deepseek_v41 MODEL_MAP claim; marked transformers-5-compat.md historical.
  • DeepSeek-V2 router: apply routed_scaling_factor after normalization when norm_topk_prob=True. Official DeepSeek-V2 configs use false, so the default path is unchanged.

Verification

Python 3.13.15 / torch 2.15 CPU / transformers 5.23.0:

  • test_lfm3_local_port.py + test_lfm3_omni_local_port.py + module-tree LFM3: 71 passed
  • test_deepseek_v2_local_port.py: 88 passed
  • test_bnb_hf_refusal_4664.py + test_hf_refusal_remedy_4676.py: 33 passed
  • test_transformers_unpatched.py: 1 passed
  • 13-file registry suite, torchvision/timm/einops blocked: 283 passed, 27 skipped, 0 failed; with extras: 300 passed, 10 skipped
  • 19-file regression set: 448 passed, 10 skipped, plus one network-only failure (test_norm_teacher_load_takes_the_model_load_lock needs the Hub)

Not in this PR

  • AWQ scale search is intentionally not restored for Bailing-MoE, PanGu, Nemotron-H and Inkling2 (the PR falls back to plain quantization); restoring it needs per-family fold qualification.
  • Full-suite-only module-tree failures in the new interns1/internvl tests pass in isolation; needs a Linux CI rerun with tracebacks.
  • Pre-existing failures (checkpoint dtype, PARO guard, failed-run offload, HummingLinear fusion contract) reproduce at the base SHA and are out of scope.

- Refuse plain-Transformers loads of CPTC checkpoints. #4620 removed the
  `hf_cptc` registration without adding `cptc` to the refusal map, so HF
  silently decoded CPTC weights as another layout.
- LFM3: do not fold an attention layer's `operator_norm` into q/k/v. The
  fold rewrites the non-quantized `gate_proj`; only `ffn_norm` (and both
  norms on conv layers) is neutral. This aligns the code with
  `test_awq_search_uses_only_verified_hybrid_norms` and fixes the 0.43
  AWQ round-trip error.
- DeepSeek-V2: apply `routed_scaling_factor` after normalization when
  `norm_topk_prob=True`, matching the legacy MoE gate and native
  Transformers semantics.
- `_resolve_qualified_name`/`materialize_submodule` accept the root's
  explicit empty path so checkpoints without layer-wise shards can
  materialize the root instead of raising "Provided module is the root".
- #4620 claims GPT-QModel never patches Transformers, but the #5304/#5421
  construction guard replaces five entry points at import. Document that
  single pass-through exception and allow-list exactly those entries in
  `test_transformers_unpatched.py` instead of leaving the PR's own policy
  test red.
- Remove the documented `export(..., "hf")` API (removed by #4620), the
  deleted `normalize_hf_config_compat` / remote-code shim description, the
  removed `rocm_llc` back-port, the removed `gptqmodel['vllm']` extra and
  the stale "deepseek_v41 not in MODEL_MAP" claim.
- Mark `docs/transformers-5-compat.md` historical and remove the reference
  to its deleted test.
- Drop the leftover `from_quantized: adapter:` debug print.
- Move torchvision-backed processor imports behind the processor entry
  points for kimi_k25, lfm3_vl, unlimited_ocr and nemotron_omni so config,
  model and tokenizer loading work without the `[vision]` extra.
- `_by_name` resolves the vendored `*ImageProcessorPil` sibling on demand
  and tolerates optional-backend import/annotation failures, so
  `backend="pil"` works without torchvision.
- `_LazyMapping` reports its real length and iterates/items/values.
- The registry generator derives class homes from Transformers'
  `_class_to_module` and reconstructs torchvision video-processor names,
  so `test_generator_reproduces_the_committed_tree` is byte-identical with
  or without torchvision installed.
- New module-tree vision ports use `pytest.importorskip` so a base install
  collects them cleanly (117 tests skipped, not 10 collection errors).
- Ship `gptqmodel_ext/ttbfp` sources, `exllamav3/CREDITS.md` and
  `nn_modules/LICENSE`; align the Tenstorrent manifest with the
  `defuser>=0.0.33` / `logbar` / `pypcre` floors and add `tiktoken`.
Add a TYPE_CHECKING-only import so ruff F822 accepts the lazy module
__getattr__ export.
@Qubitium
Qubitium merged commit d6244da into main Nov 22, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/pr4620-regressions branch November 22, 2026 02:45
Qubitium added a commit that referenced this pull request Nov 22, 2026
…rip, PARO/offload, LFM3 tests) (#5980)

* fix(awq): restore scale search for PanGu, Bailing-MoE, Nemotron-H, Inkling2

#5978 deferred AWQ scaling for four families by returning empty fold groups.
Restore every group that measures output-neutral on the real forward and keep
only the folds that are provably non-neutral:

- gpt_pangu: generic planner, minus the top block's `attn.q_proj` in the
  `ln_1` group (it consumes `custom_query`, not the norm). `ln_1 -> k/v`,
  `attn.v_proj -> attn.c_proj`, `ln_2 -> mlp.c_fc` are neutral; the
  `c_fc -> c_proj` source stays `nosrc`.
- bailing_moe: drop the `isinstance(BailingConfig): return []` override and
  use the generic planner. All groups are neutral on dense/mla/hybrid/
  legacy_gqa (worst 1.9e-07).
- nemotron_h: generic planner for dense Mamba/attention/MLP mixers. Only the
  native `NemotronHMoE` mixer stays plain (one norm feeds shared and routed
  experts; shared-only fold 2.4e-2). Also move `A_log`/`D`/`dt_bias` out of
  the `mixer` tuple: as Parameters they closed the q/k/v subset and folded
  `o_proj` from the block norm (8.1e-2).
- inkling2_loop: keep the per-expert `up_proj -> down_proj` folds
  (1.9e-07..3.5e-06). Drop the tree-order `post_attention_layernorm` and
  `o_proj.linear -> gate_proj` groups, which follow module order rather than
  data flow and change the layer output by 8e-2..4e-1.

Tests pin neutrality on production configs and pin the dropped folds as
non-neutral, so a future planner change cannot silently reintroduce them.

* fix(quantize): honor the quantization device dtype and leave the model in eval

Three independent round-trip bugs that made an in-session model disagree with
the checkpoint it just saved:

- loader: auto dtype only followed `quantize_config.device` for MiMo sources.
  On an MPS/CUDA host a CPU quantization therefore loaded and re-saved the
  dense source in the host dtype (fp16) while a CPU reload resolved bf16,
  so the round trip was not dtype-preserving. Honor the quantization device
  for every `BaseQuantizeConfig`.
- torch qlinear: wide `_decode_248_weight` cast fp16 scales to bf16 before
  the multiply while the fused/compiled path multiplies in fp32 and rounds
  once. Compute wide decodes in fp32 (fp64 when requested) and cast the
  product once, so eager and compiled decode are bitwise equal (#5740).
- base: the quantize loop installs fresh kernel modules that start in
  training mode; their `train` transition also restores the checkpoint
  zero-point layout. Call `model.eval()` at the end of `quantize()` so an
  in-session forward decodes through the same path as the saved checkpoint.

* fix: stop a PARO placeholder rotation and a cached import traceback from failing runs

- paro_processor: `pack_module()` treated the minimal placeholder triple
  `pairs=(1,)`, `theta=(1,)`, `channel_scales=(1,)` used by packing-only
  callers as real rotation state and raised the #5659 `(8,128)` vs `(1,)`
  shape error. Keep the freshly built layer's identity rotation for that
  exact placeholder; a real krot mismatch still raises.
- humming: the optional-import `ModuleNotFoundError` was cached with its
  traceback. Kernel discovery imports every qlinear module from inside
  `quantize()`, so the retained stack pinned the model and its run-exit
  state; `del model` could never run the offload finalizer and left
  `offload/run-*` behind (#4595). Clear `__traceback__`/`__context__`/
  `__cause__`; type and message are unchanged.

* test: record Humming as fusion-excluded and fix the PARO looper stub

- test_fusion_kernel_backends: `HummingLinear`/`AwqHummingLinear` were added
  by #5966 without a fusion spec or an `EXCLUDED` entry, so the registry
  contract failed. Humming's `post_init()` replaces checkpoint tensors with
  shape-padded JIT operands and a per-layer `LayerConfig`; there is no
  concatenable native layout, so list both as excluded with that rationale.
- test_paro: `_replay_layer_outputs()` now always passes `consume_inputs=`
  (since #5928) but the first `_DummyLooper` stub kept the old signature.
  Accept and discard the keyword; test semantics are unchanged.

* test(lfm3): match the shipped AWQ fold contract

#5978 suppresses the `operator_norm -> q/k/v` fold on LFM3 attention layers
because the sigmoid gate consumer is left on the divided norm (uncompensated
delta 5.5e-2; compensating it rewrites non-quantized gate weights). The conv
layer still folds both input norms. Update the LFM3 tests to that contract
instead of the pre-#5978 expectation, and pin the suppression plus its
measured error so the decision is explicit.

* test(fusion): skip the TorchInt8Linear cache-race pair on darwin

`TorchInt8Linear` has no darwin implementation, so the two race tests failed
with a backend-availability error rather than exercising the cache. Gate the
module on the platform the kernel supports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant