-
Notifications
You must be signed in to change notification settings - Fork 305
Add H100 TensorRT-LLM ModelScope coverage / 添加 H100 TensorRT-LLM ModelScope 覆盖 #3323
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
Open
functionstackx
wants to merge
4
commits into
main
Choose a base branch
from
feat/trtllm-modelscope-h100
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fc48c97
feat(h100): add TensorRT-LLM ModelScope coverage
functionstackx da732a3
docs: record ModelScope patch waiver
functionstackx 1e31a68
fix(modelscope): preserve snapshot glob filters
functionstackx 916278d
fix(evals): define the Qwen3-0.6B GSM8K regression floor
functionstackx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
benchmarks/single_node/fixed_seq_len/qwen3-0.6b_bf16_h100_trt.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| source "$(dirname "$0")/../../benchmark_lib.sh" | ||
|
|
||
| check_env_vars \ | ||
| MODEL \ | ||
| TP \ | ||
| CONC \ | ||
| ISL \ | ||
| OSL \ | ||
| MAX_MODEL_LEN \ | ||
| RANDOM_RANGE_RATIO \ | ||
| RESULT_FILENAME \ | ||
| EVAL_ONLY \ | ||
| RUN_EVAL \ | ||
| PORT \ | ||
| HF_HUB_CACHE | ||
|
|
||
| if [[ -n "$SLURM_JOB_ID" ]]; then | ||
| echo "JOB $SLURM_JOB_ID running on $SLURMD_NODENAME" | ||
| fi | ||
|
|
||
| python3 - <<'PY' | ||
| from importlib.metadata import version | ||
|
|
||
| expected = "1.3.0rc27" | ||
| actual = version("tensorrt_llm") | ||
| if actual != expected: | ||
| raise SystemExit( | ||
| f"Expected TensorRT-LLM {expected} for the pinned NGC image, got {actual}" | ||
| ) | ||
| PY | ||
|
|
||
| python3 -m pip install --quiet --disable-pip-version-check \ | ||
| "modelscope==1.40.1" "modelscope-hub==0.4.3" | ||
| python3 "$(dirname "$0")/../../../runners/patch_trtllm_modelscope.py" | ||
|
|
||
| export TRTLLM_USE_MODELSCOPE=true | ||
| export MODELSCOPE_CACHE="$HF_HUB_CACHE/modelscope" | ||
|
|
||
| # Resolve through TensorRT-LLM's patched hub boundary on the H100 node. Keep | ||
| # serving the remote model ID below so model loading, config, and tokenizer | ||
| # paths all exercise the ModelScope integration. | ||
| MODEL_PATH_FILE=$(mktemp) | ||
| python3 - "$MODEL" "$MODEL_PATH_FILE" <<'PY' | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from tensorrt_llm.llmapi.utils import download_hf_model | ||
|
|
||
| model_path = download_hf_model(sys.argv[1]) | ||
| Path(sys.argv[2]).write_text(str(model_path), encoding="utf-8") | ||
| PY | ||
| MODEL_PATH=$(<"$MODEL_PATH_FILE") | ||
| rm -f "$MODEL_PATH_FILE" | ||
| export MODEL_PATH | ||
|
|
||
| if [[ ! -f "$MODEL_PATH/config.json" ]]; then | ||
| echo "ModelScope snapshot is missing config.json: $MODEL_PATH" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "ModelScope snapshot: $MODEL_PATH" | ||
| echo "TP: $TP, CONC: $CONC, ISL: $ISL, OSL: $OSL" | ||
| nvidia-smi | ||
|
|
||
| SERVER_LOG=/workspace/server.log | ||
| EXTRA_CONFIG_FILE=$(mktemp --suffix=.yaml) | ||
| MAX_BATCH_SIZE=$((CONC > 16 ? CONC : 16)) | ||
| MAX_NUM_TOKENS=$((((ISL + CONC + 127) / 128) * 128)) | ||
| MAX_NUM_TOKENS=$((MAX_NUM_TOKENS > 8192 ? MAX_NUM_TOKENS : 8192)) | ||
|
|
||
| cat > "$EXTRA_CONFIG_FILE" <<EOF | ||
| dtype: bfloat16 | ||
| print_iter_log: true | ||
| kv_cache_config: | ||
| free_gpu_memory_fraction: 0.9 | ||
| enable_block_reuse: false | ||
| cuda_graph_config: | ||
| enable_padding: true | ||
| max_batch_size: $MAX_BATCH_SIZE | ||
| EOF | ||
|
|
||
| if [[ "$EVAL_ONLY" == "true" ]]; then | ||
| setup_eval_context | ||
| MAX_MODEL_LEN="$EVAL_MAX_MODEL_LEN" | ||
| MAX_NUM_TOKENS="$EVAL_MAX_MODEL_LEN" | ||
| fi | ||
|
|
||
| start_gpu_monitor | ||
|
|
||
| set -x | ||
| PYTHONNOUSERSITE=1 mpirun -n 1 --oversubscribe --allow-run-as-root \ | ||
| trtllm-serve "$MODEL" --port="$PORT" \ | ||
| --backend=pytorch \ | ||
| --max_batch_size="$MAX_BATCH_SIZE" \ | ||
| --max_seq_len="$MAX_MODEL_LEN" \ | ||
| --max_num_tokens="$MAX_NUM_TOKENS" \ | ||
| --tp_size="$TP" \ | ||
| --extra_llm_api_options="$EXTRA_CONFIG_FILE" \ | ||
| > "$SERVER_LOG" 2>&1 & | ||
|
|
||
| SERVER_PID=$! | ||
|
|
||
| wait_for_server_ready --port "$PORT" --server-log "$SERVER_LOG" --server-pid "$SERVER_PID" | ||
|
|
||
| run_benchmark_serving \ | ||
| --model "$MODEL" \ | ||
| --tokenizer "$MODEL_PATH" \ | ||
| --port "$PORT" \ | ||
| --backend openai \ | ||
| --input-len "$ISL" \ | ||
| --output-len "$OSL" \ | ||
| --random-range-ratio "$RANDOM_RANGE_RATIO" \ | ||
| --num-prompts "$((CONC * 10))" \ | ||
| --max-concurrency "$CONC" \ | ||
| --result-filename "$RESULT_FILENAME" \ | ||
| --result-dir /workspace/ | ||
|
|
||
| if [[ "$RUN_EVAL" == "true" ]]; then | ||
| run_eval --framework lm-eval --port "$PORT" | ||
| append_lm_eval_summary | ||
| fi | ||
|
|
||
| stop_gpu_monitor | ||
| rm -f "$EXTRA_CONFIG_FILE" | ||
| set +x | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Inference-engine patch waiver — PR #3323 | ||
|
|
||
| Filed per [`docs/PR_REVIEW_CHECKLIST.md`](../PR_REVIEW_CHECKLIST.md): this PR patches the pinned | ||
| TensorRT-LLM image before serving because the released image predates ModelScope model loading. | ||
|
|
||
| ## Config covered | ||
|
|
||
| - **Master config entry:** `qwen3-0.6b-bf16-h100-trt-modelscope` in | ||
| [`configs/nvidia-master.yaml`](../../configs/nvidia-master.yaml) | ||
| - **Pinned image:** `nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc27` | ||
| - **Image source:** NVIDIA/TensorRT-LLM tag `v1.3.0rc27`, commit | ||
| `6e1cc953c071b8a9055b03ef2ae4ee0bc4c645c4` | ||
| - **Patch entrypoint:** | ||
| [`runners/patch_trtllm_modelscope.py`](../../runners/patch_trtllm_modelscope.py), invoked by | ||
| [`benchmarks/single_node/fixed_seq_len/qwen3-0.6b_bf16_h100_trt.sh`](../../benchmarks/single_node/fixed_seq_len/qwen3-0.6b_bf16_h100_trt.sh) | ||
|
|
||
| ## What is patched | ||
|
|
||
| The patcher backports the ModelScope integration from | ||
| [SemiAnalysisAI/TensorRT-LLM#2](https://github.com/SemiAnalysisAI/TensorRT-LLM/pull/2) to the two | ||
| installed Python modules that participate in this benchmark: | ||
|
|
||
| - `tensorrt_llm/llmapi/utils.py` routes full and partial snapshot downloads through ModelScope when | ||
| `TRTLLM_USE_MODELSCOPE=true`, while preserving Hugging Face as the default. | ||
| - `tensorrt_llm/llmapi/llm.py` loads the tokenizer, generation config, and model config from the | ||
| resolved local snapshot rather than retrying the remote Hugging Face model ID. | ||
|
|
||
| The backport is source-matched to `v1.3.0rc27`, exact-anchor gated, and idempotent. It refuses an | ||
| unknown or partially patched installed source tree. `modelscope==1.40.1` and | ||
| `modelscope-hub==0.4.3` are installed in the H100 container before the patch is applied. | ||
|
|
||
| ## Why the unmodified upstream image cannot run this benchmark | ||
|
|
||
| TensorRT-LLM `1.3.0rc27` resolves remote model IDs exclusively with `huggingface_hub`. It has no | ||
| ModelScope switch or downloader and subsequently loads tokenizer and configuration files from the | ||
| original remote ID. Therefore the stock image cannot validate TensorRT-LLM model loading from | ||
| ModelScope for `Qwen/Qwen3-0.6B`; installing the optional ModelScope dependency alone does not change | ||
| that behavior. | ||
|
|
||
| ## Upstream PR | ||
|
|
||
| - https://github.com/SemiAnalysisAI/TensorRT-LLM/pull/2 | ||
|
|
||
| ## Removal plan | ||
|
|
||
| Once an NGC TensorRT-LLM release includes the ModelScope integration, update | ||
| `qwen3-0.6b-bf16-h100-trt-modelscope` to the first matching release image and verify its source tag. | ||
| In the same PR, remove `runners/patch_trtllm_modelscope.py`, remove its invocation and runtime package | ||
| installation from the benchmark script, and delete this waiver. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,9 @@ | |
| "minimaxm2.5": { | ||
| "gsm8k": 0.92 | ||
| }, | ||
| "qwen3-0.6b": { | ||
| "gsm8k": 0.60 | ||
| }, | ||
| "qwen3.5": { | ||
| "gsm8k": 0.94 | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🟡 (optional) Operators get a run that silently continues past a bad engine version or a failed ModelScope patch instead of stopping, because the script never sets
set -e/set -eo pipefail(sibling scripts like minimaxm3_fp8_h200_mtp.sh:2 do). The pinned-version check at lines 22-31 raises SystemExit on mismatch and the patcher at line 35 exits 1 on an unsupported source tree, but both are plain commands whose non-zero exit is ignored by bash withoutset -e, so trtllm-serve later starts against an unvalidated or unpatched TensorRT-LLM. Fix: addset -eo pipefailnear the top (or explicit|| exit 1after each) so the version check and the patch's fail-closed logic actually stop the run.Extended reasoning...
No
set -eorset -eo pipefailappears anywhere before line 92'sset -x, unlike minimaxm3_fp8_h200_mtp.sh which sets it at line 2 right after the shebang. Step 1: the heredoc at lines 22-31 checks the installed tensorrt_llm version and callsraise SystemExit(msg)when it does not equal 1.3.0rc27; python3 exits 1 and prints to stderr, but bash just moves to the next line. Step 2: pip install of modelscope at line 33-34 runs regardless. Step 3: the patcher at line 35 (runners/patch_trtllm_modelscope.py) can itself exit 1 via its fail-closed RuntimeError path (e.g. unsupported source tree) — again ignored. Step 4: TRTLLM_USE_MODELSCOPE is exported and trtllm-serve is launched later in the script against an engine that was never validated and may not actually be patched, instead of the run aborting immediately with the clear diagnostic message the check was designed to produce.Verification: normal. The new script benchmarks/single_node/fixed_seq_len/qwen3-0.6b_bf16_h100_trt.sh has no
set -e/set -eo pipefail; the onlysetisset -xat line 92. The sourced benchmark_lib.sh appliesset -eonly inside certain functions (3464-3541), and check_env_vars (the sole lib call before line 22) does not, so errexit is inactive at lines 22-35. Two fail-closed gates therefore have their…