Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 19 additions & 1 deletion tests/config/test_speculative_draft_hf_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from unittest.mock import MagicMock, patch

import pytest
from transformers import PreTrainedConfig
from transformers import Glm5NextConfig, PreTrainedConfig

from vllm.config.parallel import ParallelConfig
from vllm.config.speculative import SpeculativeConfig
Expand Down Expand Up @@ -270,3 +270,21 @@ def test_mtp_index_share_override(
speculative_config.draft_model_config.hf_config.index_share_for_mtp_iteration
is expected
)


@pytest.mark.cpu_test
def test_glm5_next_mtp_override_promotes_index_share():
"""The flag lives on text_config, but the MTP proposers read the draft config."""
config = Glm5NextConfig(
architectures=["Glm5NextForConditionalGeneration"],
text_config={
"num_nextn_predict_layers": 1,
"index_share_for_mtp_iteration": True,
},
)

draft_config = SpeculativeConfig.hf_config_override(config)

assert draft_config.architectures == ["Glm5NextMTPModel"]
assert draft_config.n_predict == 1
assert draft_config.index_share_for_mtp_iteration is True
11 changes: 9 additions & 2 deletions vllm/config/speculative.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,16 @@ def hf_config_override(hf_config: PreTrainedConfig) -> PreTrainedConfig:
)
if hf_config.model_type == "glm5_next":
hf_config.model_type = "glm5_next_mtp"
n_predict = hf_config.get_text_config().num_nextn_predict_layers
text_config = hf_config.get_text_config()
share_mtp_indices = getattr(
text_config, "index_share_for_mtp_iteration", False
)
hf_config.update(
{"n_predict": n_predict, "architectures": ["Glm5NextMTPModel"]}
{
"n_predict": text_config.num_nextn_predict_layers,
"architectures": ["Glm5NextMTPModel"],
"index_share_for_mtp_iteration": share_mtp_indices,
}
)

return hf_config
Expand Down
Loading