[Model] Support DeepSeek-V4.1-Flash (#56214)

Signed-off-by: Yongye Zhu <zyy1102000@gmail.com>
Signed-off-by: Jee Jee Li <jeejeelee@inferact.ai>
Signed-off-by: andyluo7 <andy.luo@amd.com>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Jee Jee Li <jeejeelee@inferact.ai>
Co-authored-by: andyluo7 <andy.luo@amd.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yongye Zhu
2026-09-11 02:11:19 -07:00
committed by GitHub
co-authored by Jee Jee Li andyluo7 OpenAI Codex zjy0516 Claude Opus 5
parent e6821ceac9
commit e77daef89e
49 changed files with 3996 additions and 138 deletions
@@ -17,9 +17,9 @@ def _resolve_dspark_attention_backend(
) -> AttentionBackendEnum | None:
if draft_backend is not None:
return draft_backend
# DeepSeek-V4 draft layers share the target's KV-cache layout. Other
# DeepSeek-V4(.1) draft layers share the target's KV-cache layout. Other
# DSpark architectures may use a different attention kind.
if draft_model_config.hf_config.model_type == "deepseek_v4":
if draft_model_config.hf_config.model_type in ("deepseek_v4", "deepseek_v41"):
if target_backend is not None:
logger.info_once(
"Using the target model's %s attention backend for the "
@@ -112,7 +112,14 @@ def get_eagle3_aux_layers_from_config(
if not layer_ids:
dspark_layer_ids = getattr(hf_config, "dspark_target_layer_ids", None)
if dspark_layer_ids:
layer_ids = [i + 1 for i in dspark_layer_ids]
if getattr(hf_config, "model_type", None) == "deepseek_v41":
# v4.1 reads the attention *inputs* of its target layers, and
# the target model captures the entry stream of layer L when
# idx+1 == L, so the ids are used as-is. (v4's ids are in
# capture-after semantics and keep the +1.)
layer_ids = list(dspark_layer_ids)
else:
layer_ids = [i + 1 for i in dspark_layer_ids]
if not layer_ids:
# Dense DSpark (e.g. Qwen3) also uses different aux layer semantics.
target_layer_ids = getattr(hf_config, "target_layer_ids", None)