Repository navigation
fix(rco): derive allocatable projections from model definition tags - #3564
Merged
Merged
Conversation
`scripts/gsq_paper/rco_allocate.py` and `rco_materialize.py` each repeated a
seven-name tuple:
PROJECTIONS = ('self_attn.q_proj', ..., 'mlp.down_proj')
An architecture that adds a projection therefore had those tensors dropped
from the width database, the bit budget and the merge -- silently. Ripple-65B
has a gated attention projection `self_attn.g_proj`, so 80 of its 640
quantised modules were never allocated, and the 560 that were got an
assignment chosen against a budget computed from the wrong denominator.
Demonstrated on the previous code with an 8-projection block:
projections actually in the block : 8
projections RCO would allocate : 7
SILENTLY DROPPED : ['self_attn.g_proj']
`gptqmodel/quantization/rco.py` now exposes `discover_projections`, which
walks the live module tree: any `nn.Linear` under an indexed block is
allocatable, minus the vocabulary projections. That covers extra attention
projections, fused `qkv_proj`-style modules and MoE expert projections without
a per-architecture list. `block_of` reports the decoder index, and
`DEFAULT_PROJECTIONS` keeps the paper's seven names as the documented default.
Both scripts now derive the set from the model (or, for the materializer, from
the assignment itself, which is the authority on what the checkpoint holds)
and fall back to the tuple only when discovery yields nothing, so existing
staged arms keep rebuilding exactly the tensors they were written with.
Use the effective module tree and its existing parser to resolve decoder boundaries, exclusion/capture tags, expert placeholders, and runtime aliases. Honor definition hooks and strict missing-module checks. Remove static projection lists, name blacklists, suffix matching and numeric-index guessing. Share the per-block inventory across allocation, packed arm restoration, assignment validation and staged export. Validate against the live definition rather than the assignment, and reject incomplete packed checkpoints through strict loading. Support block-relative leaves without a parent path. Cover renamed modules, heterogeneous blocks, experts, tree variants, effective overrides, incomplete assignments, packed bytes and an eighth export projection. Validation: 101 passed, 3 skipped on CPU, including CLI allocation/materialization and save/reload; Ruff and git diff --check 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.
RCO's seven-projection Llama list omits additional declared projections such as Ripple's attention gate. That omission changes the allocation budget and prevents complete materialization. Discovering arbitrary indexed Linear modules also includes modules the definition explicitly excludes and confuses numeric ancestors or expert indices with decoder blocks.
This change resolves projection identity and decoder boundaries from the loaded wrapper's effective
module_tree, using the existing definition parser. It honors#boundaries,:!and:?exclusions, expert expansion, runtime aliases, per-instance tree overrides, definition hooks, and strict missing-module checks. There is no static projection list, suffix filter, vocabulary-name blacklist, or inferred numeric block index.Allocation, staged-arm reconstruction, assignment validation, and export consume the same per-block inventory:
.weightentries.Validation: 101 passed, 3 skipped on CPU with Torch 2.8.0 and Transformers 5.22.1. Ruff and
git diff --checkpass.Coverage includes renamed modules and numeric ancestors, excluded/capture-only leaves, expert placeholders, heterogeneous blocks, multiple tree variants, effective overrides, Llama/Ricursive declaration differences, incomplete assignments, packed-byte preservation, an eighth export projection, and the real allocation/materialization CLI with save/reload and exact logits on a tiny local Llama model.
The three skips require MPS/accelerator capabilities. MLX execution and a full Ripple checkpoint were not tested; the Ricursive discovery check uses its real definition with a synthetic module tree.