Repository navigation
feat(sensenova): add SenseNova-Loop 9B (sensenova_loop) support (#4865) - #4897
Merged
Merged
Conversation
Qubitium
force-pushed
the
feat/sensenova-loop-9b
branch
from
November 17, 2026 18:10
c3698e3 to
9d760c3
Compare
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.
Qubitium
force-pushed
the
feat/sensenova-loop-9b
branch
from
November 17, 2026 18:23
9d760c3 to
1882e8f
Compare
This was referenced Nov 17, 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.
Closes #4865.
What
Adds a GPTQ definition for OpenSenseNova/SenseNova-Loop
(
sensenova/SenseNova-Loop-9B), whose config declaresmodel_type = "sensenova_loop"plusauto_mapremote code.Before this PR
check_and_get_model_definition()returnedBaseQModelfor thatmodel_type, soGPTQModel.load()/quantize()failed with"no explicit module_tree". Verified on
origin/main:Checkpoint facts the definition is built on
From the public
sensenova/SenseNova-Loop-9B-Previewcheckpoint (the 9B releaseitself is gated, so no release weights were downloaded):
model.language_model.layers.0..31(Qwen3.5 VL layout, plusmodel.visual.*)linear_attention×3 +full_attention×1, repeating (Qwen3.5 DeltaNet)loop_settings = {start: 4, end: 28, eval_count: 2, counts: [2]}mhc = {start: 4, end: 28, streams: 2, iterations: 20, fixed_identity: false}mtp.safetensorswithmtp.*draft-head tensorsloop_settingsmakes physical layers 4..27 execute twice while re-using thesame 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_ffnare notnn.Linear. Each holds a raw FP32weight([2*streams + streams**2, streams*hidden]) plusbias, the remoteforward raises
RuntimeErrorunless they stay FP32, and the checkpoint storesthem 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 anymhc_*path. That second guard matters becauseshould_quantize_module()isalso the load/re-save hook: without it, a future checkpoint that shipped the
routers as
nn.Linearwould be silently quantized and then fail at forward.Changes
gptqmodel/models/definitions/sensenova_loop.py— newSenseNovaLoopQModel(Qwen3_5QModel):require_trust_remote_code = True,Qwen3.5 VL tree,
mtpprefix exclusion, mHC exclusion hook, andfusable = 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
mhcentry in the tree", everydeclared path resolving against the checkpoint's real per-layer tensor
suffixes, mHC not being a quantization candidate, the
should_quantize_moduleguard, 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 andrefreshed inventory counts (208 registered / 102 qualified / 106 not).
Fusion is withheld on purpose
fusable = None.MHCDecoderLayer.forwardis remote code that callsself.self_attn(...), so admittingqkv/gate_uproles needs its ownnative-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.test_registered_module_plans.py,test_fusable_models.py,test_model_map_casefold.py,test_moe_tags.py, excluding the pre-existingtest_actual_model_definition_reaches_fusion_plannerfailures on this host):500 passed, 468 skipped.
ruff checkclean.origin/main(import error /BaseQModel).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 everymhc_attn/mhc_ffnweight/biasasF32(layers 4..27 in the releaseconfig; the tiny config only scales the layer count down) while
self_attn.q_proj/mlp.down_projbecome 4-bitqweight/qzeros/scales, andconfig.jsonstill reportsmodel_type: sensenova_loop.Known limitation (documented, not changed here)
The definition keeps Qwen3.5's text-only calibration path (
modalitydefault),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.