-
Notifications
You must be signed in to change notification settings - Fork 309
Test H100 ModelScope loading from empty caches / 测试 H100 ModelScope 冷缓存加载 #3324
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
6
commits into
main
Choose a base branch
from
feat/trtllm-modelscope-cold-cache
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
6 commits
Select commit
Hold shift + click to select a range
7e90a18
feat(h100): add TensorRT-LLM ModelScope coverage
functionstackx 3749056
docs: record ModelScope patch waiver
functionstackx 8fb22ef
fix(modelscope): preserve snapshot glob filters
functionstackx 50383b0
fix(evals): define the Qwen3-0.6B GSM8K regression floor
functionstackx 5b7f425
test(h100): verify ModelScope downloads from empty caches
functionstackx e78910c
docs: link cold-cache evidence to PR 3324
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
126 changes: 126 additions & 0 deletions
126
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,126 @@ | ||
| #!/usr/bin/env bash | ||
| set -eo pipefail | ||
|
|
||
| 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 | ||
| MODELSCOPE_CACHE=$(mktemp -d /tmp/modelscope-cold.XXXXXX) | ||
| COLD_HF_HOME=$(mktemp -d /tmp/modelscope-hf-empty.XXXXXX) | ||
| export MODELSCOPE_CACHE | ||
| SNAPSHOT_HELPER="$(dirname "$0")/../../../runners/modelscope_snapshot.py" | ||
| SNAPSHOT_REPORT=/workspace/modelscope_snapshot_report.json | ||
| python3 "$SNAPSHOT_HELPER" before --model "$MODEL" --cache "$MODELSCOPE_CACHE" \ | ||
| --hf-home "$COLD_HF_HOME" --report "$SNAPSHOT_REPORT" | ||
|
|
||
| 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 | ||
| # The caller supplies the model-specific context ceiling. Avoid a hub | ||
| # lookup before the server performs its cold ModelScope download. | ||
| export EVAL_MAX_MODEL_LEN="$MAX_MODEL_LEN" | ||
| MAX_NUM_TOKENS="$EVAL_MAX_MODEL_LEN" | ||
| fi | ||
|
|
||
| start_gpu_monitor | ||
|
|
||
| set -x | ||
| PYTHONNOUSERSITE=1 HF_HUB_OFFLINE=0 HF_HOME="$COLD_HF_HOME" \ | ||
| HF_HUB_CACHE="$COLD_HF_HOME/hub" HUGGINGFACE_HUB_CACHE="$COLD_HF_HOME/hub" \ | ||
| TRANSFORMERS_CACHE="$COLD_HF_HOME/hub" 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" | ||
|
|
||
| # Resolve only after readiness; this must reuse the fresh server download. | ||
| HF_HUB_OFFLINE=1 python3 "$SNAPSHOT_HELPER" after --model "$MODEL" --cache "$MODELSCOPE_CACHE" \ | ||
| --hf-home "$COLD_HF_HOME" --report "$SNAPSHOT_REPORT" | ||
| MODEL_PATH=$(python3 - "$SNAPSHOT_REPORT" <<'PYCODE' | ||
| import json | ||
| import sys | ||
| from pathlib import Path | ||
| print(json.loads(Path(sys.argv[1]).read_text())["snapshot"]) | ||
| PYCODE | ||
| ) | ||
| export MODEL_PATH | ||
|
|
||
| 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 #3324 | ||
|
|
||
| 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) This script adds
set -eo pipefail(line 2), unlike every other single_node/fixed_seq_len benchmark script, so operators lose the GSM8K eval results and clean GPU metrics that siblings still produce after a benchmark hiccup. Ifrun_benchmark_serving(line 106) fails transiently, the script exits immediately and never reachesrun_eval(line 120) orstop_gpu_monitor/rm -f "$EXTRA_CONFIG_FILE"(lines 124-125), so the eval stage is skipped entirely and gpu_metrics.csv is left with a truncated tail instead of being finalized. Fix: keeprun_benchmark_servingandrun_evalfailures non-fatal (e.g. capture their exit codes) so cleanup and the eval stage still run on transient failures, consistent with dsr1_fp8_h200_trt.sh and other sibling scripts that intentionally omitset -e.Extended reasoning...
grep '^set -e' across benchmarks/single_node/fixed_seq_len/*.sh shows this is the only script with errexit; all siblings (e.g. dsr1_fp8_h200_trt.sh) omit it deliberately, relying on falling through to stop_gpu_monitor even when run_benchmark_serving fails. run_benchmark_serving (benchmark_lib.sh:793) returns non-zero on ordinary conditions (missing args, benchmark_exit_code from infx.bench_serving.benchmark_serving, capture failures) not just catastrophic errors. With set -e active here, that non-zero return terminates the script at line 106 before line 119's RUN_EVAL check, so the GSM8K accuracy eval that this PR's own validation section relies on never runs for that job. It also skips stop_gpu_monitor (benchmark_lib.sh:478), which normally appends a final nvidia-smi sample and repairs a truncated trailing CSV row via _repair_truncated_gpu_metrics_tail; skipping it leaves gpu_metrics.csv with a partial/truncated last row. The mktemp'd EXTRA_CONFIG_FILE at line 52 also leaks since rm -f at line 125 is never reached.
Verification: nit. The mechanism is real and reachable but low severity. Line 2 of the new file is
set -eo pipefail(the only fixed_seq_len script with errexit; siblings such as dsr1_fp8_h200_trt.sh omit it).run_benchmark_serving(line 106) is invoked as a bare command and returns$benchmark_exit_code(benchmark_lib.sh:1018), which is non-zero whenrun_server_clientfails, when the `server_watch…