Repository navigation
cudaPackages.cudnn-frontend, python3Packages.transformer-engine: backport fixes for crashes at process exit - #577950
Draft
ConnorBaker wants to merge 2 commits into
Draft
ConnorBaker wants to merge 2 commits into
ConnorBaker wants to merge 2 commits into
Conversation
cudnn-frontend 1.31.0 keeps plans recorded into CUDA graphs alive and releases them through get_cuda_symbol(), whose library handle map is a function-local static. A static cache destroyed after that map at exit then reads freed memory. TransformerEngine's fused-attention graph cache does this, and its processes can crash with SIGSEGV at exit (NVIDIA/cudnn-frontend#1486). Apply the upstream fix from develop, which never destroys the map or its mutex. python3Packages.nvidia-cudnn-frontend builds from the same source, so it now takes the same patches. cudaPackages.tests.cudnn-frontend.teardown resolves a CUDA symbol from the destructor of a static constructed before the map, under AddressSanitizer. Without the fix it reports a heap-use-after-free in get_cuda_symbol(). It needs no GPU. The patch is applied only while the version is 1.31.0; any other version fails evaluation, so the next update has to check whether the release contains the fix. Assisted-by: Claude Code (Claude Opus 5.5)
ConnorBaker
force-pushed
the
cudnn-frontend-handle-map-teardown
branch
from
October 24, 2026 03:10
0821275 to
eac8f36
Compare
…cess exit TransformerEngine calls CUDA from two static destructors at exit, and processes can segfault there: - The static KernelManager, which owns the NVRTC-compiled kernels (LayerNorm, RMSNorm, softmax and others), unloads their modules through cuda_driver::call, whose symbol caches are function-local statics. Those are usually constructed after the KernelManager, so they're destroyed first. - The fused-attention graph caches destroy cuDNN plans retained by CUDA graphs. That resolves CUDA symbols through cudnn-frontend's get_cuda_symbol(), whose map can already be destroyed (fixed in cudnn-frontend by the previous commit). Apply both commits of NVIDIA/TransformerEngine#3733. The first never destroys cuda_driver::call's symbol caches; the second never destroys the KernelManager or the graph caches. Only the library changes are taken; the rest is test and CI changes. The patches are applied only while the version is 2.20.2; any other version fails evaluation, so the next update has to check whether the release contains the fix. Assisted-by: Claude Code (Claude Opus 5.5)
ConnorBaker
force-pushed
the
cudnn-frontend-handle-map-teardown
branch
from
October 24, 2026 15:53
eac8f36 to
dca4c23
Compare
6 of 13 tasks
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.
cudnn-frontend 1.31.0, on master since 2026-10-09, keeps execution plans alive for the CUDA graphs recorded from them (NVIDIA/cudnn-frontend#1195). Those plans are released through
get_cuda_symbol(), whose library handle map is a function-local static. A static constructed before that map is destroyed after it at exit, so when it releases such a plan, the lookup reads freed memory. TransformerEngine's fused-attention graph cache is one such static, and its processes can crash with SIGSEGV at exit (NVIDIA/cudnn-frontend#1486).Upstream fixed this on
developin NVIDIA/cudnn-frontend#1565 (NVIDIA/cudnn-frontend@473a2c8), which never destroys the map or its mutex. No release has it yet; 1.31.0 is the latest. This applies that commit withfetchpatch.python3Packages.nvidia-cudnn-frontendbuilds its extension from the same source and already reuses the package'ssrcandpostPatch, so it now takespatchesas well.python3Packages.transformer-enginecompiles againstcudaPackages.cudnn-frontend's headers, so it gets the fix through them.TransformerEngine has a second crash at exit, in its own code, which this PR also fixes.
cuda_driver::callcaches driver entry points in function-local statics. The staticKernelManagerthat owns its NVRTC-compiled kernels (LayerNorm, RMSNorm, softmax and others) is usually constructed before those caches, so it's destroyed after them, and its destructor unloads the kernels' modules through the destroyed caches. The second commit applies both commits of NVIDIA/TransformerEngine#3733 (open) withfetchpatch. The first never destroys those caches. The second never destroys theKernelManageror the fused-attention graph caches, so neither calls CUDA at exit, and TransformerEngine no longer releases retained cuDNN plans at exit. Only the library changes are taken; the rest of those commits is tests and CI wiring.This also adds
cudaPackages.tests.cudnn-frontend.teardown, built with AddressSanitizer. It resolves a CUDA symbol throughget_cuda_symbol()from the destructor of a static constructed before the map. Resolving a symbol only loads libcudart, so it needs no GPU.Testing
cudaPackages.cudnn-frontend(all outputs, including samples and tests) andpython3Packages.nvidia-cudnn-frontendbuild on x86_64-linux and aarch64-linux, and the installedcudnn_frontend_shim.hhas the fix.cudaPackages.tests.cudnn-frontend.teardownpasses on x86_64-linux and aarch64-linux.AddressSanitizer: heap-use-after-freeatcudnn_frontend_shim.h:163, the map lookup inget_cuda_symbol().cudaSupport = trueandcudaCapabilities = [ "8.9" ], I builtpython3Packages.transformer-enginefrom this branch, with JAX and PyTorch. That includes Torch 2.14.1, the JAX CUDA plugin and PJRT, onnxruntime and torchvision. I also built itspassthru.tests:withCusolvermp,withMpiandwithNvshmem;withJax,withPytorchandwithOutNcclEpare the default derivation.MALLOC_PERTURB_=165), and with 0 in 6 of 6 from both of the others. This crash is the cudnn-frontend one.test_torch_compile.pyexited with 139 in 4 of 4 runs (2 plain, 2 withMALLOC_PERTURB_=165) from both the parent and the cudnn-frontend commit alone, after all its tests passed. From this branch it exited with 0 in 4 of 4. All three ran 92 passed, 71 skipped, 1 xpassed. For the cudnn-frontend commit alone, gdb places the crash intransformer_engine::rtc::KernelManager::~KernelManager→rtc::Kernel::~Kernel, readingcuda_driver::call's symbol cache. That's the TransformerEngine one.tests/pytorch): with the cudnn-frontend commit alone, 12 of 20 files exited with 139 after their tests finished. From this branch, none did. Both have the same failing tests: 72test_numerics.pytolerance failures and CUDA out-of-memory errors intest_fused_rope.pyon the 24 GiB card.mainat NVIDIA/TransformerEngine@c9c92255: the fused-attention script exited with 139 in 6 of 6 runs without the fix and with 0 in 6 of 6 with it.test_torch_compile.pyon the same machine: without the fix, it exited with 139 in 1 of 2 plain runs and in 2 of 2 runs withMALLOC_PERTURB_=165. With the fix, it exited with 0 in every run. Both arms had the same test counts: 277 passed, 148 skipped, 1 xpassed.ci/nixpkgs-vet.shandnix-build ci -A eval.baselinefor x86_64-linux and aarch64-linux pass locally at this branch's head.The changes, the test and this description were written with Claude Code (Claude Opus 5.5); the commits carry an
Assisted-by:trailer.Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.🤖 Generated with Claude Code