Skip to content

improve(Build): Add build script capabilities - #8926

Open
jcuquemelle wants to merge 6 commits into
triton-inference-server:mainfrom
criteo-forks:improve_build_scripts
Open

improve(Build): Add build script capabilities#8926
jcuquemelle wants to merge 6 commits into
triton-inference-server:mainfrom
criteo-forks:improve_build_scripts

Conversation

@jcuquemelle

@jcuquemelle jcuquemelle commented Aug 10, 2026

Copy link
Copy Markdown

What does the PR do?

This PR adds several parameters to the main build script (and/or forwards them to ORT bakend build) to add configurability:

  • forward the main build parallelism to ORT nested build (this is partly addressed by fix(build): cap default build parallelism by available memory to prevent OOM #8873, but having the parameter forwarded makes it unified on nested build, and it allows to fix issues when the 2GB / concurrent compiler does not hold)
  • Define a CUDA arch list to support by the built image (and forward to ORT build). This allows to speed up the build and produce lighter artifacts when one doesn't need to support the full set of compute capabilities.
  • Allow to run the build in docker rootles mode by honoring DOCKER_HOST when defined.
  • Allow to use a local directory as --github-organization. This enables having a local clone of needed triton repos and build against them instead of fetching remote repositories, even in nested builds.

Checklist

  • I have read the Contribution guidelines and signed the Contributor License
    Agreement
  • 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.
  • I ran pre-commit locally (pre-commit install, pre-commit run --all)
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

Check the conventional commit type
box here and add the label to the github PR.

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

Related PRs:

triton-inference-server/onnxruntime_backend#354

Where should the reviewer start?

Only 1 file changed in the PR

Test plan:

Run the build with related options
Tested on internal CI

Caveats:

Only tested orwarding to onnx runtime, other backends could need adaption for these options to be active

Background

We needed this for adaption to our build system's constraints, and to iterate faster by adding a bit of incrementality on ORT binary build

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

None

@jcuquemelle
jcuquemelle force-pushed the improve_build_scripts branch from bd8e2e8 to 96b77a1 Compare August 11, 2026 07:06
@jcuquemelle
jcuquemelle marked this pull request as ready for review August 11, 2026 07:19
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR expands build-script configurability for nested backend builds and containerized development environments.

  • Forwards explicit build parallelism and CUDA architecture selections to nested builds.
  • Derives the default runtime compute-capability gate from the requested CUDA architectures.
  • Supports rootless or remote Docker daemons through DOCKER_HOST.
  • Normalizes and mounts local repository mirrors for container builds.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
build.py Adds build parallelism and CUDA architecture propagation, Docker daemon configuration, and local repository mirror support; the previously reported relative-path issue is fixed by normalizing the mirror path before propagation and mounting it at that absolute location.

Reviews (4): Last reviewed commit: "fix: github organization as relative pat..." | Re-trigger Greptile

Comment thread build.py
Comment thread build.py Outdated
jcuquemelle and others added 4 commits August 11, 2026 13:59
A small generic adaptation: Bind-mount `--github-organization` into the
cmake_build container when it is a local directory. This allows for nested
builds to use the local repositories instead of fetching them.

TRITON_REPO_ORGANIZATION already propagates into every nested component
configure (e.g. core -> common), so pointing the org at a local repo
mirror resolves all clones offline.
@jcuquemelle
jcuquemelle force-pushed the improve_build_scripts branch from 020bb7c to 432c610 Compare August 11, 2026 12:00
Normalize as absolute path for all usages
@Vinya567

Copy link
Copy Markdown
Contributor

Hi @jcuquemelle -

Thank you for the PR!

Confirmed on our side: this adds optional build.py knobs — --cuda-arch-list (via $CUDA_ARCH_LIST), DOCKER_HOST for rootless/remote Docker, and local --github-organization as a bind-mounted mirror.

Validated through our internal CI (Pipeline ID: 64574726, branch vinyak/tri-1722-server-8926 with your build.py changes on current main). py3-base ran ./build.py -v without --cuda-arch-list or --build-parallel, and DOCKER_HOST was unset. py3-devel and the existing ORT L0s passed.

Comment thread build.py
Comment on lines +88 to +89
DEFAULT_MIN_COMPUTE_CAPABILITY = "6.0"

@mc-nv mc-nv Aug 26, 2026

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.

This value can't be used currently we support 7.5 and higher and we no longer rely on it in favor of CUDA_ARCH_LIST
https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-feature-list

Comment thread build.py
Comment on lines +671 to +676
if FLAGS.build_parallel_was_explicit:
cargs.append(
cmake_backend_arg(
"onnxruntime", "TRITON_BUILD_PARALLEL", None, FLAGS.build_parallel
)
)

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.

I would suggest use --extra-backend-cmake-arg instead.

Comment thread build.py
Comment on lines +1727 to +1738
runargs += docker_runargs()
# If --github-organization is a local directory (a repo mirror), mount
# it too. The org propagates into every nested component configure
# (TRITON_REPO_ORGANIZATION), so pointing it at a local mirror is the
# only way to resolve deeply-nested clones (e.g. core -> common)
# offline; FETCHCONTENT_SOURCE_DIR overrides do not reach those builds.
# FLAGS.github_organization is already normalized as an absolute path
if FLAGS.github_organization and os.path.isdir(FLAGS.github_organization):
runargs += [
"-v",
f"{FLAGS.github_organization}:{FLAGS.github_organization}",
]

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.

I don't think it make sense to mess up git url prefixes with local mounts.

Comment thread build.py
Comment on lines +1769 to +1771
if FLAGS.cuda_arch_list is not None:
runargs += ["-e", f'"CUDA_ARCH_LIST={FLAGS.cuda_arch_list}"']

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.

It can be added to override some system defined variable.
Need more context on it.

Comment thread build.py
Comment on lines +2237 to +2261
def min_cuda_arch(arch_list_str):
# Lowest compute capability in a CUDA_ARCH_LIST-style string, as a decimal
# string ("8.6"). Accepts the space/semicolon-separated forms used across
# the Triton build: "8.6", "86", "75-real", "100f", "PTX". Tokens that don't
# parse are skipped. Returns None if no token parses.
if not arch_list_str:
return None
arch_list_str = arch_list_str.replace("PTX", "")
mins = []
for tok in re.split(r"[;\s]+", arch_list_str):
tok = tok.strip()
if not tok:
continue
tok = tok.rstrip("f").removesuffix("-real").removesuffix("-ptx")
try:
val = float(tok)
except ValueError:
continue
# "86" means 8.6; "8.6" stays; "100" means 10.0
if val >= 100:
val = val / 10.0
elif val >= 20 and val.is_integer():
val = val / 10.0
mins.append(val)
return f"{min(mins):.1f}" if mins else None

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.

Seams like a CMake codes for NVCC compiler, what is the motivation to add it here?

Comment thread build.py
Comment on lines +2276 to +2284
docker_host = os.getenv("DOCKER_HOST")
if docker_host is None:
return ["-v", "/var/run/docker.sock:/var/run/docker.sock"]

runargs = ["--network", "host", "-e", f"DOCKER_HOST={docker_host}"]
if docker_host.startswith("unix://"):
socket_path = docker_host[len("unix://") :]
runargs += ["-v", f"{socket_path}:{socket_path}"]
return runargs

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.

This need to be tested.

Comment thread build.py

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.

@jcuquemelle could you please share your build.py execution call so we can better understand the needs.

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