TransformerEngine
AGENTS.md3.6k starsChanged 2 months agoApache-2.0View on GitHub
This file provides repository-specific guidance for working on Transformer Engine. README.rst, CONTRIBUTING.rst, docs/, qa/ remain the authoritative sources for user documentation, contribution policy, and executable CI behavior. Transformer Engine provides optimized building blocks for Transformer models on NVIDIA GPUs. It is not a complete model-training system. Higher-level frameworks and toolkits compose its operations and modules into models and own model-level orchestration. Most functionality is at or below the level of an individual Transformer layer. Tensor, sequence, expert, and context parallel…
- Deletes or force-pushes
- Installs packages
- Commits and pushes
Trending
Quiet since August.about the whole repository
Who's talking about NVIDIA/TransformerEngine
- NVIDIA/Megatron-LM“[ROADMAP][Updated on April 07] Megatron Core MoE Roadmap”GitHub · Aug 4, 2025 · 71 reactions
- radixark/miles“[Roadmap] Blackwell MXFP8 and NVFP4 RL training”GitHub · Feb 18, 2026 · 18 reactions
- @pythonhub.dev“TransformerEngine A library for accelerating Transformer models on NVIDIA GPUs, including using 8-bit …”Bluesky · Nov 24, 2024 · 18 likes
- NVIDIA/Megatron-LM“gpt-oss implementation”GitHub · Aug 11, 2025 · 13 reactions
- sgl-project/sglang“[Proposal] Overlap allreduce in tensor parallelism”GitHub · Aug 3, 2025 · 10 reactions
The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 27
Talked about on GitHub, Hacker News and Bluesky (27 times).
On GitHub · 25
- Aug 4, 2025[ROADMAP][Updated on April 07] Megatron Core MoE Roadmap — NVIDIA/Megatron-LM71 reactions · 23 comments
- Feb 18, 2026[Roadmap] Blackwell MXFP8 and NVFP4 RL training — radixark/miles18 reactions · 1 comment
- Aug 11, 2025gpt-oss implementation — NVIDIA/Megatron-LM13 reactions · 10 comments
- Aug 3, 2025[Proposal] Overlap allreduce in tensor parallelism — sgl-project/sglang10 reactions · 3 comments
- May 15, 2026[ROADMAP][2026 Q2] Megatron Core MoE Roadmap — NVIDIA/Megatron-LM9 reactions · 4 comments
20 more on GitHub
- Aug 15, 2025[Feature] Backward pass — nunchux-ai/nunchaku7 reactions · 10 comments
- Nov 24, 2022Add deepspeed, xformers, kernl, transformerengine, ColossalAI, tritonserver, VoltaML, etc — stochasticai/x-stable-diffusion4 reactions · 3 comments
- Mar 23, 2026[ROADMAP][2026 Q1] Megatron Core Roadmap — NVIDIA/Megatron-LM3 reactions · 4 comments
- Aug 18, 2025[main][feature][under updating]zero-overhead activation offload — NVIDIA/Megatron-LM3 reactions · 15 comments
- Nov 14, 2022Explore NVIDIA/TransformerEngine for speed/efficiency — huggingface/diffusers3 reactions · 2 comments
- May 25, 2026[feat] Generalized Tensor Parallelism (GTP) — NVIDIA/Megatron-LM2 reactions · 43 comments
- Mar 17, 2026[train][2/N] Support for Megatron PP + CP for R3 — NovaSky-AI/SkyRL2 reactions · 1 comment
- Mar 10, 2026[RFC] Random Hadamard Transform API for NVFP4 Quantization — pytorch/ao2 reactions · 17 comments
- Sep 23, 2025Add TE NVFP4 recipe tests and support in benchmarks — Lightning-AI/lightning-thundersays it tested it2 reactions · 1 comment
- Dec 27, 2024TORCH_NCCL_ENABLE_TIMING break nccl/matmul overlapping — pytorch/pytorch2 reactions · 22 comments
- Jul 16, 2024[FP8 options] Float8Linear vs TransformerEngine — pytorch/torchtitan2 reactions · 8 comments
- Apr 11, 2024Introduce float8 training — keras-team/keras2 reactions · 3 comments
- Sep 10, 2023Questions: Clarifying the use of FP8 for Training — Azure/MS-AMP2 reactions · 2 comments
- Aug 17, 2026[bug] patch transformer engine logic to allow fa2 on sm103 — NovaSky-AI/SkyRL1 reaction · 2 comments
- May 29, 2026Add CuTe DSL NVFP4 quantization with 4over6 FP16 scoring — flashinfer-ai/flashinfer1 reaction · 28 comments
- May 7, 2026Support 4over6 nvfp4 for quantizer and fused MoE — flashinfer-ai/flashinfer1 reaction · 18 comments
- May 6, 2026[Megatron-FSDP] Add conditional param.grad dereferencing logic to support full-iteration (FWD-BWD) CUDA graphability. — NVIDIA/Megatron-LM1 reaction · 5 comments
- Sep 20, 2025`torch._grouped_gemm` has poor performance for large batch sizes with dtype BF16 — pytorch/pytorch1 reaction · 7 comments
- Mar 19, 2025Thunder-generated backward for sigmoid may compute `nan` for large (in absolute values) negative inputs — Lightning-AI/lightning-thunder1 reaction · 2 comments
- Mar 8, 2025[Feature] Flash attention v3 support — NVIDIA-BioNeMo/bionemo-recipes1 reaction
On Hacker News · 1
- Sep 25, 2024TransformerEngine: A library for accelerating Transformer models on Nvidia GPUs2 points
On Bluesky · 1
- Nov 24, 2024TransformerEngine A library for accelerating Transformer models on NVIDIA GPUs, including using 8-bit floating point (FP8) precision on… — @pythonhub.dev18 likes and reposts
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
16 rules. About 0 are common, 10 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Do not copy version tables into this file.
- Distinctive: line 51
Verify current framework support before extending or documenting them.
- Very specific: line 79
Place framework-independent computation in transformer_engine/common/.
- Distinctive: line 83
Prefer designs that do not re-enter Python on every steady-state invocation.
- Very specific: line 132
Use a compatible NGC PyTorch or JAX development container when possible.
- Distinctive: line 170
Before limiting compilation to a small fixed number of jobs or threads, check the number of CPU cores available on the system and choose …
- Distinctive: line 280
Use the higher-level launcher for distributed, Megatron Core, FSDP, ONNX, and attention-backend coverage rather than reconstructing its …
- Very specific: line 323
When reporting a GPU or distributed failure, include the exact command, input shape/dtype/layout, relevant NVTE_* variables, GPU model and …
- Very specific: line 332
Use the relevant program under benchmarks/ and report its exact command.
- Distinctive: line 351
Run pre-commit on explicit changed paths:
- Distinctive: line 357
Run the framework lint that covers the changed code:
- Distinctive: line 369
Update documentation for changes to public APIs, supported behavior, defaults, environment variables, actionable error messages, …
- Very specific: line 379
Follow CONTRIBUTING.rst and .github/PULL_REQUEST_TEMPLATE.md.
- Distinctive: line 381
Every PR must be reviewed by its human author before it is submitted for maintainer review.
- Distinctive: line 386
Every contributed commit requires a DCO sign-off (git commit -s).
- Distinctive: line 396
If existing commits lack the correct sign-off, the following rewrites each commit after the branch point to add the trailer:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Transformer Engine Agent Guide
This file provides repository-specific guidance for working on Transformer
Engine. README.rst, CONTRIBUTING.rst, docs/, qa/ remain the authoritative sources for
user documentation, contribution policy, and executable CI behavior.
Project Scope
Transformer Engine provides optimized building blocks for Transformer models on NVIDIA GPUs. It is not a complete model-training system. Higher-level frameworks and toolkits compose its operations and modules into models and own model-level orchestration.
Most functionality is at or below the level of an individual Transformer layer. Tensor, sequence, expert, and context parallel techniques may be in scope when they affect Transformer Engine operations. Pipeline parallelism, distributed optimizer orchestration, and complete training loops generally belong to higher-level systems such as Megatron-LM.
Do not copy version tables into this file. Current hardware, CUDA, cuDNN,
compiler, Python, and framework requirements are maintained in README.rst
and docs/installation.rst.
External Integration References
Transformer Engine must remain understandable and testable from this
repository. Some integration-facing APIs are used primarily by downstream
projects, especially Megatron-LM. When the purpose or expected usage of such an
API is unclear, inspect the downstream integration and the corresponding
launchers under qa/ to understand its real usage. Treat that usage as
supporting evidence rather than the authoritative definition of Transformer
Engine behavior.
Preserve or add standalone tests in this repository for the relevant Transformer Engine contract whenever practical. Downstream integration tests supplement those tests; they do not replace them.
For external library dependencies such as cuDNN Frontend, consult the documentation matching the version supported by Transformer Engine rather than assuming behavior from the dependency's latest branch.
Repository Map
transformer_engine/common/: framework-independent C++, CUDA, C API, shared Python definitions, kernel dispatch, and CUDA-library integrations.transformer_engine/pytorch/: PyTorch public API, modules, quantized tensor types, recipes, attention, optimizers, state, and private C++ bindings.transformer_engine/jax/: JAX and Flax public APIs, primitives, custom calls, quantization, state, and private C++ bindings.transformer_engine/debug/: numerical debugging and inspection features. Verify current framework support before extending or documenting them.tests/cpp/andtests/cpp_distributed/: common-library tests.tests/pytorch/andtests/jax/: framework-specific unit, numerical, integration, attention, quantization, and distributed tests.qa/: launchers for Transformer Engine's authoritative CI test suites. The GitHub Actions workflows expose only a subset of the full CI; use the tests and launchers underqa/to determine the coverage expected by the project's internal CI.L0_*contains the basic contribution checks, while higher levels contain distributed, integration, and specialized coverage.benchmarks/: performance benchmarks and profiling utilities, separate from correctness tests.docs/: Sphinx sources, API references, tutorials, and notebooks.examples/: runnable PyTorch and JAX examples.build_tools/,setup.py,pyproject.toml, andMANIFEST.in: build, packaging, version, and wheel infrastructure.3rdparty/: Git submodules pinned by the parent repository.
Architecture and Ownership
Transformer Engine has a framework-independent common layer and framework-aware PyTorch and JAX layers.
The common layer owns reusable computation, the public C API, low-level dispatch, CUDA kernels, calls to CUDA libraries, runtime-compiled kernels, and shared concepts used by both frontends. The framework layers adapt tensors and execution models, manage framework-visible state, interpret recipes and options, and compose focused operations into user-facing modules.
Place framework-independent computation in transformer_engine/common/. When
a frontend needs compiled common functionality that is not already readily
available in both supported frameworks, expose it through the C API or a
Python-based DSL such as Triton and adapt it in that frontend's private binding.
Prefer designs that do not re-enter Python on every steady-state invocation.
CuTeDSL kernels dispatched from common C++ may be JIT-compiled and registered
through TVM FFI. Python may participate in initial registration and compilation,
but steady-state dispatch should use the cached C++/TVM FFI function.
Framework-specific tensor handling, autograd or transformation semantics, state,
and user-facing composition belong in the corresponding frontend.
Working architecture rules
These rules describe the intended architecture. Check them against the subsystem being changed and document necessary exceptions.
- The common layer must not depend on PyTorch or JAX.
- GPU kernels belong in the common layer; private framework bindings translate framework tensor and execution conventions into common API calls.
- User-visible policy and multi-operation composition belong in a frontend; low-level kernel selection belongs in the common layer.
- Device memory is owned by the framework and passed to common operations. Common-layer device allocation is exceptional.
- Execution plans and CUDA-library handles may be owned and cached by the common layer.
- Framework-native communication generally stays in the frontend unless communication is inseparable from common computation, as in some expert-parallel and communication/GEMM-overlap paths.
- Public C and Python APIs are compatibility boundaries. Private framework bindings may evolve together with their callers.
- PyTorch and JAX should expose equivalent intent where practical, while retaining framework-native APIs.
- Feature parity between the PyTorch and JAX frontends is the goal, but is not a requirement.
For a cross-layer change, trace the affected path:
Public framework API or module
-> framework Python implementation
-> private framework C++/FFI binding
-> public common C API
-> common dispatch and kernel implementationA shared C or CUDA change requires focused common-layer validation where applicable, plus validation through each affected frontend. Validate both PyTorch and JAX when both use the changed behavior or dispatch path. A frontend-only change does not require validation of the other frontend, though shared behavior, documentation, serialization, and feature parity may still be affected.
Build and Environment
Use a compatible NGC PyTorch or JAX development container when possible. For a
host build, follow docs/installation.rst. The selected framework must be
installed before Transformer Engine because the root build imports it while
configuring the framework extension. Development builds therefore use
--no-build-isolation.
Initialize the pinned source dependencies before the first build:
git submodule update --init --recursiveThe root editable build is the normal development build. Run it from the repository root. The frontend is detected automatically but can also be selected explicitly via NVTE_FRAMEWORK environment variable during build:
NVTE_FRAMEWORK=pytorch python -m pip install -e . -v --no-build-isolation
NVTE_FRAMEWORK=jax python -m pip install -e . -v --no-build-isolation
NVTE_FRAMEWORK=pytorch,jax python -m pip install -e . -v --no-build-isolation
NVTE_FRAMEWORK=none python -m pip install -e . -v --no-build-isolationCommon build controls are:
NVTE_CUDA_ARCHS: semicolon-separated target compute capabilities. For development, set this to the exact architecture being tested to avoid compiling unused variants. On Blackwell, use the architecture-specific target such as100arather than the100family selector, which expands to multiple variants. Use a family selector or explicit list when building for multiple GPU architectures or producing portable artifacts.MAX_JOBSorNVTE_BUILD_MAX_JOBS: concurrent compilation jobs.NVTE_BUILD_THREADS_PER_JOB: threads within a build job.NVTE_USE_CCACHE=1andNVTE_CCACHE_BIN: compiler caching.NVTE_CMAKE_BUILD_DIR: alternate common-library build directory.NVTE_BUILD_DEBUG=1: debug build.CUDA_HOME,CUDA_PATH,CUDNN_PATH, andCXX: toolchain selection.
Before limiting compilation to a small fixed number of jobs or threads, check the number of CPU cores available on the system and choose concurrency that fits the current machine.
Optional native components add discovery and linking requirements:
NVTE_WITH_NCCL_EP: NCCL expert parallelism; enabled by default for applicable Hopper-or-newer targets and requires compatible NCCL headers and libraries.NVTE_UB_WITH_MPI=1: MPI userbuffers bootstrap; requiresMPI_HOME.NVTE_ENABLE_NVSHMEM=1: NVSHMEM; requiresNVSHMEM_HOME.NVTE_WITH_CUBLASMP=1: cuBLASMp; may requireCUBLASMP_HOME.NVTE_WITH_CUSOLVERMP=1: cuSolverMp; may requireCUSOLVERMP_HOME.
See docs/envvars.rst, setup.py, build_tools/, and
transformer_engine/common/CMakeLists.txt for less common settings.
Rebuild scope
- Python-only change: no rebuild after an editable install; restart processes that already imported the module.
- C++ change, either in common code or a framework binding: rerun the same build command and configuration used to build Transformer Engine before the change. This preserves the selected frontends, architecture targets, and optional features.
- Build logic, compiler flags, optional features, or framework selection: rerun the full editable build; use a clean build tree if its generated state is incompatible.
- Submodule source or revision: rebuild native targets and validate the dependent component.
CMake normally reuses build/cmake. Before removing a build tree, check
NVTE_CMAKE_BUILD_DIR and the verbose build output. A clean tree is commonly
needed after changing toolchains, CMake generators, architecture targets, or
optional native dependencies.
Verify the imported build
NGC images may already contain Transformer Engine. After building, confirm that the framework sees a GPU and that TE resolves to the current worktree:
Sandboxing may block access to GPU devices. If a GPU visibility check fails or reports no devices, do not conclude that the system has no GPUs until the check has also been attempted outside the sandbox with the required permission.
python -c 'import torch, transformer_engine, transformer_engine.pytorch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available()); print(transformer_engine.__file__)'python -c 'import jax, transformer_engine, transformer_engine.jax; print(jax.__version__, jax.devices()); print(transformer_engine.__file__)'Testing
PyTorch and JAX tests require pytest. The qa/**/test.sh launchers install
the pytest version and plugins used by their suites and contain the
authoritative environment variables, configuration files, and command-line
options for specialized tests. Before running a test directly, find its
invocation or the closest analogous test in the relevant launcher and preserve
those settings. Use a focused python -m pytest command during iteration, then
use the launcher for the corresponding full suite.
Focused framework tests
# PyTorch
python -m pytest -v tests/pytorch/path/to/test_file.py -k 'specific_case'
python -m pytest -v tests/pytorch/test_sanity.py
# JAX: use the repository pytest configuration
python -m pytest -c tests/jax/pytest.ini -v \
tests/jax/path/to/test_file.py -k 'specific_case'
python -m pytest -c tests/jax/pytest.ini -v tests/jax/test_layer.pyCommon C++ and CUDA tests
Separately built after the main build.
cmake -GNinja -S tests/cpp -B tests/cpp/build
cmake --build tests/cpp/build
ctest --test-dir tests/cpp/build --output-on-failureFor a focused GoogleTest run:
tests/cpp/build/operator/test_operator --gtest_list_tests
tests/cpp/build/operator/test_operator --gtest_filter='*RelevantPattern*'QA launchers
CONTRIBUTING.rst requires the L0_* checks. Their scripts default to
TE_PATH=/opt/transformerengine and XML_LOG_DIR=/logs; override both for a
local checkout:
TE_PATH="$PWD" XML_LOG_DIR=/tmp/te-test-logs \
bash qa/L0_pytorch_unittest/test.sh
TE_PATH="$PWD" XML_LOG_DIR=/tmp/te-test-logs \
bash qa/L0_jax_unittest/test.sh
TE_PATH="$PWD" XML_LOG_DIR=/tmp/te-test-logs \
bash qa/L0_cppunittest/test.shInspect a QA script before running it: some install dependencies or require a particular container, GPU architecture, GPU count, or external repository. Use the higher-level launcher for distributed, Megatron Core, FSDP, ONNX, and attention-backend coverage rather than reconstructing its environment.
Validation by changed area
- Shared Python: focused behavior through each affected frontend.
- PyTorch or JAX API: focused frontend test plus related integration coverage.
- Private framework binding: loaded-extension check and a focused numerical or integration test.
- Common C/CUDA: focused C++ operator test plus each affected frontend.
- Build or packaging: build in an appropriate clean environment, verify
artifact paths, then use
qa/L0_pytorch_wheel/orqa/L0_jax_wheel/. - Distributed component: smallest supported multi-process case, then its QA launcher; record the GPU count and topology.
- Public API: tests, documentation, and compatibility across supported callers.
Numerical and Backend Validation
For numerical or low-precision changes:
- Compare outputs and applicable gradients with an independent native-framework or higher-precision reference, not only shapes or successful execution.
- Cover the affected dtypes, recipes, layouts, boundary shapes, forward and backward paths, and GPU architectures.
- Base tolerances on the operation, dtype, accumulation, and reference. Do not loosen them solely to make a failing case pass.
- Record flags such as
NVTE_ALLOW_NONDETERMINISTIC_ALGOthat change expected numerical behavior. - Exercise the intended backend and fallback behavior when the operation can use cuDNN, FlashAttention, unfused attention, Triton, NVRTC, or an architecture-specific kernel.
- Give skips and expected failures a capability-based or tracked-defect reason; do not remove a failing configuration before identifying its cause.
Choose tolerances for the quantity being compared, not merely for the lowest precision used internally. For example, an MXFP8 GEMM that returns BF16 should use BF16-appropriate output tolerances rather than FP8-appropriate tolerances when its operands are chosen to be exactly representable in MXFP8. One way to construct such operands is to generate random values, quantize and dequantize them, and use the resulting values in both the reference and operation under test. Apply this construction to every quantized operand, including parameters held by a module such as weights, not only to the module's explicit inputs.
When reporting a GPU or distributed failure, include the exact command, input
shape/dtype/layout, relevant NVTE_* variables, GPU model and count, compute
capability, topology, and framework/CUDA/cuDNN/NCCL/driver versions. Also verify
which backend was selected and that the imported extension came from the
current worktree. Reduce failures across ranks, shapes, recipes, and backends
while preserving the observed behavior.
Performance Changes
Use the relevant program under benchmarks/ and report its exact command. A
performance result must identify the selected TE backend or kernel, GPU model
and count, software versions, shapes, layouts, dtypes, recipes, warm-up,
synchronization, input distribution, and measurement statistic. Separate
compile or autotune time, Python launch overhead, communication, and
steady-state kernel time where they materially affect the result.
Compare on equivalent hardware and software configurations and confirm numerical correctness before accepting a faster result. Do not place one-off performance measurements in correctness tests.
Formatting and Linting
- C++ follows the Google C++ Style Guide and local conventions.
- Python is formatted with Black at line length 100.
- C++, CUDA, and headers under
transformer_engine/use the repository clang-format configuration. - CI linting uses pylint and cpplint through the framework L0 scripts.
Run pre-commit on explicit changed paths:
pre-commit run --files path/to/changed.py path/to/changed.cuRun the framework lint that covers the changed code:
TE_PATH="$PWD" bash qa/L0_pytorch_lint/test.sh
TE_PATH="$PWD" bash qa/L0_jax_lint/test.shBoth lint scripts also inspect common code. Use CPP_ONLY=1 or PYTHON_ONLY=1
to select one half during iteration.
Documentation
Update documentation for changes to public APIs, supported behavior, defaults, environment variables, actionable error messages, installation/build requirements, or performance-relevant behavior.
- Environment variables are documented in
docs/envvars.rst. - Standalone examples live under
examples/pytorch/andexamples/jax/. - Tutorials and notebooks live under
docs/examples/.
Contribution Requirements
Follow CONTRIBUTING.rst and .github/PULL_REQUEST_TEMPLATE.md.
- Every PR must be reviewed by its human author before it is submitted for maintainer review. If an agent prepares a PR fully autonomously, the PR must remain a draft, and the agent must notify the user working with it that they need to review the PR before marking it ready for maintainer review.
- PR and commit titles use imperative mood.
- Every contributed commit requires a DCO sign-off (
git commit -s). - New files must satisfy
qa/L0_license/test.sh. If a contributor retains separate copyright, use the documentedexclude_copyrightmechanism. - Contributions require applicable tests and documentation, no new warnings,
and the
L0_*checks described inCONTRIBUTING.rst.
TE_PATH="$PWD" bash qa/L0_license/test.shIf existing commits lack the correct sign-off, the following rewrites each commit after the branch point to add the trailer:
base_ref=origin/main # Replace with the PR's target branch when different.
merge_base=$(git merge-base "$base_ref" HEAD)
git -c user.name="HUMAN NAME" -c user.email="HUMAN EMAIL" \
rebase --signoff "$merge_base"Rebasing changes commit IDs. Obtain the user's explicit approval before doing
this on a published branch or updating it with git push --force-with-lease.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

