Skip to content

fix(rco): derive allocatable projections from model definition tags - #3564

Merged
Qubitium merged 2 commits into
ModelCloud:mainfrom
Qubitium:fix/rco-discovery-generic
Nov 6, 2026
Merged

Qubitium merged 2 commits into
ModelCloud:mainfrom
Qubitium:fix/rco-discovery-generic

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • Each block uses its own declared live projections, including heterogeneous blocks and additional projections.
  • Packed arms are restored using their packed state and strict loading; discovery does not look for dense .weight entries.
  • Assignment completeness is checked against the model definition. Omitting a projection from every block cannot redefine what counts as complete.
  • Export validates every declared packed projection and writes its selected width to the dynamic configuration.
  • Legacy block-level assignments expand through the same definition-derived inventory.

Validation: 101 passed, 3 skipped on CPU with Torch 2.8.0 and Transformers 5.22.1. Ruff and git diff --check pass.

tests/test_rco.py
tests/test_rco_paper.py
tests/test_rco_discovery.py
tests/test_gsq_layer_bit_allocation.py
tests/test_gsq_staged_public.py

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.

`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.
@Qubitium Qubitium changed the title fix(rco): discover allocatable projections instead of hardcoding Llama's fix(rco): derive allocatable projections from model definition tags Nov 6, 2026
@Qubitium
Qubitium merged commit b2dcecc into ModelCloud:main Nov 6, 2026
1 check passed
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