-
Notifications
You must be signed in to change notification settings - Fork 2k
[None][chore] Move submit.sh to python and use yaml configuration #8003
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
Conversation
📝 WalkthroughWalkthroughAdds a YAML-driven benchmark configuration, refactors the SLURM script to consume config-based arguments and log directories, introduces a Python-based Slurm submission orchestrator that generates per-role worker configs and submits jobs, and removes the legacy shell-based submission script. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant SubmitPy as submit.py
participant FS as Filesystem
participant Slurm as Slurm (sbatch)
participant SlurmJob as disaggr_torch.slurm
User->>SubmitPy: Run with --config config.yaml
SubmitPy->>FS: Load config.yaml
SubmitPy->>FS: Create log_dir
SubmitPy->>FS: Write ctx/gen worker_config YAMLs
SubmitPy->>SubmitPy: Calculate nodes/tasks
SubmitPy->>Slurm: sbatch with resources and args<br/>(log_dir, ctx_config_path, gen_config_path, env)
Slurm-->>User: Submission response (job ID)
Slurm->>SlurmJob: Launch job on allocated nodes
SlurmJob->>FS: Read worker configs, write logs to log_dir
note over SlurmJob,FS: Job stages use config-driven parameters
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 5
🧹 Nitpick comments (7)
examples/disaggregated/slurm/benchmark/submit.py (4)
27-35: Use safe_dump and explicit YAML formattingSwitch to yaml.safe_dump and stable formatting for reproducibility.
Apply this diff:
- with open(output_path, 'w') as f: - yaml.dump(worker_config, f, default_flow_style=False) + with open(output_path, 'w') as f: + yaml.safe_dump(worker_config, f, default_flow_style=False, sort_keys=True)
42-47: Resolve script path robustlyIf script_file is relative, resolve it against work_dir (or the config file’s directory) to avoid “file not found.”
Apply this diff:
def submit_job(config): # Extract configurations slurm_config = config['slurm'] hw_config = config['hardware'] env_config = config['environment'] + # Resolve script path relative to work_dir if needed + script_path = slurm_config['script_file'] + if not os.path.isabs(script_path): + script_path = os.path.join(env_config['work_dir'], script_path) + if not os.path.exists(script_path): + raise FileNotFoundError(f"SLURM script not found: {script_path}")
91-103: Set working directory and use resolved script pathEnsure job starts in work_dir and passes the correct script. Also consider using --chdir for sbatch.
Apply this diff:
cmd = [ 'sbatch', f'--partition={slurm_config["partition"]}', f'--gres=gpu:{hw_config["gpus_per_node"]}', f'--account={slurm_config["account"]}', f'--time={slurm_config["job_time"]}', f'--job-name={slurm_config["job_name"]}', f'--nodes={total_nodes}', f'--ntasks={total_tasks}', f'--ntasks-per-node={hw_config["gpus_per_node"]}', - f'--segment={total_nodes}', - slurm_config['script_file'], + f'--chdir={env_config["work_dir"]}', + script_path,
141-147: Pass cwd to subprocess.run and surface stderr/stdout on failureImproves reliability and debugging of submission failures.
Apply this diff:
- try: - subprocess.run(cmd, check=True) + try: + subprocess.run(cmd, check=True, cwd=env_config['work_dir']) except subprocess.CalledProcessError as e: - print(f"Error submitting job: {e}", file=sys.stderr) + print(f"Error submitting job: {e}", file=sys.stderr) sys.exit(1)examples/disaggregated/slurm/benchmark/disaggr_torch.slurm (3)
81-86: Add traps for reliable cleanupEnsure cleanup_on_failure runs on ERR/INT/TERM and that scancel is issued on failures automatically.
Apply this diff:
cleanup_on_failure() { echo "Error: $1" scancel ${SLURM_JOB_ID} exit 1 } +trap 'cleanup_on_failure "Script interrupted (INT)"' INT +trap 'cleanup_on_failure "Script terminated (TERM)"' TERM +trap 'cleanup_on_failure "Script failed (ERR)"' ERR
156-166: Pin srun placement or node lists if contention arisesYou compute gen_nodes/ctx_nodes but don’t use them. If you observe step contention, pass explicit node lists via -w "${gen_nodes_csv}" and -w "${ctx_nodes_csv}".
90-96: Container launch: run a real no-op command within bash -cA bare echo is fine, but using bash -c avoids surprises with shell builtins across environments; keep logging as-is.
Apply this diff:
-if ! srun -l --container-image=${container_image} \ +if ! srun -l --container-image=${container_image} \ --container-name=${container_name} \ --container-mounts=${container_mount} \ --mpi=pmix \ - echo "Container up." &> ${log_dir}/container_launch.log; then + bash -lc 'echo "Container up."' &> ${log_dir}/container_launch.log; then
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
examples/disaggregated/slurm/benchmark/config.yaml(1 hunks)examples/disaggregated/slurm/benchmark/disaggr_torch.slurm(10 hunks)examples/disaggregated/slurm/benchmark/submit.py(1 hunks)examples/disaggregated/slurm/benchmark/submit.sh(0 hunks)
💤 Files with no reviewable changes (1)
- examples/disaggregated/slurm/benchmark/submit.sh
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Use only spaces, no tabs; indent with 4 spaces.
Files:
examples/disaggregated/slurm/benchmark/submit.py
**/*.py
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.
Files:
examples/disaggregated/slurm/benchmark/submit.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).
Files:
examples/disaggregated/slurm/benchmark/submit.py
🪛 Ruff (0.13.1)
examples/disaggregated/slurm/benchmark/submit.py
1-1: Shebang is present but file is not executable
(EXE001)
143-143: subprocess call: check for execution of untrusted input
(S603)
⏰ 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)
- GitHub Check: Pre-commit Check
🔇 Additional comments (4)
examples/disaggregated/slurm/benchmark/config.yaml (3)
3-3: Consider making script_file an absolute or work_dir-relative path"disaggr_torch.slurm" will fail if submit.py isn’t executed from this directory. Prefer an absolute path or make submit.py resolve relative to work_dir/config location.
82-83: Verify moe_config.backend value"WIDEEP" looks non-standard; confirm it matches the expected enum in your runtime. If not, update to a supported backend value to avoid runtime parse errors.
80-80: Confirm kv_cache_config dtype compatibilityfp8 requires specific kernels/hardware support. Ensure this matches your TRT-LLM build and model weights; otherwise, set to a supported dtype (e.g., fp16/bf16).
examples/disaggregated/slurm/benchmark/submit.py (1)
142-146: Subprocess safety noteInputs originate from YAML; you’re using shell=False, which is good. Keep validating/normalizing types (ints, bools, paths) before constructing the cmd to prevent sbatch rejections.
c49efff to
4abae99
Compare
4abae99 to
304a3e5
Compare
a572409 to
7369ce0
Compare
Signed-off-by: Zero Zeng <[email protected]> update Signed-off-by: Zero Zeng <[email protected]>
7369ce0 to
a6fb940
Compare
Signed-off-by: Zero Zeng <[email protected]>
a6fb940 to
899940d
Compare
Signed-off-by: Zero Zeng <[email protected]>
Signed-off-by: Zero Zeng <[email protected]>
|
/bot skip --comment "slurm scripts are not protected by CI pipelines" |
|
PR_Github #21978 [ skip ] triggered by Bot. Commit: |
|
PR_Github #21978 [ skip ] completed with state |
…IDIA#8003) Signed-off-by: Zero Zeng <[email protected]>
…IDIA#8003) Signed-off-by: Zero Zeng <[email protected]> Signed-off-by: yufeiwu-nv <[email protected]>
…IDIA#8003) Signed-off-by: Zero Zeng <[email protected]>
…IDIA#8003) Signed-off-by: Zero Zeng <[email protected]>
…IDIA#8003) Signed-off-by: Zero Zeng <[email protected]>
…IDIA#8003) Signed-off-by: Zero Zeng <[email protected]>
Summary by CodeRabbit
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
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.
Details
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-listparameter 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.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip 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-pipelineReuse 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.