Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CUDA] Add debug env to save cuda graphs to dot files#2825

Merged
zcbenz merged 1 commit intoml-explore:mainfrom
zcbenz:print-cuda-graph
Nov 25, 2025
Merged

[CUDA] Add debug env to save cuda graphs to dot files#2825
zcbenz merged 1 commit intoml-explore:mainfrom
zcbenz:print-cuda-graph

Conversation

@zcbenz
Copy link
Collaborator

@zcbenz zcbenz commented Nov 24, 2025

By setting the MLX_SAVE_CUDA_GRAPHS_DOT_FILE=graph env the CUDA graphs will be saved to graph_1.dot, graph_2.dot ... files.

Comment on lines +436 to +441
static std::unordered_set<std::string> saved_keys;
auto [_, new_graph] = saved_keys.insert(graph_key);
if (new_graph) {
auto path = fmt::format("{}_{}.dot", filename, saved_keys.size());
CHECK_CUDA_ERROR(cudaGraphDebugDotPrint(graph_, path.c_str(), 0));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should save all the graphs and not just the unique graph_key?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah simply saving all graphs should be enough for most cases.

Copy link
Member

@awni awni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@zcbenz zcbenz merged commit 23a9168 into ml-explore:main Nov 25, 2025
10 checks passed
@zcbenz zcbenz deleted the print-cuda-graph branch November 25, 2025 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants