Repository navigation
[CUDA] Avoid multi-root graphs on DGX/RTX spark - #4745
Merged
Merged
Conversation
dhiltgen
force-pushed
the
cuda-graph-single-root
branch
from
October 22, 2026 15:37
d30f34c to
127f757
Compare
Contributor
Author
Prompt processing (tok/s)mlx-lm benchmarks Gemma 4 26B-A4B (nvfp4)
Qwen 3.6 35B-A3B (nvfp4)
Qwen 3.6 27B (nvfp4)
Generation (tok/s)128 token generations: Gemma 4 26B-A4B (nvfp4)
Qwen 3.6 35B-A3B (nvfp4)
Qwen 3.6 27B (nvfp4)
|
zcbenz
reviewed
Oct 23, 2026
| params.gridDim = dim3(1); | ||
| params.blockDim = dim3(1); | ||
| cudaGraphNode_t root; | ||
| CHECK_CUDA_ERROR(cudaGraphAddKernelNode(&root, graph_, NULL, 0, ¶ms)); |
Member
There was a problem hiding this comment.
Would an empty node do the work? i.e. cudaGraphAddEmptyNode
Contributor
Author
There was a problem hiding this comment.
Unfortunately it doesn't work, and has the same slower performance as multi-root
zcbenz
force-pushed
the
cuda-graph-single-root
branch
from
October 25, 2026 10:10
127f757 to
3838495
Compare
zcbenz
approved these changes
Oct 25, 2026
rcfa
pushed a commit
to cubiculum-ai/mlx
that referenced
this pull request
Nov 26, 2026
Co-authored-by: Cheng <[email protected]> (cherry picked from commit 1e547d8)
Brooooooklyn
added a commit
to mlx-node/mlx
that referenced
this pull request
Nov 29, 2026
…aph limits, and Win32 NVRTC/PTX fixes Adapted for upstream: - ml-explore#4885: use private cache_memory_locked() and memory_limit_locked() while holding mutex_ in malloc_async()/free() to avoid recursive mutex deadlock, preserving overflow asserts. - ml-explore#4868: preserve move_to_device_memory() / cuda_malloc_async() / cuda_free_async(). - ml-explore#4711: preserve debug track_allocation/untrack_allocation and registered_data_ptrs_. - ml-explore#4706: preserve BIN_DIR macro and try/catch in delayload.cpp alongside resolve_bin_dir(), std::error_code guards, and unconditional nvrtc-builtins preload. - ml-explore#4745: preserve force_single_root_/roots_/get_noop_kernel_ptr() in cuda/device.{h,cpp}.
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.
Related to #4697
I've been trying to figure out the slowdown on RTX/DGX Spark systems with CUDA graphs. What appears to be going on is these systems are much less efficient when there are multiuple roots in the CUDA graph.
Instead of serializing the graphs, this PR aims to mitigate this by adding a single dummy root kernel in cases where MLX would have created multiple root nodes. This is limited to just CC 12.1 to avoid any impact to other systems which don't exhibit the negative impact with multiple roots. This achives significant speedup on prompt and modest generation performance improvements on these systems.
Prompt processing (tok/s)
mlx-lm benchmarks
Gemma 4 26B-A4B (nvfp4)
Qwen 3.6 35B-A3B (nvfp4)
Qwen 3.6 27B (nvfp4)
Generation (tok/s)
128 token generations:
Gemma 4 26B-A4B (nvfp4)
Qwen 3.6 35B-A3B (nvfp4)
Qwen 3.6 27B (nvfp4)