bridge.utils.cuda_graph#
Module Contents#
Functions#
Return configured per-layer CUDA graph module names. |
|
Set per-layer CUDA graph modules using the current MCore API when available. |
|
Clear per-layer CUDA graph modules using the active MCore API. |
|
Enable full-iteration CUDA graph capture using the current MCore API. |
|
Return whether a per-layer CUDA graph module is enabled. |
|
Return whether config enables full-iteration CUDA graph capture. |
|
Validate Bridge-supported CUDA graph implementation/scope combinations. |
|
Return whether Bridge should create a local MCore CudaGraphManager. |
|
Capture each Hybrid mixer position and the feed-forward position after it as one TE CUDA graph. |
API#
- bridge.utils.cuda_graph._as_list(value: Any) list[Any]#
- bridge.utils.cuda_graph._member_name(value: Any) str#
- bridge.utils.cuda_graph._member_name_list(value: Any) list[str]#
- bridge.utils.cuda_graph._member_names(value: Any) set[str]#
- bridge.utils.cuda_graph._supports_cuda_graph_modules(config: Any) bool#
- bridge.utils.cuda_graph._module_value(name: str)#
- bridge.utils.cuda_graph.cuda_graph_module_names(config: Any) list[str]#
Return configured per-layer CUDA graph module names.
- bridge.utils.cuda_graph.set_cuda_graph_modules(
- config: Any,
- modules: Any,
Set per-layer CUDA graph modules using the current MCore API when available.
- bridge.utils.cuda_graph.clear_cuda_graph_modules(config: Any) None#
Clear per-layer CUDA graph modules using the active MCore API.
- bridge.utils.cuda_graph.set_full_iteration_cuda_graph(config: Any) None#
Enable full-iteration CUDA graph capture using the current MCore API.
- bridge.utils.cuda_graph.has_cuda_graph_module(config: Any, module: Any) bool#
Return whether a per-layer CUDA graph module is enabled.
Supports both the current MCore
cuda_graph_modulesAPI and the deprecatedcuda_graph_scopevalues still present in older Bridge configs.
- bridge.utils.cuda_graph.is_full_iteration_cuda_graph(config: Any) bool#
Return whether config enables full-iteration CUDA graph capture.
- bridge.utils.cuda_graph.validate_cuda_graph_configuration(
- config: Any,
- *,
- config_name: str = 'model',
Validate Bridge-supported CUDA graph implementation/scope combinations.
- bridge.utils.cuda_graph.uses_local_cuda_graph_manager(config: Any) bool#
Return whether Bridge should create a local MCore CudaGraphManager.
- bridge.utils.cuda_graph.enable_hybrid_cuda_graph_pairs(config: Any) bool#
Capture each Hybrid mixer position and the feed-forward position after it as one TE CUDA graph.
Hybrid models such as Qwen3.5 run each decoder block as two positions, the mixer (attention or Gated DeltaNet) and its MoE or MLP, so per-layer Transformer Engine graphs launch two forward and two backward graphs per block. Megatron-Core’s
TransformerConfig.cuda_graph_pair_hybrid_layerscaptures each such pair as one graph, which halves the graph launches of the decoder blocks; Megatron-Core decides which adjacent positions it can pair. The same field also graphs the layers of Hybrid MTP blocks, which per-layer graphs leave eager, except withkeep_mtp_in_bf16in FP8/FP4 training ormtp_use_repeated_layerover more than one MTP depth. Losses and gradients stay bitwise identical. On a Megatron-Core without the field this changes nothing: depending on the config class, assigning an unknown field would raise or leave an unused attribute, so the assignment is guarded, as in_select_gdn_kernel_backend.- Parameters:
config – Model config or provider to update. A Hybrid model config forwards the field to its transformer config.
- Returns:
Whether Megatron-Core has the field and it was set.