Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion tests/evals/gsm8k/configs/GLM-5.2-NVFP4-TP1-PCP4-EP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ num_questions: 1319
num_fewshot: 5
max_concurrency: 100
server_args: >-
--enforce-eager
--compilation-config '{"cudagraph_mode":"PIECEWISE"}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep sparse-MLA PCP evaluations in eager mode

With nvidia/GLM-5.2-NVFP4, both this PCP4 configuration and the paired PCP2 configuration now fail during server initialization instead of running the evaluation. GLM-5.2 is a sparse-MLA model with index_topk, and PCPManager.validate_config() explicitly raises NotImplementedError whenever sparse MLA combines PCP with any CUDA graph mode other than NONE; setting PIECEWISE therefore makes these evaluation configurations unusable.

Useful? React with 👍 / 👎.

--max-model-len 4096
--max-num-batched-tokens 32768
--safetensors-load-strategy prefetch
Expand Down
2 changes: 1 addition & 1 deletion tests/evals/gsm8k/configs/GLM-5.2-NVFP4-TP2-PCP2-EP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ num_questions: 1319
num_fewshot: 5
max_concurrency: 100
server_args: >-
--enforce-eager
--compilation-config '{"cudagraph_mode":"PIECEWISE"}'
--max-model-len 4096
--max-num-batched-tokens 32768
--safetensors-load-strategy prefetch
Expand Down
53 changes: 53 additions & 0 deletions tests/v1/cudagraph/test_cudagraph_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
VllmConfig,
)
from vllm.distributed.device_communicators import pynccl_allocator
from vllm.v1.kv_cache_interface import KVCacheConfig
from vllm.v1.worker.gpu import cudagraph_utils as gpu_cudagraph_utils
from vllm.v1.worker.gpu.cudagraph_utils import BatchExecutionDescriptor
from vllm.v1.worker.gpu.input_batch import InputBuffers
from vllm.v1.worker.gpu.pcp_manager import PCPManager

pytestmark = pytest.mark.cpu_test

Expand Down Expand Up @@ -112,6 +115,56 @@ def cuda_graph_enter(*args, **kwargs):
mock_cuda_graph.assert_called_once()


def test_piecewise_capture_uses_pcp_dummy_slot_mappings():
num_reqs = 32
num_tokens = 56
pcp_world_size = 2
input_buffers = InputBuffers(num_reqs, num_tokens, torch.device("cpu"))

pcp_block_tables = SimpleNamespace(
num_kv_cache_groups=1,
input_block_tables=(torch.zeros(num_reqs * 2, 1, dtype=torch.int32),),
)
pcp_manager = PCPManager(
pcp_world_size=pcp_world_size,
pcp_rank=0,
device=torch.device("cpu"),
max_num_reqs=num_reqs,
max_num_tokens=num_tokens,
block_tables=pcp_block_tables,
)

block_tables = MagicMock()
block_tables.cp_size = 1
block_tables.get_dummy_block_tables.return_value = ()
block_tables.get_dummy_slot_mappings.return_value = torch.zeros(
1, num_tokens, dtype=torch.int64
)
model_state = MagicMock()
model_state.prepare_attn.return_value = {}
kv_cache_config = KVCacheConfig(
num_blocks=0,
kv_cache_tensors=[],
kv_cache_groups=[],
)

gpu_cudagraph_utils.prepare_inputs_to_capture(
num_reqs,
num_tokens,
model_state,
input_buffers,
block_tables,
[],
kv_cache_config,
full_cudagraph=False,
pcp_manager=pcp_manager,
)

slot_mappings = model_state.prepare_attn.call_args.args[3]
assert slot_mappings.shape == (1, num_tokens * pcp_world_size)
block_tables.get_dummy_slot_mappings.assert_not_called()


_DECODE_QUERY_LEN = 3


Expand Down
10 changes: 9 additions & 1 deletion vllm/v1/worker/gpu/cudagraph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

if TYPE_CHECKING:
from vllm.v1.worker.gpu.model_runner import GPUModelRunner
from vllm.v1.worker.gpu.pcp_manager import PCPManager

logger = init_logger(__name__)

Expand Down Expand Up @@ -491,6 +492,7 @@ def capture(
block_tables: BlockTables,
attn_groups: list[list[AttentionGroup]],
kv_cache_config: KVCacheConfig,
pcp_manager: "PCPManager | None" = None,
has_lora: bool = False,
use_aux_hidden_state_outputs: bool = False,
lora_capture_hook: Callable[[int, int, int], None] | None = None,
Expand Down Expand Up @@ -540,6 +542,7 @@ def create_forward_fn(
kv_cache_config,
full_cudagraph=desc.cg_mode == CUDAGraphMode.FULL,
max_query_len=desc.max_query_len,
pcp_manager=pcp_manager,
)

# Capture with dummy rows marked as padding.
Expand Down Expand Up @@ -632,12 +635,17 @@ def prepare_inputs_to_capture(
kv_cache_config: KVCacheConfig,
full_cudagraph: bool,
max_query_len: int | None = None,
pcp_manager: "PCPManager | None" = None,
) -> AttentionState:
input_batch = InputBatch.make_dummy(
num_reqs, num_tokens, input_buffers, max_query_len=max_query_len
)
input_block_tables = block_tables.get_dummy_block_tables(num_reqs)
slot_mappings = block_tables.get_dummy_slot_mappings(num_tokens)
slot_mappings = (
pcp_manager.get_dummy_slot_mappings(num_tokens)
if pcp_manager is not None and not full_cudagraph
else block_tables.get_dummy_slot_mappings(num_tokens)
)
slot_mappings_by_layer = build_slot_mappings_by_layer(
slot_mappings, kv_cache_config
)
Expand Down
1 change: 1 addition & 0 deletions vllm/v1/worker/gpu/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ def capture_model(self) -> int:
self.block_tables,
self.attn_groups,
self.kv_cache_config,
pcp_manager=self.pcp_manager,
has_lora=self.lora_config is not None,
use_aux_hidden_state_outputs=self.use_aux_hidden_state_outputs,
lora_capture_hook=create_lora_capture_hook(self.lora_config, self),
Expand Down
Loading