Skip to content

feat(sensenova): add SenseNova-Loop 9B (sensenova_loop) support (#4865) - #4897

Merged
Qubitium merged 1 commit into
mainfrom
feat/sensenova-loop-9b
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
feat/sensenova-loop-9b

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #4865.

What

Adds a GPTQ definition for OpenSenseNova/SenseNova-Loop
(sensenova/SenseNova-Loop-9B), whose config declares
model_type = "sensenova_loop" plus auto_map remote code.

Before this PR check_and_get_model_definition() returned BaseQModel for that
model_type, so GPTQModel.load() / quantize() failed with
"no explicit module_tree". Verified on origin/main:

main resolves to: BaseQModel

Checkpoint facts the definition is built on

From the public sensenova/SenseNova-Loop-9B-Preview checkpoint (the 9B release
itself is gated, so no release weights were downloaded):

decoder model.language_model.layers.0..31 (Qwen3.5 VL layout, plus model.visual.*)
layer types linear_attention ×3 + full_attention ×1, repeating (Qwen3.5 DeltaNet)
loop loop_settings = {start: 4, end: 28, eval_count: 2, counts: [2]}
mHC mhc = {start: 4, end: 28, streams: 2, iterations: 20, fixed_identity: false}
auxiliary mtp.safetensors with mtp.* draft-head tensors

loop_settings makes physical layers 4..27 execute twice while re-using the
same physical layer objects, so a single quantized copy per physical layer is
correct and the calibration Hessian accumulates over both visits (the looper
already handles looped/recurrent decoders).

Why the mHC routers need explicit handling

mhc_attn / mhc_ffn are not nn.Linear. Each holds a raw FP32
weight ([2*streams + streams**2, streams*hidden]) plus bias, the remote
forward raises RuntimeError unless they stay FP32, and the checkpoint stores
them as FP32 (_keep_in_fp32_modules = ["mhc_attn", "mhc_ffn"]).

They are therefore absent from the module tree (so they are never quantized
leaves), and SenseNovaLoopQModel.should_quantize_module() now refuses any
mhc_* path. That second guard matters because should_quantize_module() is
also the load/re-save hook: without it, a future checkpoint that shipped the
routers as nn.Linear would be silently quantized and then fail at forward.

Changes

  • gptqmodel/models/definitions/sensenova_loop.py — new
    SenseNovaLoopQModel(Qwen3_5QModel): require_trust_remote_code = True,
    Qwen3.5 VL tree, mtp prefix exclusion, mHC exclusion hook, and
    fusable = None.
  • gptqmodel/models/auto.py — import + MODEL_MAP["sensenova_loop"].
  • tests/test_sensenova_loop_support.py — 11 contracts: model-type dispatch,
    remote-code/processor requirement, VL decoder layout, the tree still equalling
    Qwen3.5's, the exact quantized leaf set, "no mhc entry in the tree", every
    declared path resolving against the checkpoint's real per-layer tensor
    suffixes, mHC not being a quantization candidate, the
    should_quantize_module guard, and fusion being withheld.
  • tests/module_tree/fixtures/{registered_module_plans,fusable_models}.json —
    registry plan case and explicit fusion-withheld row.
  • docs/supported-models.md, docs/fusion-model-coverage.md — new row and
    refreshed inventory counts (208 registered / 102 qualified / 106 not).

Fusion is withheld on purpose

fusable = None. MHCDecoderLayer.forward is remote code that calls
self.self_attn(...), so admitting qkv / gate_up roles needs its own
native-forward qualification; declaring it from the inherited Llama layout
alone would be an unverified claim. Requesting fusion on this model type raises
a clear ValueError.

Verification

  • tests/test_sensenova_loop_support.py: 11 passed.
  • Registry contracts (test_registered_module_plans.py,
    test_fusable_models.py, test_model_map_casefold.py,
    test_moe_tags.py, excluding the pre-existing
    test_actual_model_definition_reaches_fusion_planner failures on this host):
    500 passed, 468 skipped.
  • ruff check clean.
  • New test fails on unmodified origin/main (import error / BaseQModel).
  • End-to-end on a tiny random-weight checkpoint built from the public Preview
    remote code (since the 9B weights are gated): GPTQModel.load(..., trust_remote_code=True) -> quantize() (4-bit, group 32) -> save() ->
    GPTQModel.load(saved) -> forward. The saved checkpoint keeps every
    mhc_attn / mhc_ffn weight/bias as F32 (layers 4..27 in the release
    config; the tiny config only scales the layer count down) while
    self_attn.q_proj / mlp.down_proj become 4-bit
    qweight/qzeros/scales, and config.json still reports
    model_type: sensenova_loop.

Known limitation (documented, not changed here)

The definition keeps Qwen3.5's text-only calibration path (modality default),
so image/video calibration for the vision tower is not exercised yet. The
vision tower is not in the tree and stays dense, exactly as for qwen3_5.

@Qubitium
Qubitium force-pushed the feat/sensenova-loop-9b branch from c3698e3 to 9d760c3 Compare November 17, 2026 18:10
OpenSenseNova's `sensenova/SenseNova-Loop-9B` declares
`model_type = "sensenova_loop"` and ships its own remote
`modeling_sensenova_loop.py`, so `GPTQModel.load()`/`quantize()` fell through
to `BaseQModel` and failed with "no explicit module_tree".

The physical decoder is Qwen3.5's VL layout (`model.language_model.layers`,
`model.visual`), so the new definition reuses that tree: q/k/v/o, the
linear-attention `in_proj_qkv`/`in_proj_z`/`out_proj`, and gate/up/down are the
only quantized leaves, exactly as for `qwen3_5`.

Two remote-code features had to be modelled explicitly:

* The looped block (`loop_settings = {start: 4, end: 28, eval_count: 2}`)
  executes physical layers 4..27 twice while reusing the same layer objects, so
  one quantized copy per physical layer is correct and the calibration Hessian
  accumulates over both visits. The looper already supports looped decoders.
* The mHC routers (`mhc_attn`/`mhc_ffn` on layers 4..27) are raw FP32
  parameters, not `nn.Linear`; the remote forward raises unless they stay FP32.
  They are absent from the tree, and `should_quantize_module` now refuses any
  `mhc_*` path so a future checkpoint that stored them as `nn.Linear` still
  keeps them dense.

Auxiliary `mtp.*` draft-head tensors stay out of the model, as they already do
for Qwen3.5.

Fusion is explicitly withheld (`fusable = None`): the mHC decoder layer runs the
remote forward, so QKV/gate-up admission needs its own native-forward
qualification.

Tests: `tests/test_sensenova_loop_support.py` pins the definition to the
published Preview checkpoint layout (per-layer tensor suffix sets copied from
`model.safetensors.index.json`), the registry plan case, the mHC exclusion, and
the fact that the declared tree still equals Qwen3.5's.
Manually verified end-to-end on a tiny random-weight checkpoint built from the
public Preview remote code: quantize (4-bit, group 32) -> save -> reload ->
forward, with `mhc_attn.weight`/`mhc_ffn.weight` preserved as FP32.
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.

feat: add SenseNova-Loop 9B (sensenova_loop) model support

1 participant