Skip to content

Commit 2bc0a99

Browse files
authored
[TRTLLMINF-336][infra] BOLT profile merge: skip runtime tensorrt import gate (libs-only) (#18395)
Signed-off-by: Matt Lefebvre <mlefebvre@nvidia.com>
1 parent c44de1a commit 2bc0a99

2 files changed

Lines changed: 31 additions & 8 deletions

File tree

scripts/bolt/internal/slurm_merge.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ srun --ntasks=1 --ntasks-per-node=1 --nodes=1 \
117117
# No instrument -- the collect jobs already produced the .fdata.
118118
_extract='"$RUNDIR"'/extract
119119
mkdir -p "$_extract" && tar xzf /builds/'"$TARBALL_NAME"' -C "$_extract" 2>/dev/null
120-
/workspace/bolt/setup_env.sh "$_extract"
120+
# Libs-only: the merge only needs the wheel ELFs on disk to convert
121+
# .fdata -> .yaml (no runtime import), so skip setup_env.sh runtime
122+
# tensorrt gate -- the profiling base image has no importable tensorrt
123+
# before install and would otherwise fail here.
124+
BOLT_SETUP_LIBS_ONLY=1 /workspace/bolt/setup_env.sh "$_extract"
121125
source /workspace/bolt/bolt_lib.sh
122126
bolt_run_stages setup_directories backup_libraries
123127

scripts/bolt/setup_env.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,32 @@ set -euo pipefail
2525
EXTRACT="${1:?usage: setup_env.sh <dir containing TensorRT-LLM/ (wheel)>}"
2626
PYTHON="${PYTHON:-python3}"
2727

28+
# BOLT_SETUP_LIBS_ONLY=1: the caller only needs the wheel's ELF .so files ON DISK
29+
# (e.g. the merge job reconstructs the pre-instrument originals to convert
30+
# .fdata -> .yaml -- see internal/slurm_merge.sh). That path never imports
31+
# tensorrt / tensorrt_llm at runtime (library discovery uses
32+
# importlib.util.find_spec, which does NOT execute the package), so the
33+
# runtime-tensorrt gate below is irrelevant and would spuriously fail on a
34+
# profiling base image whose `import tensorrt` isn't wired up before install.
35+
# Skip the import checks in that mode but still install the wheel (--no-deps).
36+
LIBS_ONLY="${BOLT_SETUP_LIBS_ONLY:-0}"
37+
2838
WHEEL=$(ls "$EXTRACT"/TensorRT-LLM/tensorrt_llm-*.whl 2>/dev/null | head -1 || true)
2939
[[ -f "$WHEEL" ]] || { echo "[ERROR] No tensorrt_llm wheel under $EXTRACT/TensorRT-LLM/"; exit 1; }
3040

3141
# 0. The container must already have a working tensorrt (runtime-capable image).
32-
if ! "$PYTHON" -c "import tensorrt" 2>/dev/null; then
33-
echo "[ERROR] 'import tensorrt' fails in this container BEFORE install." >&2
34-
echo " Use a runtime-capable image (devel/release) with TensorRT intact;" >&2
35-
echo " a bare CUDA/pytorch base or an image with a stripped tensorrt will not work." >&2
36-
exit 1
42+
# Skipped in libs-only mode (no runtime import happens downstream).
43+
if [[ "$LIBS_ONLY" != "1" ]]; then
44+
if ! "$PYTHON" -c "import tensorrt" 2>/dev/null; then
45+
echo "[ERROR] 'import tensorrt' fails in this container BEFORE install." >&2
46+
echo " Use a runtime-capable image (devel/release) with TensorRT intact;" >&2
47+
echo " a bare CUDA/pytorch base or an image with a stripped tensorrt will not work." >&2
48+
exit 1
49+
fi
50+
echo "[INFO] tensorrt OK: $("$PYTHON" -c 'import tensorrt; print(tensorrt.__version__)')"
51+
else
52+
echo "[INFO] BOLT_SETUP_LIBS_ONLY=1: skipping runtime tensorrt import checks (libs-only)."
3753
fi
38-
echo "[INFO] tensorrt OK: $("$PYTHON" -c 'import tensorrt; print(tensorrt.__version__)')"
3954

4055
# 1. Wheel WITHOUT deps -> never touches tensorrt. --force-reinstall so the BOLT
4156
# libs overlay any preinstalled trtllm (release image).
@@ -44,5 +59,9 @@ pip install --no-deps --force-reinstall "$WHEEL"
4459

4560
# 2. Verify from a neutral cwd so the extracted source tree doesn't shadow the
4661
# installed package (a source `tensorrt_llm/` has no compiled bindings).
47-
( cd /tmp && "$PYTHON" -c "import tensorrt, tensorrt_llm; print('[INFO] runtime + trtllm ok:', tensorrt_llm.__file__)" )
62+
# Skipped in libs-only mode: only the on-disk .so files are needed, and the
63+
# runtime import may legitimately fail on a libs-only base image.
64+
if [[ "$LIBS_ONLY" != "1" ]]; then
65+
( cd /tmp && "$PYTHON" -c "import tensorrt, tensorrt_llm; print('[INFO] runtime + trtllm ok:', tensorrt_llm.__file__)" )
66+
fi
4867
echo "[SUCCESS] Environment ready for BOLT flow."

0 commit comments

Comments
 (0)