Skip to content

[None][feat] Add TRTLLM_PRECOMPILED_FROM_MAIN env var for installing from post-merge builds#12039

Open
tomeras91 wants to merge 6 commits intoNVIDIA:mainfrom
tomeras91:precompiled-from-main
Open

[None][feat] Add TRTLLM_PRECOMPILED_FROM_MAIN env var for installing from post-merge builds#12039
tomeras91 wants to merge 6 commits intoNVIDIA:mainfrom
tomeras91:precompiled-from-main

Conversation

@tomeras91
Copy link
Collaborator

@tomeras91 tomeras91 commented Mar 9, 2026

Summary by CodeRabbit

  • New Features

    • Added support for installing precompiled binaries from the latest main branch CI build via TRTLLM_PRECOMPILED_FROM_MAIN environment variable
  • Documentation

    • Updated installation guide with instructions for using the latest post-merge builds from main branch
  • Chores

    • Improved build artifact location configuration for better maintainability

Description

Adds a new TRTLLM_PRECOMPILED_FROM_MAIN env var that allows developers to install TensorRT-LLM using precompiled C++/CUDA binaries from the latest compatible GenPostMergeBuilds CI build on internal Artifactory (added in #11895), similar to vLLM's VLLM_USE_PRECOMPILED mechanism. This enables fast editable installs (pip install -e.) without compiling from source, using binaries that match the developer's current branch state via git merge-base commit correlation. Requires NVIDIA network/VPN access.

This enhances the current TRTLLM_USE_PRECOMPILED behavior, that only searches for RC wheels.

Summary

  • Add TRTLLM_PRECOMPILED_FROM_MAIN env var to install precompiled wheels from the GenPostMergeBuilds pipeline on internal Artifactory, using vLLM-style git merge-base commit correlation
  • Supports =1 (auto-detect via merge-base) or =<commit SHA> (short or full) to pin to a specific main commit
  • Works standalone — no need to also set TRTLLM_USE_PRECOMPILED=1
  • Extract NVIDIA_ARTIFACTORY_URL constant into scripts/get_wheel_from_package.py to avoid duplicating the URL across scripts
  • Added relevant doc entry

Usage

# Auto-detect
TRTLLM_PRECOMPILED_FROM_MAIN=1 pip install -e .

# Pin to a specific commit
TRTLLM_PRECOMPILED_FROM_MAIN=abc123d pip install -e .

Test plan

  • Smoke test on NVIDIA network: TRTLLM_PRECOMPILED_FROM_MAIN=1 pip install -e . --no-build-isolation
  • Verify correct build is selected by checking printed commit/build output
  • Test with explicit short SHA: TRTLLM_PRECOMPILED_FROM_MAIN=<short_sha> pip install -e .
  • Test outside NVIDIA network: verify clear SetupError mentioning VPN
  • Test on old branch (>14 days diverged): verify error mentions rebasing
  • Verify existing TRTLLM_USE_PRECOMPILED=1 behavior is unchanged
  • Verify TRTLLM_PRECOMPILED_LOCATION still takes priority

All checks worked as expected in a local setup.

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

  • Update tava architecture diagram if there is a significant design change in PR.

  • 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

To see a list of available CI bot commands, please comment /bot help.

…ng commit on main

Signed-off-by: Tomer Asida <57313761+tomeras91@users.noreply.github.com>
…ove unused workspace param

Signed-off-by: Tomer Asida <57313761+tomeras91@users.noreply.github.com>
Signed-off-by: Tomer Asida <57313761+tomeras91@users.noreply.github.com>
Signed-off-by: Tomer Asida <57313761+tomeras91@users.noreply.github.com>
@tomeras91 tomeras91 requested review from a team as code owners March 9, 2026 14:45
@tomeras91 tomeras91 requested review from arysef and chang-l March 9, 2026 14:45
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

This change introduces a new precompiled build workflow using TRTLLM_PRECOMPILED_FROM_MAIN environment variable to fetch the latest post-merge builds from main branch. It centralizes the Artifactory URL constant across scripts and adds logic to resolve builds via GitHub API and Artifactory queries.

Changes

Cohort / File(s) Summary
Artifactory URL Centralization
scripts/get_wheel_from_package.py, scripts/package_trt_llm.py
Extracts hardcoded Artifactory URL into NVIDIA_ARTIFACTORY_URL constant and replaces inline references with the centralized variable.
Precompiled Main Build Resolution
setup.py
Adds resolve_precompiled_from_main() function to query GitHub API for merge-base commit and Artifactory for matching GenPostMergeBuilds artifacts. Integrates TRTLLM_PRECOMPILED_FROM_MAIN environment variable into precompiled workflow decision logic, allowing builds from latest main branch or pinned commit SHA.
Installation Documentation
docs/source/installation/build-from-source-linux.md
Documents new "Using the Latest Post-Merge Build" workflow section describing TRTLLM_PRECOMPILED_FROM_MAIN environment variable usage, commit resolution via git merge-base, and artifact download mechanism.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Setup as setup.py
    participant GitHub as GitHub API
    participant Artifactory
    participant System

    User->>Setup: Run setup with TRTLLM_PRECOMPILED_FROM_MAIN=1
    Setup->>Setup: Check environment variables
    alt from_main_value is "1"
        Setup->>Setup: Run git merge-base to find common ancestor
        Setup->>GitHub: Query merge-base commit SHA
    else from_main_value is commit SHA
        Setup->>Setup: Use provided commit SHA directly
    end
    Setup->>Artifactory: Query GenPostMergeBuilds folders
    Artifactory-->>Setup: Return list of builds
    Setup->>Artifactory: Check build_info.txt for matching commit
    Artifactory-->>Setup: Confirm build match
    Setup->>Setup: Construct tarball URL with architecture info
    Setup->>Artifactory: Download precompiled tarball
    Artifactory-->>Setup: Return tarball
    Setup->>System: Extract and use precompiled binaries
    System-->>User: Build complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new TRTLLM_PRECOMPILED_FROM_MAIN environment variable for installing precompiled binaries from post-merge builds.
Description check ✅ Passed The PR description comprehensively covers all required template sections with clear explanations of what, why, test coverage, and checklist completion.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
scripts/package_trt_llm.py (1)

11-11: Prefer importing the helper module, not the constant.

This keeps the dependency namespaced and avoids another direct-symbol import in module scope.

♻️ Minimal refactor
-from get_wheel_from_package import NVIDIA_ARTIFACTORY_URL
+import get_wheel_from_package as wheel_pkg
@@
-        f'{NVIDIA_ARTIFACTORY_URL}/sw-tensorrt-generic/llm-artifacts/LLM/main/L0_PostMerge/1379/'
+        f'{wheel_pkg.NVIDIA_ARTIFACTORY_URL}/sw-tensorrt-generic/llm-artifacts/LLM/main/L0_PostMerge/1379/'

As per coding guidelines, "When importing in Python, always maintain the namespace. Import the module, not individual classes or functions."

Also applies to: 177-177

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/package_trt_llm.py` at line 11, The file currently imports the
constant directly (from get_wheel_from_package import NVIDIA_ARTIFACTORY_URL);
change this to import the module (import get_wheel_from_package) and update all
usages to reference get_wheel_from_package.NVIDIA_ARTIFACTORY_URL (also apply
the same replacement where the direct constant import appears again around the
other occurrence), keeping the symbol namespaced to the module.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/source/installation/build-from-source-linux.md`:
- Around line 264-279: State in the "Using the Latest Post-Merge Build" section
that when both environment variables are set, TRTLLM_PRECOMPILED_LOCATION takes
precedence over TRTLLM_PRECOMPILED_FROM_MAIN (this behavior comes from setup.py
which checks TRTLLM_PRECOMPILED_LOCATION first), and add a short note advising
users to unset TRTLLM_PRECOMPILED_LOCATION if they intend to use
TRTLLM_PRECOMPILED_FROM_MAIN (or show a quick example: unset
TRTLLM_PRECOMPILED_LOCATION && TRTLLM_PRECOMPILED_FROM_MAIN=... pip install -e
.).

In `@setup.py`:
- Around line 460-463: precompiled_from_main currently treats an empty
TRTLLM_PRECOMPILED_FROM_MAIN="" as enabled while later logic treats it as
falsey; normalize and reject empty values early by converting
precompiled_from_main = os.getenv("TRTLLM_PRECOMPILED_FROM_MAIN") into None when
it's an empty or all-whitespace string (e.g., set to None if not value.strip()),
then compute use_precompiled using the normalized precompiled,
precompiled_location, and precompiled_from_main variables; additionally, where
download_precompiled(tempdir, None) would be called (the code path using
download_precompiled), add an explicit check and raise a clear setup/config
error if TRTLLM_PRECOMPILED_FROM_MAIN was provided but empty instead of
attempting a download.
- Around line 22-23: The code masks real fetch/parse errors by only catching
URLError in storage_url and using bare excepts in the build_info.txt loop;
change these to catch specific exceptions (e.g., urllib.error.HTTPError,
urllib.error.URLError and json.JSONDecodeError) and only treat a
404/missing-metadata response as a skip; for all other HTTP errors or JSON parse
failures re-raise or abort immediately. Update imports to include HTTPError and
json.JSONDecodeError, replace bare except: blocks inside storage_url and the
build_info.txt processing loop with except HTTPError as e: check for 404 (handle
skip) else raise, except URLError as e: raise, and except json.JSONDecodeError
as e: raise so only the true "missing metadata" case is swallowed.
- Around line 285-305: The current loop picks the first descending build whose
commit starts with target_commit, which can silently pick the wrong build for
short SHA prefixes; instead iterate over the candidate window
(build_numbers[:MAX_BUILDS_TO_CHECK]) and collect all build_nums whose
build_commit matches the target_commit prefix, then require that the set of
matching build_commits is exactly one unique commit and exactly one matching
build_num; if zero or multiple distinct commits match, raise/exit with a clear
error; otherwise set matched_build to that single matching build_num. Update
logic around matched_build, build_commit, build_numbers and MAX_BUILDS_TO_CHECK
to perform the full-scan-and-validate before selecting a build.

---

Nitpick comments:
In `@scripts/package_trt_llm.py`:
- Line 11: The file currently imports the constant directly (from
get_wheel_from_package import NVIDIA_ARTIFACTORY_URL); change this to import the
module (import get_wheel_from_package) and update all usages to reference
get_wheel_from_package.NVIDIA_ARTIFACTORY_URL (also apply the same replacement
where the direct constant import appears again around the other occurrence),
keeping the symbol namespaced to the module.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 40db3dc6-f868-4ce6-a81b-65443c881312

📥 Commits

Reviewing files that changed from the base of the PR and between 9fe24db and 3f9200b.

📒 Files selected for processing (4)
  • docs/source/installation/build-from-source-linux.md
  • scripts/get_wheel_from_package.py
  • scripts/package_trt_llm.py
  • setup.py

- Document TRTLLM_PRECOMPILED_LOCATION precedence in docs
- Narrow exception handling: only skip build_info.txt on 404, fail on other errors
- Catch json.JSONDecodeError on Artifactory storage listing
- Reject empty TRTLLM_PRECOMPILED_FROM_MAIN early with clear error

Signed-off-by: Tomer Asida <57313761+tomeras91@users.noreply.github.com>
@tomeras91
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38287 [ run ] triggered by Bot. Commit: dda4de2 Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38287 [ run ] completed with state SUCCESS. Commit: dda4de2
/LLM/main/L0_MergeRequest_PR pipeline #29666 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@tomeras91
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38312 [ run ] triggered by Bot. Commit: cbc8074 Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38312 [ run ] completed with state SUCCESS. Commit: cbc8074
/LLM/main/L0_MergeRequest_PR pipeline #29689 completed with status: 'SUCCESS'

Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants