Repository navigation
[https://nvbugs/6858547][fix] Ignore cp_type with one CP rank and require HELIX with more - #21192
trtllm-agent wants to merge 1 commit into
Conversation
…uire HELIX with more With context_parallel_size 1, the PyTorch executor still checked cp_config["cp_type"] in its request path. merge_requests and PyExecutor._update_request_states accepted only HELIX and raised NotImplementedError for any other cp_type, and DecoderInputPreparer.prepare_inputs raised NotImplementedError for RING. CpConfig defaults cp_type to ULYSSES. So with one CP rank, a cp_config with the default cp_type or ULYSSES made the first request raise NotImplementedError inside the executor loop, and RING failed during warmup. With context_parallel_size > 1, TorchLlmArgs accepted a cp_type other than HELIX, for which merge_requests raises NotImplementedError. The three request-path checks now apply a cp_type only when cp_size > 1, like Mapping.has_cp_helix() and has_cp_ulysses(), the decoder warmup and the attention modules. With one CP rank, a cp_type other than HELIX no longer changes how requests are merged, updated and prepared: they are handled as without a cp_config. TorchLlmArgs now raises ValueError for a cp_type other than HELIX when context_parallel_size > 1, so that configuration fails at argument validation instead of in the executor. HELIX handling is unchanged. Tests: unit tests for the three request-path checks with one and two CP ranks, TorchLlmArgs tests for accepted and rejected cp_config values, and an LLM API test that compares greedy tokens with CpConfig() and CpConfig(cp_type="RING") at context_parallel_size 1 against no cp_config. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validate multi-rank configurations tensorrt_llm/llmapi/llm_args.py, tests/unittest/llmapi/test_llm_args.py |
TorchLlmArgs rejects configured cp_type values other than HELIX when context_parallel_size > 1. Tests cover accepted and rejected configurations. |
Gate executor behavior by CP size tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/inputs.py, tensorrt_llm/_torch/pyexecutor/py_executor.py, tensorrt_llm/_torch/pyexecutor/request_utils.py, tests/unittest/_torch/executor/* |
Input preparation, request-state updates, and request merging apply cp_type-specific handling only when context parallelism uses multiple ranks. Tests cover single-rank and multi-rank behavior and compare generated token IDs. |
Priority:
Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Suggested reviewers: lori-ren
Merge Risk: 
Minimal · up to 0bc05
-
No actionable merge-blocking risk was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 inconclusive Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 8 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Description
With
context_parallel_size1, the PyTorch executor still checkedcp_config["cp_type"]in its request path:merge_requests(request_utils.py) andPyExecutor._update_request_statesaccepted onlyHELIXand raisedNotImplementedError(Unsupported cp type ...) for any othercp_type.DecoderInputPreparer.prepare_inputsraisedNotImplementedErrorforRING.CpConfigdefaultscp_typetoULYSSES. So with one CP rank, acp_configwith the defaultcp_type(for examplecp_config: {}) orULYSSESmade the first request raiseNotImplementedErrorinside the executor loop, andRINGfailed during warmup.Mapping.has_cp_helix()andhas_cp_ulysses(), the decoder warmup and the attention modules already apply acp_typeonly whencp_size > 1.With
context_parallel_size> 1,TorchLlmArgsaccepted acp_typeother thanHELIX, for whichmerge_requestsand_update_request_statesraiseNotImplementedError. Where theAttentionorMLAconstructor (or some other module) checks it, such a configuration failed later, at executor initialization. By static reading, a model whose layers have no such check (for exampleGlm5NextForCausalLM) could start and reach that raise on the first request.With this change:
cp_size > 1. With one CP rank, acp_typeother thanHELIXno longer changes how requests are merged, updated and prepared: they are handled as without acp_config.TorchLlmArgsraisesValueErrorfor acp_configwhosecp_typeis notHELIX(includingCpConfig(), whose default isULYSSES) whencontext_parallel_size> 1. That configuration now fails at argument validation, before any model is built, instead of in the executor.Not changed:
HELIXhandling, for anycontext_parallel_size.context_parallel_size> 1 without acp_config.ULYSSEScp_configand one CP rank, startup withoutkv_cache_config.max_tokensstill fails (Quota not set), as before.Test Coverage
tests/unittest/_torch/executor/test_request_utils.py(CPU): with one CP rank,merge_requestsmerges the default,ULYSSESandRINGcp_configlike nocp_config, aggregated and disaggregated. Withcp_size2,ULYSSESandRINGstill raise.tests/unittest/_torch/executor/test_py_executor.py(CPU): with one CP rank,_update_request_statestakes the TP path forULYSSES,RINGandHELIX.ULYSSESwithcp_size2 still raises.tests/unittest/_torch/executor/test_pytorch_model_engine.py: with one CP rank,prepare_inputsacceptsULYSSESandRING.RINGwithcp_size2 still raises.tests/unittest/llmapi/test_llm_args.py(CPU): withcontext_parallel_size2,TorchLlmArgsrejectsCpConfig(),ULYSSESandRING, and acceptsHELIXand nocp_config. Withcontext_parallel_size1, it acceptsCpConfig()andRING.tests/unittest/_torch/executor/test_single_cp_rank_cp_config.py(GPU, Qwen3-0.6B):LLMwithCpConfig()and withCpConfig(cp_type="RING")atcontext_parallel_size1 generates the same greedy tokens as without acp_config.ULYSSESinprepare_inputsandHELIXin_update_request_states) and the threeTorchLlmArgsrejections. Thecp_size2 guards and the accepted configurations pass. Both cases of the new LLM API test fail. With the change, all pass.test_request_utils.py,test_py_executor.py,test_executor_request_queue.py,tests/unittest/executor/test_forward_error_survival.py,tests/unittest/others/test_mapping.py,tests/unittest/llmapi/test_llm_args.py,tests/unittest/api_stabilityandtests/unittest/llmapi/test_trtllm_serve_config_schemas.py: 1083 passed without the change, 1102 with it (the 19 new CPU-only cases).test_pytorch_model_engine.py: 116 passed without the change, 118 with it. The same 2DecoderForwardTestCase::test_mrope_*tests fail in both runs, withTypeError: create_model_engine_and_kvcache() missing 1 required positional argument: 'test_case'.scripts/generate_llm_args_golden_manifest.py --checkandscripts/generate_trtllm_serve_schemas.py --checkpass with the change.trtllm-serveon H200 withQwen2.5-0.5B-Instructandkv_cache_config.max_tokens: 8192. Each run sends six requests: chat, greedy chat, completion, streaming chat, chat withn=2, and chat with a long prompt.cp_type: ULYSSES,cp_config: {}, andULYSSESwithdisable_overlap_scheduler: true: before, the first request failed withUnsupported cp type ULYSSESraised in the executor loop. After, all six return 200.cp_type: RING: before, startup failed in warmup. After, all six return 200.pipeline_parallel_size2 withcp_type: ULYSSES: before, the first request failed withUnsupported cp type ULYSSESraised in the executor loop. After, all six return 200.cp_config.cp_configand withcp_type: HELIX: all six return 200 before and after, with the same outputs.context_parallel_size2 withULYSSESorRING: before, argument validation passed and executor initialization failed inAttentionconstruction (CP type must be HELIX for Attention). After,trtllm-servestops at argument validation with the newValueError, before the executor starts.context_parallel_size2 withHELIX: argument validation passes with the change. Executor initialization then stops with the existingHelix context parallelism is supported only on disaggregated generation serverserror.The new tests are collected by existing CI entries:
unittest/_torch/executorinl0_cpu.yml(CPU-only tests) andl0_h100.yml(GPU tests), andunittest/llmapi/test_llm_args.pyinl0_cpu.yml.PR Checklist
[JIRA ticket/NVBugs ID/GitHub issue/None][type] summary.context_parallel_size> 1 with acp_typeother thanHELIXis refused at argument validation.Dev Engineer Review
context_parallel_size == 1, request merging, request-state updates, and decoder input preparation no longer reject or act on non-HELIXcp_typevalues. This makes these paths behave as ifcp_configwere absent.context_parallel_size > 1,TorchLlmArgsnow rejects non-HELIXcp_configvalues during argument validation. The request paths retain their existing unsupported-type errors as defense in depth.HELIXhandling and KV cache sizing unchanged. A one-rank ULYSSES setup withoutkv_cache_config.max_tokensstill fails withQuota not set.QA Engineer Review
trtllm-servechecks cover one-rank ULYSSES/RING and two-GPU pipeline-parallel ULYSSES. The reported multi-rank outcomes distinguish early validation errors for ULYSSES/RING from the existing disaggregated-generation-server restriction for HELIX.test_llm_args.pyis listed in CI test lists.test_pytorch_model_engine.pyis listed with a selector for a different test, so the new cases are not shown as selected. The other changed test files were not found in the CI or manual-QA lists.Per-File QA Perspective
tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/inputs.py: Verify that single-rank non-HELIX configs use the usual decoder preparation path and that multi-rank unsupported types still fail.tensorrt_llm/_torch/pyexecutor/py_executor.py: Verify that single-rank request-state updates use the TP path for configured CP types and that multi-rank unsupported types remain rejected.tensorrt_llm/_torch/pyexecutor/request_utils.py: Verify that single-rank request merging matches the no-config result for aggregated and disaggregated requests. Verify that multi-rank non-HELIX types still raise.tensorrt_llm/llmapi/llm_args.py: Verify early validation for multi-rank non-HELIXcp_config, and acceptance of HELIX or no config at multiple ranks.test_llm_args.pyappears in CI lists.tests/unittest/_torch/executor/test_py_executor.py: Adds request-state tests for all CP types at one rank and an unsupported ULYSSES case at two ranks. Not found in the integration test lists.tests/unittest/_torch/executor/test_pytorch_model_engine.py: Adds decoder preparation tests for one-rank ULYSSES/RING and two-rank RING. The file is listed in CI with a selector for a different test; the new cases are not included by that selector.tests/unittest/_torch/executor/test_request_utils.py: Adds aggregated and disaggregated merge checks at one rank and error checks at two ranks. Not found in the integration test lists.tests/unittest/_torch/executor/test_single_cp_rank_cp_config.py: Adds a generated-token comparison between no config and one-rank default/RING config. Not found in the integration test lists.tests/unittest/llmapi/test_llm_args.py: Adds argument-validation cases for default, ULYSSES, RING, HELIX, and absent config at one or multiple ranks. Listed in CI.