Repository navigation
fix(awq): preserve scale-search routing and reject incomplete replay groups - #4144
Merged
Merged
Conversation
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
Qubitium
marked this pull request as ready for review
November 15, 2026 12:33
Contributor
Devin Review🟢 Devin Review found nothing to fix · View findings |
6 tasks done
This was referenced Nov 15, 2026
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.
Summary
Make AWQ scale search and final folding agree, reject incomplete/ambiguous replay groups, and repair confirmed architecture-boundary mistakes with the existing module-tree syntax. No DSL or automatic graph tracing.
The source audit covered 206 model types / 182 definitions. Its 14 unsafe-acceptance entries led to conservative corrections in 13 definition families; this is not certification of every supported model.
What Changed
Q(W * s) / son the original input and leaves non-quantized routers/shared gates unchanged. Final folding still compensates declared consumers.finally. Validate live bindings, widths, replay containment, declared-target execution and equal reference/candidate chunk counts.fallback=None; conflicts always raise.:nosrcboundaries/explicit owners for AXK2, GLM-MoE-DSA, LongCatFlash, Falcon Mamba, Moss, Gemma3n, Inkling and original Qwen.Tests
Python 3.12.16, Torch 2.15.0, Transformers 5.22.2, Defuser 0.0.31; CPU only.
-savoids an older user-site Defuser shadowing the installed supported version.python -s -m pytest \ tests/test_awq_{scale_search_safety,moe_router_scaling,scaling_groups,scale_folding,weight_mean,per_module_bits,empty_groups,mla_scaling,dynamic_group_size,position_kwargs,rank_and_empty,rotary_device,vl_rotary_resolution,scale_search_memory,clip_consistency,affine_range}.py \ tests/module_tree/test_{registered_module_plans,awq_relationships,granite_swa_model_tree,definition_subset_ordering}.py \ -q -o addopts='' -o log_cli=false --timeout=300 \ -o junit_family=legacy --junitxml=awq-final-cpu.xml # 929 passed, 100 skipped, 1 warning in 37.36s # Skips: 89 CUDA unavailable, 9 absent local model fixtures, 2 non-buildable HF families. python -s -m ruff check gptqmodel docs/eora tests setup.py PATH=/home/ubuntu/.pyenv/versions/3.12.16/bin:$PATH bash format/check.sh python -s -m compileall -q gptqmodel tests git diff --check # All passedType-checking all 13 touched definitions reports two pre-existing Inkling nullable-attribute diagnostics, identical to the pre-follow-up source. No new definition diagnostics. The original processor comparison also reported no new diagnostics.
Independent Torch FP32 oracles cover candidate loss/selection and transformed outputs; FP32/FP16/BF16 identity-quantizer tests check router neutrality, and injected failures check exact rollback. Restoring old search code produced 12 expected failures. Old architecture declarations also fail the new native regression checks.
Trained Hugging Face CPU checkpoints
Downloads allow only JSON/tokenizer/safetensors, with
trust_remote_code=False. Tests perform real CPU AWQ quantization, verify packed counts and floating-point routers, enforce finite outputs and held-out drift limits, save safetensors with no new pickle payloads, explicitly reload FP16, and compare reloaded logits and greedy generation.Model Support / Module Plan
state_dict()entries resolve to deepest owners; quantized owners are declared and non-quantized owners explicitly excluded. Inkling'sglobal_scaleis a native trainable parameter, not a runtime cache.Key nodes:
test_every_inferred_fold_preserves_full_text_outputs,test_real_model_weight_owners_are_declared,test_native_branched_decoders, andtest_cross_branch_groups_reject_incomplete_replayintest_awq_relationships.py.Legacy Moss, InternLM2, MiniCPM and Qwen have separate pinned-source CPU audit probes, rerun against these fixes. Their CI declaration checks do not claim remote full-model/checkpoint qualification. Inkling's fixture exercises the real text backbone under its multimodal checkpoint prefix; Gemma3n exercises its real decoder, not a downloaded multimodal checkpoint.
Logic Flow Documentation
flowchart TD A["AWQProcessor._quantize_layer"] --> B["_validate_scale_group_conflicts"] B --> C{"source or target overlap?"} C -- "yes" --> X["raise _AWQScaleGroupError<br/>no folds applied"] C -- "no" --> P["filter low-sample / missing-feature groups"] P --> D["_search_best_scale<br/>_validate_scale_group"] D --> E{"exact live bindings, widths,<br/>and targets inside replay boundary?"} E -- "no" --> F{"configured fallback enabled?"} E -- "yes" --> G["reference forward<br/>temporary target observation hooks"] G --> H["finally remove observation hooks"] H --> R{"reference replay succeeded?"} R -- "no" --> Y["propagate evaluation exception"] R -- "yes" --> I{"every declared target executed?"} I -- "no" --> F I -- "yes" --> J["_compute_best_scale<br/>20 candidates: Q(W * s) / s<br/>routers and shared gates unchanged"] J --> K["finally restore original weights"] K --> L{"candidate evaluation succeeded?"} L -- "yes" --> M["collect scale results<br/>apply_scale once per source<br/>apply_quant"] L -- "no" --> Y F -- "yes" --> N["warn with group and reason<br/>exclude group from folding and clipping<br/>apply_quant with empty scales"] F -- "no" --> X style X fill:#f8d7da,stroke:#842029,stroke-width:2px style Y fill:#f8d7da,stroke:#842029,stroke-width:2px style N fill:#fff3cd,stroke:#997404,stroke-width:2pxc9efdbacf)awq_processor.py:3099-3119).models/base.py:5540-5546).awq_processor.py:2551-2572).awq_processor.py:3267-3278).finally, covering quantizer, replay, and loss exceptions.awq_processor.py:2352-2359).Existing declarations now control the conservative path:
flowchart TD A["architecture module_tree<br/>parallel stages, :in, nested :!, :nosrc"] --> B["awq_get_modules_for_scaling"] B --> C["_merge_shared_source_nodes"] C --> D["_filter_awq_scaling_sources"] D --> E{"selected source is :nosrc?"} E -- "yes" --> P["drop smoothing group<br/>existing plain quantization path"] E -- "no" --> F["AWQProcessor._quantize_layer<br/>conflict, boundary and execution checks"] F --> G{"complete supported replay?"} G -- "yes" --> H["search and fold once"] G -- "no: _AWQScaleGroupError" --> I{"configured fallback enabled?"} I -- "yes" --> P I -- "no" --> X["raise; no unsafe fold"] F -- "raw forward exception" --> Y["propagate; not a safe fallback"] style P fill:#fff3cd,stroke:#997404 style X fill:#f8d7da,stroke:#842029 style Y fill:#f8d7da,stroke:#842029The architecture qualification table records the per-family before/after changes.
Review Requirements
Kernel Accuracy Requirements
No inference kernel, packer, fusion dispatch or persistent-weight-storage change. Search arithmetic is covered by independent Torch CPU oracles; GPU/native backend qualification is not claimed.
Notes
:nosrcdeliberately uses the existing plain-quantization path. This is distinct from a generated group rejected underfallback=None. Conservative boundaries trade smoothing coverage for correctness.388f82f01: 70 static-appears-safe, 65 CPU-confirmed, 14 unsafe-accepted, 13 safe rejection/fallback, 30 unverified source, 9 unverified execution, 2 unverified layout and 3 raw replay errors.Link to Devin session: https://app.devin.ai/sessions/c7078b36d9ee47ee8105dc9185147b39
Open in Devin Desktop: https://app.devin.ai/desktop/session/c7078b36d9ee47ee8105dc9185147b39?variant=devin
Requested by: @Qubitium