Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
7c7bd61
one pass
WANDY666 Jun 3, 2026
d790ad2
Optimization
WANDY666 Jun 5, 2026
a161244
add prompt cache
WANDY666 Jun 5, 2026
61eed87
support cudagraph
WANDY666 Jun 5, 2026
19866d0
refact tokenizer
WANDY666 Jun 8, 2026
29c6082
add statement
WANDY666 Jun 8, 2026
ffafdbf
format
WANDY666 Jun 8, 2026
e8009cb
pass gsm8k but need review
WANDY666 Jun 11, 2026
b3b8123
fix
WANDY666 Jun 11, 2026
6002866
fix rope
WANDY666 Jun 11, 2026
6bc34ad
dsv4: enable decode cudagraph; fix warmup-baked FlashMLASchedMeta
WANDY666 Jun 11, 2026
e78e0d4
dsv4: enable prefill cudagraph; zero pad-row attention output
Jun 11, 2026
c09dc6a
fix profile
WANDY666 Jun 11, 2026
c07e38c
support fp8
WANDY666 Jun 12, 2026
ff71706
optimize
WANDY666 Jun 12, 2026
d7dd6e0
fix
WANDY666 Jun 12, 2026
3a5dcdc
compress infer
WANDY666 Jun 14, 2026
d76450f
add c128 to mem_manager
WANDY666 Jun 14, 2026
07d2308
refact
WANDY666 Jun 15, 2026
d4dcd8a
opt
WANDY666 Jun 15, 2026
62c16d5
opt
WANDY666 Jun 15, 2026
69824d0
delete launch.sh
WANDY666 Jun 15, 2026
df70ecb
fix
WANDY666 Jun 15, 2026
1ad981d
restore
WANDY666 Jun 16, 2026
7b17bb5
support parser
WANDY666 Jun 16, 2026
6837abd
fix
WANDY666 Jun 16, 2026
e1376fe
Merge branch 'main' of https://github.com/ModelTC/LightLLM into suppo…
WANDY666 Jun 16, 2026
02a24ce
add c4 paged indexes
WANDY666 Jun 18, 2026
52a1528
fix chunk_size and page_size
WANDY666 Jun 18, 2026
0dbc90b
add sglang third_party
WANDY666 Jun 18, 2026
e8c49d1
fix tpsp
WANDY666 Jun 18, 2026
88309b5
fix profile
WANDY666 Jun 21, 2026
cf433fb
fix swa insufficient
WANDY666 Jun 22, 2026
40f5810
fix
WANDY666 Jun 22, 2026
f527ca2
rename
WANDY666 Jun 22, 2026
255e90d
tune config
WANDY666 Jun 22, 2026
d88dc71
prepare opt
WANDY666 Jun 22, 2026
a56c79b
delete
WANDY666 Jun 22, 2026
e286943
item1: wire fused_q_indexer_rope_hadamard_quant (rope+hadamard+fp8qua…
WANDY666 Jun 23, 2026
58b145b
item3: lazy-cache layer-independent c4 paged metadata (page_table/ctx…
WANDY666 Jun 23, 2026
a0379bb
gate-bf16 (flag) + drop redundant attn_sink fp32 copy + lazy gen_nsa_…
WANDY666 Jun 23, 2026
b796d48
cache prefill FlashMLA sched-meta per compress-ratio (was rebuilt eve…
WANDY666 Jun 23, 2026
e07b85e
2-stream
WANDY666 Jun 23, 2026
51f5c84
fix parser
WANDY666 Jun 24, 2026
2f12a07
fix multi-invoke
WANDY666 Jun 24, 2026
da3fec2
speed up prepare
WANDY666 Jun 24, 2026
82cb6d6
fix arguments
WANDY666 Jun 24, 2026
bc22591
tune H100
WANDY666 Jun 24, 2026
77baa05
add encoding_dsv4
WANDY666 Jun 25, 2026
2225e1a
fix c4 error
WANDY666 Jun 26, 2026
112247b
fuse wq_a+wkv & indexer wkv+wgate GEMMs; fp8 wo_a at tp8 (1 group/rank)
WANDY666 Jun 26, 2026
0d52fde
reduce alloc fragment
WANDY666 Jun 28, 2026
c711fe9
set _C4_PREFILL_LOGITS_BUDGET_BYTES reduce max memory usage
WANDY666 Jun 28, 2026
fced38b
fix(deepseek-v4): align fp8 serving numerics with reference
WANDY666 Jul 1, 2026
17a0d54
fix stirde bug (if-inverse 73)
WANDY666 Jul 2, 2026
c19b853
default topk from huggingface's 50 to -1, if_inverse 70.6 -> 73
WANDY666 Jul 2, 2026
bc6ad97
Optimize AI code
WANDY666 Jul 3, 2026
99520f9
Optimize AI code
WANDY666 Jul 3, 2026
57bf22d
convert list to text
WANDY666 Jul 6, 2026
a61d9bc
support DS4 cache budgets in recover_paused_reqs
WANDY666 Jul 6, 2026
7dd651a
add error info
WANDY666 Jul 6, 2026
09402d2
support mtp
WANDY666 Jul 7, 2026
a0b258c
Merge branch 'ds4_prod' of https://github.com/ModelTC/LightLLM into s…
WANDY666 Jul 7, 2026
1b7e95c
fix
WANDY666 Jul 7, 2026
730766c
v4 don't need ragged_mem_buffers to save mem
WANDY666 Jul 8, 2026
9f4b534
fix error alloc
WANDY666 Jul 8, 2026
a3676bb
fix
WANDY666 Jul 8, 2026
f65915d
free infer_state.mtp_draft_input_hiddens
WANDY666 Jul 8, 2026
6bab228
fix
WANDY666 Jul 8, 2026
6f03e72
support dpep
WANDY666 Jul 8, 2026
c97c086
draft need only swa
WANDY666 Jul 9, 2026
444ca14
speed up
WANDY666 Jul 9, 2026
a0acc06
support overlap
WANDY666 Jul 13, 2026
b8c3a63
refact
WANDY666 Jul 13, 2026
1a2f29d
mega_moe support clamp_limit
WANDY666 Jul 13, 2026
2408462
Move DSV4 SWA/c4/c128 slot preparation into the model-specific path.
WANDY666 Jul 13, 2026
388dd29
autotune
WANDY666 Jul 13, 2026
6bfd98f
delete third_party
WANDY666 Jul 13, 2026
b39625c
optimize flashmla
WANDY666 Jul 14, 2026
51194ee
fix 9.11 < 9.9
WANDY666 Jul 14, 2026
5f17bd4
refact
WANDY666 Jul 14, 2026
dbe0f5e
reuse stable EP buffers to reduce memory fragmentation
WANDY666 Jul 14, 2026
4ac53e8
add test/benchmark/static_inference/static_benchmark.py
WANDY666 Jul 14, 2026
0a48e27
static benchmark support multi nodes
WANDY666 Jul 15, 2026
b0d6612
Merge branch 'support_ds4' of https://github.com/ModelTC/LightLLM int…
WANDY666 Jul 17, 2026
ad4508a
make c128 compression state request-local and MTP-safe
WANDY666 Jul 17, 2026
f411671
fix c4 mtp overwrite bug
WANDY666 Jul 17, 2026
9a071ca
autoset NUM_MAX_DISPATCH_TOKENS_PER_RANK_DECODE
WANDY666 Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lightllm/common/basemodel/attention/create_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,25 @@ def get_mla_decode_att_backend_class(index=0, priority_list: list = ["flashinfer
return _auto_select_backend(llm_dtype, kv_type_to_backend=mla_data_type_to_backend, priority_list=priority_list)


def get_nsa_prefill_att_backend_class(index=0, priority_list: list = ["flashmla_sparse"]) -> BaseAttBackend:
def get_nsa_prefill_att_backend_class(
index=0, priority_list: list = ["flashmla_sparse"], backend_map=nsa_data_type_to_backend
) -> BaseAttBackend:
args = get_env_start_args()
llm_dtype = args.llm_kv_type
backend_str = args.llm_prefill_att_backend[index]
if backend_str != "auto":
return nsa_data_type_to_backend[llm_dtype][backend_str]
return backend_map[llm_dtype][backend_str]
else:
return _auto_select_backend(llm_dtype, kv_type_to_backend=nsa_data_type_to_backend, priority_list=priority_list)
return _auto_select_backend(llm_dtype, kv_type_to_backend=backend_map, priority_list=priority_list)


def get_nsa_decode_att_backend_class(index=0, priority_list: list = ["flashmla_sparse"]) -> BaseAttBackend:
def get_nsa_decode_att_backend_class(
index=0, priority_list: list = ["flashmla_sparse"], backend_map=nsa_data_type_to_backend
) -> BaseAttBackend:
args = get_env_start_args()
llm_dtype = args.llm_kv_type
backend_str = args.llm_decode_att_backend[index]
if backend_str != "auto":
return nsa_data_type_to_backend[llm_dtype][backend_str]
return backend_map[llm_dtype][backend_str]
else:
return _auto_select_backend(llm_dtype, kv_type_to_backend=nsa_data_type_to_backend, priority_list=priority_list)
return _auto_select_backend(llm_dtype, kv_type_to_backend=backend_map, priority_list=priority_list)
186 changes: 186 additions & 0 deletions lightllm/common/basemodel/attention/nsa/dsv4_fp8_flashmla_sparse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import dataclasses
from typing import TYPE_CHECKING

import torch

from ..base_att import AttControl, BaseAttBackend, BaseDecodeAttState, BasePrefillAttState

if TYPE_CHECKING:
from lightllm.common.basemodel.infer_struct import InferStateInfo


# The current FlashMLA MODEL1 binary only instantiates these Q-head counts.
_SUPPORTED_Q_HEADS = (64, 128)


def get_dsv4_flashmla_padded_q_heads(q_head_num: int) -> int:
for supported_head_num in _SUPPORTED_Q_HEADS:
if q_head_num <= supported_head_num:
return supported_head_num
raise ValueError(f"FlashMLA does not support {q_head_num} local Q heads; supported counts: {_SUPPORTED_Q_HEADS}")


def _view_cache(buffer: torch.Tensor, page_size: int) -> torch.Tensor:
from lightllm.common.kv_cache_mem_manager.deepseek4_mem_manager import DSV4_MLA_BYTES_PER_TOKEN

byte_num = page_size * DSV4_MLA_BYTES_PER_TOKEN
return buffer[:, :byte_num].view(buffer.shape[0], page_size, 1, DSV4_MLA_BYTES_PER_TOKEN)


def _get_vllm_flashmla():
from vllm.v1.attention.ops import flashmla

return flashmla


class DeepseekV4FlashMlaFp8SparseAttBackend(BaseAttBackend):
def __init__(self, model):
super().__init__(model=model)
self.real_q_head_num = model.config["num_attention_heads"] // model.tp_world_size_
self.padded_q_head_num = get_dsv4_flashmla_padded_q_heads(self.real_q_head_num)
self.compress_ratios = tuple(dict.fromkeys(model.config["compress_ratios"]))

def _flashmla_att(
self,
q: torch.Tensor,
packed_kv: torch.Tensor,
mem_manager,
nsa_dict: dict,
sched_meta,
flash_mla,
flashmla_out: torch.Tensor = None,
) -> torch.Tensor:
from lightllm.common.kv_cache_mem_manager.deepseek4_mem_manager import (
DSV4_C128_PAGE_SIZE,
DSV4_C4_PAGE_SIZE,
DSV4_SWA_PAGE_SIZE,
)

ratio = nsa_dict["compress_ratio"]
extra_cache = None
if ratio == 4:
extra_page_size = DSV4_C4_PAGE_SIZE
elif ratio == 128:
extra_page_size = DSV4_C128_PAGE_SIZE
elif ratio != 0:
raise ValueError(f"unsupported DeepSeek-V4 compress ratio: {ratio}")
if ratio:
buffer = mem_manager.get_compressed_kv_buffer(nsa_dict["layer_index"])
extra_cache = _view_cache(buffer, extra_page_size)

kwargs = dict(
q=q.unsqueeze(1),
k_cache=_view_cache(packed_kv, DSV4_SWA_PAGE_SIZE),
block_table=None,
cache_seqlens=None,
head_dim_v=nsa_dict["head_dim_v"],
tile_scheduler_metadata=sched_meta,
num_splits=None,
softmax_scale=nsa_dict["softmax_scale"],
causal=False,
is_fp8_kvcache=True,
indices=nsa_dict["swa_indices"],
attn_sink=nsa_dict["attn_sink"],
topk_length=nsa_dict["swa_lengths"],
extra_k_cache=extra_cache,
extra_indices_in_kvcache=nsa_dict.get("extra_indices"),
extra_topk_length=nsa_dict.get("extra_lengths"),
)
if flashmla_out is not None:
kwargs["out"] = flashmla_out
full_out, _ = flash_mla.flash_mla_with_kvcache(**kwargs)
return full_out[:, 0, : self.real_q_head_num, :]

def create_att_prefill_state(self, infer_state: "InferStateInfo") -> "_PrefillAttState":
return _PrefillAttState(backend=self, infer_state=infer_state)

def create_att_decode_state(self, infer_state: "InferStateInfo") -> "_DecodeAttState":
return _DecodeAttState(backend=self, infer_state=infer_state)


@dataclasses.dataclass
class _PrefillAttState(BasePrefillAttState):
flashmla_sched_meta: dict = None
flash_mla: object = None

def init_state(self):
self.flash_mla = _get_vllm_flashmla()
self.flashmla_sched_meta = {}

def _get_sched_meta(self, compress_ratio: int):
if compress_ratio not in self.flashmla_sched_meta:
self.flashmla_sched_meta[compress_ratio] = self.flash_mla.get_mla_metadata()[0]
return self.flashmla_sched_meta[compress_ratio]

def prefill_att(
self,
q: torch.Tensor,
k: torch.Tensor,
v: torch.Tensor,
att_control: AttControl = AttControl(),
alloc_func=torch.empty,
*,
out: torch.Tensor = None,
) -> torch.Tensor:
assert att_control.nsa_prefill, "nsa_prefill must be True for NSA prefill attention"
assert att_control.nsa_prefill_dict is not None, "nsa_prefill_dict is required"
nsa_dict = att_control.nsa_prefill_dict
if out is None:
out = alloc_func(
(q.shape[0], self.backend.real_q_head_num, nsa_dict["head_dim_v"]),
dtype=q.dtype,
device=q.device,
)
full_out = self.infer_state.dsv4_workspace.flashmla_prefill_full_out[: q.shape[0]]
out.copy_(
self.backend._flashmla_att(
q,
k,
self.infer_state.mem_manager,
nsa_dict,
self._get_sched_meta(nsa_dict["compress_ratio"]),
self.flash_mla,
flashmla_out=full_out,
)
)
return out


@dataclasses.dataclass
class _DecodeAttState(BaseDecodeAttState):
flashmla_sched_meta: dict = None
flash_mla: object = None

def init_state(self):
self.reset_sched_meta_for_capture()

def reset_sched_meta_for_capture(self):
# FlashMLA lazily binds extra-cache geometry, so ratios cannot share one sched-meta object.
self.flash_mla = _get_vllm_flashmla()
self.flashmla_sched_meta = {
ratio: self.flash_mla.get_mla_metadata()[0] for ratio in self.backend.compress_ratios
}

def decode_att(
self,
q: torch.Tensor,
k: torch.Tensor,
v: torch.Tensor,
att_control: AttControl = AttControl(),
alloc_func=torch.empty,
) -> torch.Tensor:
assert att_control.nsa_decode, "nsa_decode must be True for NSA decode attention"
assert att_control.nsa_decode_dict is not None, "nsa_decode_dict is required"
nsa_dict = att_control.nsa_decode_dict
real_out = self.backend._flashmla_att(
q,
k,
self.infer_state.mem_manager,
nsa_dict,
self.flashmla_sched_meta[nsa_dict["compress_ratio"]],
self.flash_mla,
)
return real_out.contiguous()


DSV4_NSA_BACKENDS = {"fp8kv_dsa": {"flashmla_sparse": DeepseekV4FlashMlaFp8SparseAttBackend}}
91 changes: 64 additions & 27 deletions lightllm/common/basemodel/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@


class TpPartBaseModel:
is_mtp_draft_model = False

# weight class
pre_and_post_weight_class = None
transformer_weight_class = None
Expand Down Expand Up @@ -554,8 +556,10 @@ def _decode(
else:
infer_batch_size = model_input.batch_size

if self.graph is not None and self.graph.can_run(
batch_size=infer_batch_size, max_len_in_batch=model_input.max_kv_seq_len
if (
self.graph is not None
and not self.is_mtp_draft_model
and self.graph.can_run(batch_size=infer_batch_size, max_len_in_batch=model_input.max_kv_seq_len)
):
infer_batch_size = self.graph.find_closest_graph_batch_size(batch_size=infer_batch_size)
model_input = self._create_padded_decode_model_input(
Expand Down Expand Up @@ -600,6 +604,7 @@ def _decode(
def _context_forward(self, infer_state: InferStateInfo):

input_embs = self.pre_infer.context_forward(infer_state.input_ids, infer_state, self.pre_post_weight)
infer_state.mtp_draft_input_hiddens = None
if self.args.enable_dp_prefill_balance:
assert not self.args.enable_prefill_cudagraph, "not support now"
infer_state.prepare_prefill_dp_balance()
Expand Down Expand Up @@ -645,14 +650,20 @@ def prefill_func(input_tensors, infer_state):
last_input_embs = infer_state._all_to_all_unbalance_get(data=last_input_embs)

predict_logits = self.post_infer.token_forward(last_input_embs, infer_state, self.pre_post_weight)
mtp_main_output_hiddens = None
if isinstance(predict_logits, tuple):
predict_logits, mtp_main_output_hiddens = predict_logits
model_output = ModelOutput(logits=predict_logits)

# 特殊模型特殊模式的额外输出
if self.is_mtp_mode:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
if infer_state.need_dp_prefill_balance:
input_embs = infer_state._all_to_all_unbalance_get(data=input_embs)
model_output.mtp_main_output_hiddens = input_embs.contiguous()
if mtp_main_output_hiddens is not None:
model_output.mtp_main_output_hiddens = mtp_main_output_hiddens.contiguous()
else:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
if infer_state.need_dp_prefill_balance:
input_embs = infer_state._all_to_all_unbalance_get(data=input_embs)
model_output.mtp_main_output_hiddens = input_embs.contiguous()

# 在开启使用deepep的时候,需要调用clear_deepep_buffer做资源清理,没有启用的时候
# 该调用没有实际意义
Expand All @@ -664,23 +675,30 @@ def _token_forward(self, infer_state: InferStateInfo):
input_ids = infer_state.input_ids
cuda_input_ids = input_ids
input_embs = self.pre_infer.token_forward(cuda_input_ids, infer_state, self.pre_post_weight)
infer_state.mtp_draft_input_hiddens = None
input_embs = self.pre_infer._tpsp_sp_split(input=input_embs, infer_state=infer_state)

for i in range(self.layers_num):
layer = self.layers_infer[i]
input_embs: torch.Tensor = layer.token_forward(input_embs, infer_state, self.trans_layers_weight[i])

last_input_embs = self.post_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
predict_logits: torch.Tensor = self.post_infer.token_forward(
predict_logits = self.post_infer.token_forward(
last_input_embs, infer_state=infer_state, layer_weight=self.pre_post_weight
)
mtp_main_output_hiddens = None
if isinstance(predict_logits, tuple):
predict_logits, mtp_main_output_hiddens = predict_logits

model_output = ModelOutput(logits=predict_logits.contiguous())

# 特殊模型特殊模式的额外输出
if self.is_mtp_mode:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
model_output.mtp_main_output_hiddens = input_embs.contiguous()
if mtp_main_output_hiddens is not None:
model_output.mtp_main_output_hiddens = mtp_main_output_hiddens.contiguous()
else:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
model_output.mtp_main_output_hiddens = input_embs.contiguous()

# 在 cuda graph 模式下,输出需要转为 no ref tensor, 加强mem pool 的复用,降低显存的使用。
if infer_state.is_cuda_graph:
Expand Down Expand Up @@ -917,18 +935,31 @@ def _overlap_tpsp_context_forward(self, infer_state: InferStateInfo, infer_state
last_input_embs, last_input_embs1, infer_state, infer_state1, self.pre_post_weight
)
g_cache_manager.cache_env_out()
mtp_main_output_hiddens = None
mtp_main_output_hiddens1 = None
if isinstance(predict_logits, tuple):
predict_logits, mtp_main_output_hiddens = predict_logits
if isinstance(predict_logits1, tuple):
predict_logits1, mtp_main_output_hiddens1 = predict_logits1

model_output = ModelOutput(logits=predict_logits.contiguous())
model_output1 = ModelOutput(logits=predict_logits1.contiguous())

if self.is_mtp_mode:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
input_embs1 = self.pre_infer._tpsp_allgather(input=input_embs1, infer_state=infer_state1)
if infer_state.need_dp_prefill_balance:
input_embs = infer_state._all_to_all_unbalance_get(data=input_embs)
input_embs1 = infer_state1._all_to_all_unbalance_get(data=input_embs1)
model_output.mtp_main_output_hiddens = input_embs.contiguous()
model_output1.mtp_main_output_hiddens = input_embs1.contiguous()
if mtp_main_output_hiddens is not None:
model_output.mtp_main_output_hiddens = mtp_main_output_hiddens.contiguous()
else:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
if infer_state.need_dp_prefill_balance:
input_embs = infer_state._all_to_all_unbalance_get(data=input_embs)
model_output.mtp_main_output_hiddens = input_embs.contiguous()
if mtp_main_output_hiddens1 is not None:
model_output1.mtp_main_output_hiddens = mtp_main_output_hiddens1.contiguous()
else:
input_embs1 = self.pre_infer._tpsp_allgather(input=input_embs1, infer_state=infer_state1)
if infer_state.need_dp_prefill_balance:
input_embs1 = infer_state1._all_to_all_unbalance_get(data=input_embs1)
model_output1.mtp_main_output_hiddens = input_embs1.contiguous()

return model_output, model_output1

Expand All @@ -955,15 +986,27 @@ def _overlap_tpsp_token_forward(self, infer_state: InferStateInfo, infer_state1:
predict_logits, predict_logits1 = self.post_infer.overlap_tpsp_token_forward(
last_input_embs, last_input_embs1, infer_state, infer_state1, self.pre_post_weight
)
mtp_main_output_hiddens = None
mtp_main_output_hiddens1 = None
if isinstance(predict_logits, tuple):
predict_logits, mtp_main_output_hiddens = predict_logits
if isinstance(predict_logits1, tuple):
predict_logits1, mtp_main_output_hiddens1 = predict_logits1

model_output = ModelOutput(logits=predict_logits.contiguous())
model_output1 = ModelOutput(logits=predict_logits1.contiguous())

if self.is_mtp_mode:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
input_embs1 = self.pre_infer._tpsp_allgather(input=input_embs1, infer_state=infer_state1)
model_output.mtp_main_output_hiddens = input_embs.contiguous()
model_output1.mtp_main_output_hiddens = input_embs1.contiguous()
if mtp_main_output_hiddens is not None:
model_output.mtp_main_output_hiddens = mtp_main_output_hiddens.contiguous()
else:
input_embs = self.pre_infer._tpsp_allgather(input=input_embs, infer_state=infer_state)
model_output.mtp_main_output_hiddens = input_embs.contiguous()
if mtp_main_output_hiddens1 is not None:
model_output1.mtp_main_output_hiddens = mtp_main_output_hiddens1.contiguous()
else:
input_embs1 = self.pre_infer._tpsp_allgather(input=input_embs1, infer_state=infer_state1)
model_output1.mtp_main_output_hiddens = input_embs1.contiguous()

if infer_state.is_cuda_graph:
model_output.to_no_ref_tensor()
Expand Down Expand Up @@ -1171,13 +1214,7 @@ def _init_padded_req(self):
def _gen_special_model_input(self, token_num: int):
special_model_input = {}

is_mtp_draft_model = (
"Deepseek3MTPModel" in str(self.__class__)
or "Qwen3MOEMTPModel" in str(self.__class__)
or "MistralMTPModel" in str(self.__class__)
or "Glm4MoeLiteMTPModel" in str(self.__class__)
)
if is_mtp_draft_model:
if self.is_mtp_draft_model:
special_model_input["mtp_draft_input_hiddens"] = torch.randn(
token_num, self.config["hidden_size"], dtype=self.data_type, device="cuda"
)
Expand Down
Loading