Skip to content

feat(build): experimental build presets (--build-presets-file)#8886

Merged
mc-nv merged 5 commits into
mainfrom
mchornyi/TRI-829/build-presets
Jul 17, 2026
Merged

feat(build): experimental build presets (--build-presets-file)#8886
mc-nv merged 5 commits into
mainfrom
mchornyi/TRI-829/build-presets

Conversation

@mc-nv

@mc-nv mc-nv commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What does the PR do?

Adds an experimental, opt-in build presets mechanism to build.py, gated behind TRITON_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 — for core / backends / repoagents / caches. Command-line flags take precedence over the file. A per-backend org sets both the git clone URL and -DTRITON_REPO_ORGANIZATION, which the global --github-organization cannot do per backend.
  • On --dryrun, build.py writes build_presets.json — a provenance-annotated snapshot of every resolved cmake -D flag each component receives (matching cmake_build), each labeled with its source: cli / preset / default. That file reloads via --build-presets-file to reproduce the build.

All load/validate/precedence/dump logic lives in tools/build/build_presets.py; the build.py integration is intentionally minimal (an argparse flag, a guarded apply block, one line in the backend build loop, and the --dryrun snapshot block).

Also included:

  • qa/L2_build_presets — a self-contained pytest suite validating the documented scenarios via build.py --dryrun (no GPU / container / real build). Runs in-tree, via TRITON_BUILD_PY, or self-clones in a bare container; test.sh installs deps and writes a log + JUnit report.
  • Incremental SPDX license-header adoption — a migrate-on-touch pre-commit hook (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 with add_copyright.py.

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

  • feat

Related PRs:

None — single repo (server).

Where should the reviewer start?

  • build.py — the integration points: the --build-presets-file arg, the guarded apply block, the per-backend clone-org line in the backend build loop, and the --dryrun snapshot 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_PREFIX exclusion, provenance (cli vs default), extra-channel routing, env gate, example apply, round-trip reload, and validation errors.

  • Regression: the documented CI build.py invocations produce byte-identical cmake_build with the feature unused (verified via --dryrun diff).

  • CI Pipeline ID:

Caveats:

  • Experimental and off by default (gated behind TRITON_BUILD_EXPERIMENTAL=1).
  • Reload pins cmake -D values but does not re-derive conditionally-emitted flags; reload alongside the same top-level flags (or --enable-all) for exact reproduction.
  • Repoagent/cache cmake_args are snapshot-only (not re-pinned on load); their tag is applied.
  • The SPDX migrate-on-touch hook changes pre-commit behavior repo-wide (files migrate as they are touched); it can be split into its own PR if preferred.

Background

Follow-up to the TRI-829 build.py CLI 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:

  • Relates to TRI-829 (Linear)

mc-nv added 3 commits July 15, 2026 13:49
…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.
@mc-nv mc-nv self-assigned this Jul 15, 2026
Comment thread qa/L2_build_presets/build_presets_test.py Fixed
Comment thread tools/add_spdx_header.py Fixed
mc-nv added 2 commits July 15, 2026 14:00
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
mc-nv force-pushed the mchornyi/TRI-829/build-presets branch from 6f47c87 to 578f88e Compare July 15, 2026 21:23
@mc-nv
mc-nv requested review from nv-rinig, whoisj and yinggeh July 15, 2026 23:39
@mc-nv
mc-nv marked this pull request as ready for review July 15, 2026 23:39

@whoisj whoisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. @yinggeh will this conflict with your recent change?

@mc-nv
mc-nv merged commit 0ae38c7 into main Jul 17, 2026
3 checks passed
@mc-nv
mc-nv deleted the mchornyi/TRI-829/build-presets branch July 17, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants