feat(build): experimental build presets (--build-presets-file)#8886
Merged
Conversation
…file) Add an experimental --build-presets-file flag (gated behind TRITON_BUILD_EXPERIMENTAL=1) that loads a JSON file overriding per-backend properties: git tag, clone organization, library path, and extra/override CMake args. Command-line flags take precedence over the file. Unlike the global --github-organization, a per-backend "org" drives both the git clone URL and -DTRITON_REPO_ORGANIZATION. On --dryrun, the fully-resolved presets (defaults + CLI + file) are written to build_presets.json in the build directory for inspection and reuse. All load/validate/precedence logic lives in tools/build/build_presets.py to keep build.py's integration minimal. No behavioral change when the flag is unused. Refs TRI-829.
…le snapshot
Rework the experimental --build-presets-file dump/reload:
- dump: on --dryrun, write build_presets.json capturing EVERY resolved cmake -D
flag each component receives (core/backends/repoagents/caches), matching
cmake_build, each annotated with its source (cli/preset/default). Provenance
is derived from argv (which options were passed) plus before/after snapshots
of the extra/override dicts.
- reload: the same file loads back and pins every flag. cmake_args route to the
override channel (flags build.py emits natively); extra_cmake_args route to the
extra/append channel (user-added flags such as TRITON_BOOST_URL) so they are
not dropped. TRITON_REPO_ORGANIZATION in a backend's cmake_args also drives the
per-backend clone org. CLI flags still win.
- values may be a scalar or a {value, source} object; CMAKE_INSTALL_PREFIX is
excluded (absolute path). Repoagent/cache cmake_args are visibility-only on
load (tag is pinned).
All snapshot/parse/annotate logic lives in tools/build/build_presets.py
(write_snapshot); build.py only gathers the per-component cmake args and calls
it. No behavioral change when the flag is unused (CI variants byte-identical).
Refs TRI-829.
Add qa/L2_build_presets validating the documented build-presets scenarios via build.py --dryrun (no GPU/container/build): snapshot sections + source annotation, CMAKE_INSTALL_PREFIX exclusion, provenance, extra-channel routing, env gate, example apply, round-trip reload, and validation errors. Runs from the server source tree, TRITON_BUILD_PY, or a shallow clone (bare container). Ships test.sh (deps + pytest --log-cli-level=INFO --junitxml, teed to a log), requirements.txt, and a README. SPDX-header adoption via a migrate-on-touch pre-commit hook (tools/add_spdx_header.py): scoped by file type so it brings each changed source file to the two-line SPDX header -- maintaining an existing one, replacing a legacy long-form NVIDIA BSD header in place (preserving comment style, shebang, and start year), or inserting one. Runs after add_copyright.py; the two coexist. Migrates the build_presets files and .pre-commit-config.yaml. Refs TRI-829.
Add qa/L2_build_presets validating the documented build-presets scenarios via build.py --dryrun (no GPU/container/build): snapshot sections + source annotation, CMAKE_INSTALL_PREFIX exclusion, provenance, extra-channel routing, env gate, example apply, round-trip reload, and validation errors. Runs from the server source tree, TRITON_BUILD_PY, or a shallow clone (bare container). Ships test.sh (deps + pytest --log-cli-level=INFO --junitxml, teed to a log), requirements.txt, and a README. SPDX-header adoption via a migrate-on-touch pre-commit hook (tools/add_spdx_header.py): scoped by file type so it brings each changed source file to the two-line SPDX header -- maintaining an existing one, replacing a legacy long-form NVIDIA BSD header in place (preserving comment style, shebang, and start year), or inserting one. Runs after add_copyright.py; the two coexist. Migrates the build_presets files and .pre-commit-config.yaml. Refs TRI-829.
…ference-server/server into mchornyi/TRI-829/build-presets
mc-nv
force-pushed
the
mchornyi/TRI-829/build-presets
branch
from
July 15, 2026 21:23
6f47c87 to
578f88e
Compare
mc-nv
marked this pull request as ready for review
July 15, 2026 23:39
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does the PR do?
Adds an experimental, opt-in build presets mechanism to
build.py, gated behindTRITON_BUILD_EXPERIMENTAL=1(off by default — no behavioral change when unused):--build-presets-file <json>pins per-component build settings — git tag, clone organization, library path, and extra/override CMake args — forcore/backends/repoagents/caches. Command-line flags take precedence over the file. A per-backendorgsets both thegit cloneURL and-DTRITON_REPO_ORGANIZATION, which the global--github-organizationcannot do per backend.--dryrun,build.pywritesbuild_presets.json— a provenance-annotated snapshot of every resolved cmake-Dflag each component receives (matchingcmake_build), each labeled with itssource:cli/preset/default. That file reloads via--build-presets-fileto reproduce the build.All load/validate/precedence/dump logic lives in
tools/build/build_presets.py; thebuild.pyintegration is intentionally minimal (an argparse flag, a guarded apply block, one line in the backend build loop, and the--dryrunsnapshot block).Also included:
qa/L2_build_presets— a self-contained pytest suite validating the documented scenarios viabuild.py --dryrun(no GPU / container / real build). Runs in-tree, viaTRITON_BUILD_PY, or self-clones in a bare container;test.shinstalls deps and writes a log + JUnit report.tools/add_spdx_header.py) that converts each changed source file's legacy NVIDIA BSD header to the two-line SPDX form (maintaining / replacing-in-place / inserting), coexisting withadd_copyright.py.Checklist
<commit_type>: <Title>Commit Type:
Related PRs:
None — single repo (
server).Where should the reviewer start?
build.py— the integration points: the--build-presets-filearg, the guarded apply block, the per-backend clone-org line in the backend build loop, and the--dryrunsnapshot block.tools/build/build_presets.py— all preset load / validate / precedence / dump logic.qa/L2_build_presets/build_presets_test.py— the scenarios covered.tools/add_spdx_header.py+.pre-commit-config.yaml— the SPDX migrate-on-touch hook.Test plan:
cd qa/L2_build_presets && bash test.sh→ 11 pytest scenarios pass: snapshot sections, per-flag source annotation,CMAKE_INSTALL_PREFIXexclusion, provenance (cli vs default), extra-channel routing, env gate, example apply, round-trip reload, and validation errors.Regression: the documented CI
build.pyinvocations produce byte-identicalcmake_buildwith the feature unused (verified via--dryrundiff).CI Pipeline ID:
Caveats:
TRITON_BUILD_EXPERIMENTAL=1).-Dvalues but does not re-derive conditionally-emitted flags; reload alongside the same top-level flags (or--enable-all) for exact reproduction.cmake_argsare snapshot-only (not re-pinned on load); theirtagis applied.Background
Follow-up to the TRI-829
build.pyCLI usability work: lets users declaratively pin per-backend build settings (including a per-backend clone org) and inspect exactly which cmake flags each component receives.Related Issues: