perf: speed up TransformerEngine source builds#3333
Merged
Conversation
Signed-off-by: Jonas Yang <joyang@nvidia.com>
Member
Author
|
/ok to test d193bcb |
Signed-off-by: Jonas Yang <joyang@nvidia.com> (cherry picked from commit c86b28e6c28322f1fca7da289f3cc98f43dafbe7)
Member
Author
|
/ok to test a801ec5 |
Signed-off-by: Jonas Yang <joyang@nvidia.com>
Member
Author
|
/ok to test 26abf6d |
Member
Author
|
Root cause of the
This failure was therefore unrelated to the TransformerEngine optimization or Apptainer retry changes. |
terrykong
approved these changes
Jul 24, 2026
terrykong
enabled auto-merge (squash)
July 24, 2026 04:55
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 this PR do ?
Reduces cold TransformerEngine source-build time by limiting CUDA compilation to the H100/B200 architectures currently targeted by the image, increasing TE-native parallelism, enabling nvcc worker threads, and selecting only the PyTorch framework. All build knobs remain overridable.
It also makes the GB200/arm64 Apptainer source installation resilient to transient GitHub rate limiting while downloading build dependencies.
Why these TransformerEngine settings?
NVTE_CUDA_ARCHS=90;100The pinned TransformerEngine release defaults to building CUDA 13 code for
75;80;89;90;100;120. The NeMo-RL image currently setsTORCH_CUDA_ARCH_LIST="9.0 10.0"for H100 and B200, so compiling the four additional architecture families adds substantial source-build time without benefiting those targets. TransformerEngine internally expands architecture100into the required generic and Blackwell-specific variants for architecture-specific sources.This is the main performance optimization, but it has a compatibility tradeoff: this source-built TransformerEngine will not support A100, L40, or other omitted architectures. If the release image must remain broadly portable, the architecture restriction should instead be supplied only to the H100/GB200 CI builds as an overridable build argument.
NVTE_FRAMEWORK=pytorchTransformerEngine can auto-detect installed frameworks and build bindings for PyTorch, JAX, or Paddle. NeMo-RL and Megatron use the PyTorch bindings, so setting this explicitly makes the build deterministic and prevents an environment-dependent extra framework build. This is primarily a correctness/reproducibility guard; it is expected to contribute much less to the speedup than restricting CUDA architectures.
Apptainer dependency-download reliability
The GB200/arm64 image build also exposed a transient failure while Apptainer downloaded an unauthenticated GitHub patch:
docker/install_apptainer.shnow retries Apptainer's dependency downloader up to five times with exponential backoff (5s, 10s, 20s, and 40s between attempts). Apptainer cleans partial dependency files before each attempt; if all attempts fail, the script preserves the final nonzero status and fails the image build.Issues
None.
Usage
No user-facing API changes. Docker builds may override
NVTE_BUILD_MAX_JOBS,NVTE_BUILD_THREADS_PER_JOB,NVTE_CUDA_ARCHS, orNVTE_FRAMEWORKas build arguments.Performance comparison
The before and after measurements use the same CI build path and the same
Building transformer-engine/Built transformer-enginetimestamps.Before optimization
The baseline CI log reports:
uvbuilds these source packages concurrently; the three other native packages are sibling builds, not TransformerEngine phases. They all finish by 831.5s, while TransformerEngine continues until 4612.8s. TransformerEngine is therefore the critical path and remains active for 3,781.3s (63m01.3s) after the final listed sibling build completes.After optimization
The optimized CI log reports:
The sibling package timings remain similar, while TransformerEngine's source-build interval falls from 4,393.1s to 1,260.6s. After the final listed sibling build completes, the remaining TransformerEngine critical-path time falls from 63m01.3s to 10m34.4s.
Validation
Additional local measurements:
uv sync --link-mode symlink --frozen --extra mcore --no-install-project: 18m00s, including dependency downloads, recursive TE checkout/submodules, and concurrent native dependency builds.--call=outlinevalidation passed and exposed the intended argument defaults.bash -n docker/install_apptainer.shpassed.git diff --checkpassed.Before your PR is "Ready for review"
Pre checks:
Additional Information
The existing global uv cache continues to reuse completed TE wheels. A separate persistent ccache flow was intentionally avoided because it would not improve the first cold build and would require additional registry-cache lifecycle complexity for ephemeral CI builders.