--- license: apache-2.0 base_model: sensenova/SenseNova-Loop-9B base_model_relation: quantized pipeline_tag: text-generation language: - en - zh tags: - nvfp4 - fp8 - modelopt - quantized - looped-transformer - vllm - blackwell - custom_code --- # SenseNova-Loop-9B-NVFP4 NVFP4 / FP8 mixed-precision quantization of [sensenova/SenseNova-Loop-9B](https://huggingface.co/sensenova/SenseNova-Loop-9B), made with NVIDIA's official tool ([TensorRT Model Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer) 0.48.0, `hf_ptq.py`) and NVIDIA's model-specific recipe for the Qwen3.5 architecture that SenseNova-Loop builds on. | | BF16 | This model | |---|---|---| | Size on disk | 19 GB | **8.3 GB** | | Weights in GPU memory (vLLM) | 16.75 GiB | **7.05 GiB** | | Decode speed, 1 request (DGX Spark) | 7.5 tok/s | **21.9 tok/s (2.9x)** | > [!IMPORTANT] > **Text only, vLLM only, patched vLLM required.** No released inference engine supports SenseNova-Loop yet, > quantized or not. This repo includes a ready-to-build vLLM image (`vllm/`): the open vLLM PR > [#64832](https://github.com/vllm-project/vllm/pull/64832), which adds SenseNova-Loop (text-only), plus a > small patch so it loads quantized checkpoints. Loading this checkpoint with plain `transformers` is not supported. ## Quick start ```bash # 1. Download the repo (includes the vLLM patch) hf download sambit9238/SenseNova-Loop-9B-NVFP4 --local-dir SenseNova-Loop-9B-NVFP4 # 2. Build the patched vLLM image docker build -t vllm-sensenova-nvfp4 SenseNova-Loop-9B-NVFP4/vllm # 3. Serve (OpenAI-compatible API on :8000) docker run --gpus all --ipc=host -p 8000:8000 \ -v $PWD/SenseNova-Loop-9B-NVFP4:/model:ro \ vllm-sensenova-nvfp4 /model \ --served-model-name SenseNova-Loop-9B-NVFP4 --trust-remote-code \ --max-model-len 131072 --enable-prefix-caching \ --enable-auto-tool-choice --tool-call-parser qwen3_coder --reasoning-parser qwen3 ``` The model thinks before answering (reasoning appears in `reasoning_content`). The base model's recommended sampling is `temperature=1.0, top_p=0.95`; leave enough `max_tokens` for long reasoning. Tested on an NVIDIA DGX Spark (GB10, 128 GB unified memory). It should also run on other GPUs vLLM supports for NVFP4 weight-only (Marlin) and FP8 (Ada / Hopper / Blackwell). ## What was quantized Recipe: `model_type/qwen3_5/ptq/w4a16_nvfp4_mse-fp8_attn-kv_fp8_cast` (ships with ModelOpt 0.48.0). | Part | Format | |---|---| | MLP `gate/up/down_proj` and `lm_head` (97 linears) | **NVFP4** weights (W4A16, 16-element blocks, FP8 block scales), MSE-calibrated | | Full attention `q/k/v/o_proj` and Gated DeltaNet `in_proj_qkv`, `in_proj_z`, `out_proj` (104 linears) | **FP8** E4M3 weights and activations, per-tensor | | KV cache | FP8 | | Gated DeltaNet `in_proj_a/b`, `A_log`, `dt_bias`, mHC routers, norms, `loop_gate`, embeddings | unchanged (BF16 / FP32) | | Vision tower, MTP head (`mtp.safetensors`) | unchanged (BF16); not used by the vLLM path | Because layers 4–27 run twice (the loop), each looped weight is stored once and used by both passes, as in the base model. **Calibration:** the `hf_ptq.py` default `cnn_nemotron_v2_mix` (cnn_dailymail + nvidia/Nemotron-Post-Training-Dataset-v2), 1,024 samples × 512 tokens. ```bash python hf_ptq.py --pyt_ckpt_path SenseNova-Loop-9B --trust_remote_code \ --recipe model_type/qwen3_5/ptq/w4a16_nvfp4_mse-fp8_attn-kv_fp8_cast \ --export_path SenseNova-Loop-9B-NVFP4 python scripts/restore_fp32_modelopt.py SenseNova-Loop-9B SenseNova-Loop-9B-NVFP4 ``` The second step matters: the ModelOpt export downcasts the 48 FP32 Gated DeltaNet `A_log` / `dt_bias` tensors to BF16. `restore_fp32_modelopt.py` (included) puts back the exact source tensors and touches nothing that was quantized. > **About Blackwell FP4.** Blackwell GPUs have FP4 tensor cores, but this recipe keeps activations in 16-bit for the NVFP4 > layers (W4A16), so vLLM runs them with the Marlin weight-only kernel. The speedup comes from moving 4-bit weights, > not from FP4 math. On a memory-bandwidth-bound device like DGX Spark that is where decode time goes. ## Evaluation: BF16 vs NVFP4 Both models ran in the same patched vLLM build with identical server flags on one NVIDIA DGX Spark (GB10): thinking mode on, greedy decoding (temperature 0), output capped at 8,192 tokens. lm-evaluation-harness ran through the chat API. | Check | BF16 | NVFP4 | Notes | |---|---|---|---| | **Quality** | | | | | GSM8K (8-shot CoT, flexible-extract) | 96.0% (±1.1) | 93.3% (±1.4) | 300 questions; strict-match 76.7% vs 69.0% (answer-format misses) | | IFEval (prompt-level strict / loose) | 71.0% / 74.7% | 71.7% / 75.7% | 300 prompts; instruction-level strict 77.9% vs 78.7%, loose 80.3% vs 81.4% | | MMLU-Pro (14 subjects × 25) | 56.6% (±2.4) | 54.6% (±2.4) | 350 questions; gap within noise; both understated by the output cap (see below) | | **Tool calling** (`qwen3_coder` parser) | | | | | Tool call parse / right tool / valid args (T=0) | 100% / 100% / 100% | 100% / 100% / 100% | 105 tool cases | | Tool call exact argument match (T=0) | 97.1% | **85.7%** | NVFP4 rewords free-text values (see below) | | Tool call parse / right tool / valid args (T=0.7, 3 runs) | 99.4% / 99.4% / 99.4% | 100% / 100% / 100% | 315 tool calls per model | | Tool call exact argument match (T=0.7, 3 runs) | 93.3% | 89.8% | 315 tool calls per model | | Correctly not calling a tool (T=0 / T=0.7) | 100% / 99.3% | 100% / 99.3% | 45 no-tool cases (135 at T=0.7) | | **Long context** (needle in a haystack) | | | | | Needle retrieval @8k / @32k | 5/5, 5/5 | 5/5, 4/5 | | | Needle retrieval @64k | 5/5 | 4/5 | | | Needle retrieval @~120k | 4/5 | 5/5 | | | **Closeness to BF16** | | | | | Mean KL vs BF16, chat (238,971 positions) | — | 0.047 | p99 KL 0.51; 200 UltraChat conversations | | Mean KL vs BF16, wikitext (50,618 positions) | — | 0.110 | p99 KL 1.18; 200 passages | | Top-1 token agreement, chat / wikitext | — | 92.6% / 85.6% | | | Wikitext perplexity | 22.57 | 21.74 | Computed from top-20 logprobs, approximate; not a real gain | | **Speed and memory** | | | | | Size on disk | 19 GB | 8.3 GB | 2.3x smaller | | Weights in GPU memory | 16.75 GiB | 7.05 GiB | 2.4x smaller | | KV cache available (`--gpu-memory-utilization 0.8`) | 77.8 GiB | 87.1 GiB | | | Decode, 1 request (1,024 in / 512 out) | 7.5 tok/s (132 ms/token) | 21.9 tok/s (45 ms/token) | **2.9x faster** | | Decode, 8 concurrent requests | 58 tok/s | 130 tok/s | 2.2x faster | | Prefill, 4 concurrent 8k-token prompts | 1,418 tok/s | 1,530 tok/s | about the same | **Reading the results.** - **Instruction following and knowledge hold up.** IFEval is unchanged and the MMLU-Pro gap is within noise. - **GSM8K drops slightly.** The loss is mostly answers that miss the strict "The answer is X" format. - **Tool arguments are the main regression.** NVFP4 always picks the right tool and produces well-formed calls, but it more often rewrites free-text argument values (for example a refund `reason`) in its own words instead of copying them exactly from the user message. If your tools need verbatim strings, validate them or use BF16. - **Decode is 2.9x faster at 1 request.** SenseNova-Loop runs 56 layer passes per token from 32 physical layers, so decode reads the looped weights twice per token. That makes weight size matter even more than for a normal 9B model. - KL figures use each model's top-20 log-probabilities, so they are approximate. An exact full-vocabulary check outside vLLM (64 prompts of 1,024 tokens) gave KL 0.050 on chat and 0.091 on wikitext, in line with these. > **These are not the model's official scores.** The 8,192-token output cap is our test setting, not a model limit. > On MMLU-Pro many answers were still reasoning when they hit it and returned nothing, so both absolute scores are > understated. Greedy decoding also differs from the base model's recommended sampling (`temperature=1.0, top_p=0.95`). > The comparison between the two builds is like-for-like. ## The vLLM patch (`vllm/`) | File | What it is | |---|---| | `Dockerfile` | `vllm/vllm-openai` nightly (0.31.1rc1.dev376, pinned by digest) + the overlay | | `overlay/vllm/...` | The 8 Python files from PR #64832 (head `86014ad`), with our patch applied | | `pr64832_vllm_only.diff` | The PR's vLLM changes, for reference | | `quant_patch.diff` | Our change on top of the PR (78 lines) | The PR rejects quantized checkpoints. The patch: 1. passes `quant_config` into the model and the `lm_head`; 2. uses the Qwen3.5 `packed_modules_mapping`, so vLLM can load the fused `qkv` / `gate_up` / `in_proj_qkvz` layers (ModelOpt already exports them with shared scales); 3. maps ModelOpt per-layer names from physical layers (`model.language_model.layers.P.*`) to vLLM's unrolled loop executions (`model.layers.E.*`), so both passes of a looped layer get the right format. The overlay replaces whole files and only fits the pinned base image. Once SenseNova-Loop support lands in vLLM, the patch should shrink to the quantization part. ## Limitations - **Text only.** The vLLM PR does not run the vision tower, so image and video input were not tested. - **No speculative decoding.** The MTP head is included unchanged, but the vLLM PR does not support it. - **Tool-argument fidelity drops** (see above). - **Small evaluation subsets** (300–350 questions). Differences under ~2–3 points are within noise. - The base model's own limitations apply. See its [model card](https://huggingface.co/sensenova/SenseNova-Loop-9B). ## License and credits Apache 2.0, same as the [base model](https://huggingface.co/sensenova/SenseNova-Loop-9B). All credit for the model goes to the SenseNova team. Quantization uses NVIDIA TensorRT Model Optimizer. vLLM support is from PR #64832 by its authors.