Download vllm/quant_patch.diff from sambit9238/SenseNova-Loop-9B-NVFP4: direct link, hf CLI and curl.
- Browser
- Download file 3.38 kB
-
https://huggingface.co/sambit9238/SenseNova-Loop-9B-NVFP4/resolve/main/vllm/quant_patch.diff
- Command line
-
hf download hf://sambit9238/SenseNova-Loop-9B-NVFP4/vllm/quant_patch.diff
-
curl -L -o quant_patch.diff https://huggingface.co/sambit9238/SenseNova-Loop-9B-NVFP4/resolve/main/vllm/quant_patch.diff
3.38 kB
| --- sensenova_loop.pr_orig.py 2026-11-19 08:55:22.831270918 +0530 | |
| +++ overlay/vllm/model_executor/models/sensenova_loop.py 2026-11-19 08:55:36.438953456 +0530 | |
| ) | |
| +def _remap_quant_config_names(quant_config, config) -> None: | |
| + """Rewrite ModelOpt per-layer names from checkpoint (physical) to vLLM (execution) form. | |
| + | |
| + The checkpoint names `model.language_model.layers.<physical>.*`; this model builds one | |
| + module per execution (`model.layers.<execution>.*`), so a looped physical layer maps to | |
| + several execution prefixes. | |
| + """ | |
| + destinations: dict[int, list[int]] = {} | |
| + for execution, physical in enumerate(config.loop_physical_indices): | |
| + destinations.setdefault(physical, []).append(execution) | |
| + | |
| + def expand(name: str) -> list[str]: | |
| + if name.startswith("model.language_model."): | |
| + name = "model." + name[len("model.language_model.") :] | |
| + if name.startswith("model.layers."): | |
| + _, _, index, suffix = name.split(".", 3) | |
| + if index.isdigit(): | |
| + return [ | |
| + f"model.layers.{e}.{suffix}" for e in destinations.get(int(index), []) | |
| + ] | |
| + return [name] | |
| + | |
| + excl = getattr(quant_config, "exclude_modules", None) | |
| + if isinstance(excl, list) and excl: | |
| + quant_config.exclude_modules = list( | |
| + dict.fromkeys(n for e in excl for n in [e, *expand(e)]) | |
| + ) | |
| + layers = getattr(quant_config, "quantized_layers", None) | |
| + if isinstance(layers, dict) and layers: | |
| + quant_config.quantized_layers = { | |
| + n: v for k, v in layers.items() for n in [k, *expand(k)] | |
| + } | |
| + | |
| + | |
| class SenseNovaLoopForConditionalGeneration( | |
| nn.Module, HasInnerState, IsHybrid, SupportsMRoPE | |
| ): | |
| + packed_modules_mapping = Qwen3_5ForCausalLMBase.packed_modules_mapping | |
| + | |
| @classmethod | |
| def get_mamba_state_dtype_from_config( | |
| cls, vllm_config: VllmConfig | |
| self.config = self.model_config.hf_text_config | |
| if ( | |
| vllm_config.parallel_config.pipeline_parallel_size != 1 | |
| - or vllm_config.quant_config is not None | |
| or vllm_config.speculative_config is not None | |
| or vllm_config.lora_config is not None | |
| or getattr(self.config, "layer_scale", False) | |
| ): | |
| raise ValueError( | |
| - "SenseNova Loop currently requires unquantized text inference " | |
| + "SenseNova Loop currently requires text inference " | |
| "without pipeline parallelism, LoRA, speculation or layer_scale" | |
| ) | |
| - self.quant_config = None | |
| + # Local patch: allow (ModelOpt) quantized checkpoints. | |
| + self.quant_config = vllm_config.quant_config | |
| + if self.quant_config is not None: | |
| + _remap_quant_config_names(self.quant_config, self.config) | |
| self.scheduler_config = vllm_config.scheduler_config | |
| self.model = SenseNovaLoopModel( | |
| vllm_config=vllm_config, prefix=maybe_prefix(prefix, "model") | |
| self.lm_head = ParallelLMHead( | |
| self.config.vocab_size, | |
| self.config.hidden_size, | |
| + quant_config=self.quant_config, | |
| prefix=maybe_prefix(prefix, "lm_head"), | |
| ) | |
| if self.config.tie_word_embeddings: | |