auroter commited on
Commit
17e0f9d
·
verified ·
1 Parent(s): c1de79b

the draft-routing patch enabling DSpark on NVFP4 checkpoints

Browse files
Files changed (1) hide show
  1. dspark-nvfp4-draft-routing.patch +43 -0
dspark-nvfp4-draft-routing.patch ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/vllm/models/deepseek_v4/quant_config.py b/vllm/models/deepseek_v4/quant_config.py
2
+ index 89cf695..5918fa0 100644
3
+ --- a/vllm/models/deepseek_v4/quant_config.py
4
+ +++ b/vllm/models/deepseek_v4/quant_config.py
5
+ @@ -4,6 +4,7 @@
6
+
7
+ from __future__ import annotations
8
+
9
+ +import re
10
+ from typing import TYPE_CHECKING, cast
11
+
12
+ from vllm.config import get_current_vllm_config
13
+ @@ -175,7 +176,7 @@ class DeepseekV4FP8Config(Fp8Config):
14
+ ):
15
+ return UnquantizedFusedMoEMethod(layer.moe_config)
16
+ if self.expert_dtype == "fp4":
17
+ - if self.moe_quant_algo == "NVFP4":
18
+ + if self.moe_quant_algo == "NVFP4" and not self._is_draft_layer(prefix):
19
+ from vllm.model_executor.layers.quantization.modelopt import (
20
+ ModelOptNvFp4FusedMoE,
21
+ )
22
+ @@ -189,7 +190,20 @@ class DeepseekV4FP8Config(Fp8Config):
23
+ # returns Fp8MoEMethod with block-wise float32 scales.
24
+ return super().get_quant_method(layer, prefix)
25
+
26
+ + def _is_draft_layer(self, prefix: str) -> bool:
27
+ + # NVFP4 conversions quantize only the main stack; the speculative
28
+ + # module (runtime layer index >= num_hidden_layers) keeps its
29
+ + # original MXFP4 experts and must load through the MXFP4 path.
30
+ + m = re.search(r"layers\.(\d+)\.", prefix)
31
+ + if m is None:
32
+ + return False
33
+ + try:
34
+ + hf_config = get_current_vllm_config().model_config.hf_config
35
+ + except Exception:
36
+ + return False
37
+ + return int(m.group(1)) >= hf_config.num_hidden_layers
38
+ +
39
+ def is_mxfp4_quant(self, prefix, layer):
40
+ if not isinstance(layer, RoutedExperts) or self.expert_dtype != "fp4":
41
+ return False
42
+ - return self.moe_quant_algo != "NVFP4"
43
+ + return self.moe_quant_algo != "NVFP4" or self._is_draft_layer(prefix)