[Bugfix] DFlash fc sized wrong when num_target_layers != num_hidden_layers (#48524)

Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Michael Goin
2026-07-21 14:42:52 -07:00
committed by GitHub
co-authored by Codex
parent b8fb56d970
commit a7d00ec051
3 changed files with 61 additions and 11 deletions
+37 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Config-only resolution of DFlash draft attention causality.
"""Config-only DFlash behavior.
``dflash_has_any_non_causal`` decides pre-build whether the draft needs a
non-causal-capable backend, so its branch table (explicit override, SWA-derived
@@ -13,8 +13,12 @@ import pytest
from vllm.model_executor.models.qwen3_dflash import (
_dflash_layer_causal,
_get_dflash_fc_input_size,
dflash_has_any_non_causal,
)
from vllm.v1.worker.gpu.spec_decode.eagle.eagle3_utils import (
get_eagle3_aux_layers_from_config,
)
def _config(num_hidden_layers, layer_types=None, causal_override=None):
@@ -53,3 +57,35 @@ def test_dflash_layer_causal_is_per_layer():
config = _config(2, layer_types=["sliding_attention", "full_attention"])
assert _dflash_layer_causal(config, 0) is True
assert _dflash_layer_causal(config, 1) is False
def _vllm_config(**draft_config):
config = SimpleNamespace(**draft_config)
return SimpleNamespace(
speculative_config=SimpleNamespace(
draft_model_config=SimpleNamespace(hf_config=config)
)
)
def test_dflash_fc_uses_aux_layer_count():
vllm_config = _vllm_config(
num_hidden_layers=5,
hidden_size=4096,
target_hidden_size=None,
target_layer_ids=[1, 17, 32],
)
assert _get_dflash_fc_input_size(vllm_config) == 3 * 4096
@pytest.mark.parametrize("config_name", ["dflash_config", "eagle_config"])
def test_eagle_aux_layers_preserves_legacy_layer_ids(config_name):
layer_ids = [1, 17, 32]
vllm_config = _vllm_config(
**{config_name: {"layer_ids": layer_ids}},
)
assert get_eagle3_aux_layers_from_config(vllm_config.speculative_config) == tuple(
layer_ids
)