-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[https://nvbugs/5394392][fix] Enlarge scheduler capacity under disagg bs == 1 #6975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[https://nvbugs/5394392][fix] Enlarge scheduler capacity under disagg bs == 1 #6975
Conversation
… bs == 1 (NVIDIA#6537) Signed-off-by: Yifei Zhang <[email protected]>
📝 WalkthroughWalkthroughAdds guards to skip sequence-slot assignment for DISAGG_GENERATION_INIT requests in both C++ and Python paths, adjusts scheduler capacity for an attention-DP edge case (bs=1), moves SEQ_SLOT_MANAGER.prepare_resources from disagg-init to transmission-complete, and adds a generation-only BS=1 disaggregated test config, test, and test-list entry. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant PyExecutor
participant SeqSlotManager
participant AssignReqSeqSlots
Client->>PyExecutor: Submit request (DISAGG_GENERATION_INIT)
PyExecutor->>SeqSlotManager: prepare_resources(disagg_init)
SeqSlotManager-->>PyExecutor: Skip DISAGG_GENERATION_INIT (no slot)
Note over PyExecutor: Cache transmission completes later
PyExecutor->>SeqSlotManager: prepare_resources(transmission_complete)
SeqSlotManager->>AssignReqSeqSlots: include requests for slot assignment
AssignReqSeqSlots-->>SeqSlotManager: allocate/assign sequence slot
SeqSlotManager-->>PyExecutor: request now has slot and scheduling info
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
/bot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (5)
tensorrt_llm/_torch/pyexecutor/_util.py (1)
527-532
: Bump scheduler capacity for bs==1 attention-DP edge case; add a debug log for observabilityThe capacity bump logic is correct and low-risk. Consider logging when the adjustment happens to aid diagnosis in field.
Apply this diff to add a debug log:
scheduler_capacity = max_num_sequences - if scheduler_capacity == 1 and mapping.enable_attention_dp and kv_cache_manager: - scheduler_capacity += 1 + if scheduler_capacity == 1 and mapping.enable_attention_dp and kv_cache_manager: + scheduler_capacity += 1 + logger.debug( + "Adjusting scheduler capacity from %d to %d due to attention_dp with KV cache manager (bs==1)", + max_num_sequences, scheduler_capacity)Also applies to: 534-534
tests/integration/defs/disaggregated/test_configs/disagg_config_gen_only_bs1.yaml (3)
17-18
: Unify boolean literals for YAML 1.2 style consistencyBooleans are mixed (
True
/False
vstrue
/false
). While PyYAML accepts both, prefer lowercase for consistency and to avoid surprises with stricter parsers.Apply:
- enable_partial_reuse: False - disable_overlap_scheduler: True + enable_partial_reuse: false + disable_overlap_scheduler: true @@ - enable_partial_reuse: False + enable_partial_reuse: falseAlso applies to: 33-33
23-37
: Consider explicitly mirroring overlap-scheduler setting on generation serversYou set
disable_overlap_scheduler: true
for context servers but not for generation servers. If the intent is to keep behavior aligned (especially with attention DP enabled), explicitly setting it in both places prevents subtle divergence during debugging and triage. If the difference is intentional, ignore this.Suggested addition:
generation_servers: num_instances: 1 tensor_parallel_size: 2 pipeline_parallel_size: 1 enable_attention_dp: true max_batch_size: 1 max_num_tokens: 4096 max_seq_len: 4096 + disable_overlap_scheduler: true kv_cache_config: free_gpu_memory_fraction: 0.2 enable_partial_reuse: false
15-16
: Sanity-check KV cache headroom vs max_seq_lenIn tests/integration/defs/disaggregated/test_configs/disagg_config_gen_only_bs1.yaml you’ve set
- Line 16:
kv_cache_config.free_gpu_memory_fraction: 0.2
- Line 32:
kv_cache_config.free_gpu_memory_fraction: 0.2
together with
max_seq_len: 4096
andenable_attention_dp: true
. This headroom can be tight under allocator fragmentation and per‐rank memory pressure, leading to intermittent OOMs in CI. Consider bumpingfree_gpu_memory_fraction
to 0.25–0.3 in both spots if you observe flakiness.tests/integration/test_lists/test-db/l0_dgx_h100.yml (1)
36-36
: Optional: add an explicit timeout guardGiven this test specifically targets a former “nonstop” edge case, consider adding a TIMEOUT to make CI failures more actionable if regressions reintroduce hangs.
For example:
- - disaggregated/test_disaggregated.py::test_disaggregated_genbs1[TinyLlama-1.1B-Chat-v1.0] + - disaggregated/test_disaggregated.py::test_disaggregated_genbs1[TinyLlama-1.1B-Chat-v1.0] TIMEOUT (120)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
cpp/tensorrt_llm/batch_manager/assignReqSeqSlots.cpp
(1 hunks)tensorrt_llm/_torch/pyexecutor/_util.py
(1 hunks)tensorrt_llm/_torch/pyexecutor/py_executor.py
(1 hunks)tensorrt_llm/_torch/pyexecutor/seq_slot_manager.py
(1 hunks)tests/integration/defs/disaggregated/test_configs/disagg_config_gen_only_bs1.yaml
(1 hunks)tests/integration/defs/disaggregated/test_disaggregated.py
(2 hunks)tests/integration/test_lists/test-db/l0_dgx_h100.yml
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh}
: In C++, close namespaces with a comment naming the namespace (e.g., } // namespace foo)
Prefer const/constexpr variables over #define for constants
Declare variables const if not modified after initialization
Use Allman brace style in C++
C++ filenames use lowerCamelCase and must be case-insensitively unique within a build target
C++ type names use UpperCamelCase
Local variables, methods, and namespaces use lowerCamelCase
Global non-static variables not in anonymous namespace use gPrefix lowerCamelCase (e.g., gExample)
Static globals or globals in anonymous namespaces use sPrefix lowerCamelCase
Locally visible static variables start with 's' (e.g., static std::once_flag sFlag;)
Member variables use mPrefix lowerCamelCase; public members may omit but are encouraged to use 'm'
Constants (enums, global/static/function-scope magic numbers) use kPREFIXED_UPPER_SNAKE (e.g., kDIGIT_NUM)
If macros are unavoidable, use UPPER_SNAKE_CASE (prefer constants over #define)
Constructor parameter that conflicts with a public member name gets trailing underscore (foo_)
Literal suffixes should be uppercase (e.g., 1234L not 1234l)
C++: use spaces only; indent 4 spaces
Run clang-format (LLVM style) before submitting; wrap lines at 120 characters
If formatting must be bypassed, use // clang-format off/on around the section
Prefer smart pointers; use unique_ptr for sole ownership, shared_ptr for shared; weak_ptr only in exceptional cases
Do not use deprecated pre-C++11 smart pointers
Use C++ style comments; avoid C comments except special inline cases; prefer // single-line
Capitalize and punctuate full-sentence comments
Follow Doxygen rules: use //! for comments and //!< for members in C++
Disable code with #if/#endif and mnemonic conditions; avoid commented-out code; avoid dead code
Do not throw exceptions across library boundaries
Use least-forceful casts; avoid removing const/volatile; avoid C-style and functional casts (except constructors); p...
Files:
cpp/tensorrt_llm/batch_manager/assignReqSeqSlots.cpp
**/*.{cpp,cxx,cc,cu}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.{cpp,cxx,cc,cu}
: Avoid literal values except for 0, nullptr, true, false; use named constexpr for other literals
Place semicolon of empty for/while loop on a new line
Always use brace-delimited bodies for switch/while/do-for/if/else
Use inline C comments in argument lists when parameter meaning is unclear (e.g., /* checkForErrors = */ false)
Do not use assignment in subexpressions (e.g., if (x = y) ... is forbidden)
Switch on enums should enumerate all values and omit default to catch new values at compile time
Structure switch statements; prohibit fallthrough except between empty cases; each case ends with break or throw; return at end of case not allowed; put break inside braces for compound case
Prefer anonymous namespaces over static for internal linkage of functions
Every defined function must be called at least once (no unused methods)
Files:
cpp/tensorrt_llm/batch_manager/assignReqSeqSlots.cpp
**/*.{h,hpp,hxx,hh,cuh,cpp,cxx,cc,cu}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
Parameter names must be consistent between declarations and definitions
Files:
cpp/tensorrt_llm/batch_manager/assignReqSeqSlots.cpp
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
Prepend NVIDIA copyright header (current year) to all source files
Files:
cpp/tensorrt_llm/batch_manager/assignReqSeqSlots.cpp
tensorrt_llm/_torch/pyexecutor/seq_slot_manager.py
tensorrt_llm/_torch/pyexecutor/py_executor.py
tensorrt_llm/_torch/pyexecutor/_util.py
tests/integration/defs/disaggregated/test_disaggregated.py
**/*.py
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.py
: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else
Files:
tensorrt_llm/_torch/pyexecutor/seq_slot_manager.py
tensorrt_llm/_torch/pyexecutor/py_executor.py
tensorrt_llm/_torch/pyexecutor/_util.py
tests/integration/defs/disaggregated/test_disaggregated.py
🧬 Code Graph Analysis (3)
tensorrt_llm/_torch/pyexecutor/py_executor.py (5)
tensorrt_llm/_torch/pyexecutor/resource_manager.py (7)
ResourceManagerType
(45-50)prepare_resources
(70-71)prepare_resources
(358-386)prepare_resources
(986-994)prepare_resources
(1087-1089)prepare_resources
(1148-1151)prepare_resources
(1250-1266)tensorrt_llm/_torch/pyexecutor/seq_slot_manager.py (1)
prepare_resources
(17-29)tensorrt_llm/_torch/speculative/mtp.py (1)
prepare_resources
(63-71)tensorrt_llm/_torch/speculative/ngram.py (1)
prepare_resources
(68-69)tensorrt_llm/_torch/speculative/eagle3.py (1)
prepare_resources
(48-57)
tensorrt_llm/_torch/pyexecutor/_util.py (5)
tensorrt_llm/_torch/models/checkpoints/base_weight_mapper.py (1)
mapping
(152-153)cpp/include/tensorrt_llm/batch_manager/runtimeBuffers.h (1)
kv_cache_manager
(48-51)cpp/tensorrt_llm/batch_manager/trtGptModel.h (1)
kv_cache_manager
(43-46)cpp/include/tensorrt_llm/batch_manager/capacityScheduler.h (1)
kv_cache_manager
(28-31)tensorrt_llm/_torch/pyexecutor/scheduler.py (1)
BindCapacityScheduler
(70-97)
tests/integration/defs/disaggregated/test_disaggregated.py (1)
tests/integration/defs/conftest.py (4)
disaggregated_test_root
(2339-2344)disaggregated_example_root
(270-275)llm_venv
(707-723)llama_model_root
(964-1039)
🪛 Ruff (0.12.2)
tensorrt_llm/_torch/pyexecutor/seq_slot_manager.py
20-20: Undefined name logger
(F821)
🔇 Additional comments (4)
cpp/tensorrt_llm/batch_manager/assignReqSeqSlots.cpp (1)
33-37
: Correctly skipping slot assignment for DISAGG_GENERATION_INITGuarding DISAGG_GENERATION_INIT requests from slot assignment here aligns with the new flow (slots allocated at transmission-complete). This prevents the deadlock when bs==1. Looks good.
tests/integration/defs/disaggregated/test_disaggregated.py (1)
50-52
: Add gen_only_bs1 config mappingThe new entry for the bs=1 gen-only disaggregated config looks good and matches the test below.
tests/integration/test_lists/test-db/l0_dgx_h100.yml (2)
36-36
: LGTM: Added gen-only bs=1 disaggregated testThe placement and parameterization look correct alongside neighboring disaggregated tests.
36-36
: All tests and config wiring verified
- The
test_disaggregated_genbs1
function is defined in tests/integration/defs/disaggregated/test_disaggregated.py (line 395).- The config file disagg_config_gen_only_bs1.yaml exists under tests/integration/defs/disaggregated/test_configs/.
- That config is referenced in tests/integration/defs/disaggregated/test_disaggregated.py (line 51).
No further changes needed.
PR_Github #15574 [ run ] triggered by Bot |
PR_Github #15574 [ run ] completed with state |
Signed-off-by: Yifei Zhang <[email protected]>
/bot run |
1 similar comment
/bot run |
PR_Github #15678 [ run ] triggered by Bot |
PR_Github #15678 [ run ] completed with state |
/bot run --disable-fail-fast |
PR_Github #15720 [ run ] triggered by Bot |
PR_Github #15720 [ run ] completed with state |
/bot run |
PR_Github #15864 [ run ] triggered by Bot |
PR_Github #15864 [ run ] completed with state |
… bs == 1 (#6975) Signed-off-by: Yifei Zhang <[email protected]>
… bs == 1 (NVIDIA#6975) Signed-off-by: Yifei Zhang <[email protected]> Signed-off-by: Wangshanshan <[email protected]>
… bs == 1 (NVIDIA#6975) Signed-off-by: Yifei Zhang <[email protected]> Signed-off-by: Wangshanshan <[email protected]>
… bs == 1 (NVIDIA#6975) Signed-off-by: Yifei Zhang <[email protected]> Signed-off-by: Wangshanshan <[email protected]>
… bs == 1 (NVIDIA#6975) Signed-off-by: Yifei Zhang <[email protected]> Signed-off-by: Wangshanshan <[email protected]>
… bs == 1 (NVIDIA#6975) Signed-off-by: Yifei Zhang <[email protected]> Signed-off-by: Wangshanshan <[email protected]>
Description
Under disagg, if generation server runs with bs == 1, the dummy
GENERATION_IN_PROGRESS
request for attention dp will preventDISAGG_GENERATION_INIT
from being scheduled, thus letting generation server running in an endless cycle. This PR enlarges scheduler capacity and related resources to be with at least capacity == 2.Besides, originally py_executor logic assign new
SEQ_SLOT
resource onDISAGG_GEN_INIT
state. This PR delays the preparation toDISAGG_TRANS_COMPLETE
state.Test Coverage
Added
disaggregated/test_disaggregated.py::test_disaggregated_genbs1[TinyLlama-1.1B-Chat-v1.0]
to cover generation server bs==1 case.GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...
Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]
to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]
Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id
(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test
(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast
(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test
(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"
(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"
(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"
(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test
(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test
(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test
(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge
(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"
(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log
(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug
(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-list
parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.md
and the
scripts/test_to_stage_mapping.py
helper.kill
kill
Kill all running builds associated with pull request.
skip
skip --comment COMMENT
Skip testing for latest commit on pull request.
--comment "Reason for skipping build/test"
is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipeline
Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.
Summary by CodeRabbit
Bug Fixes
Tests