Graph fusion is a compiler optimization technique that merges multiple adjacent operators or nodes within a computational graph into a single, compound kernel. This fusion reduces kernel launch overhead and minimizes costly intermediate memory accesses by keeping data in fast registers or caches. It is a critical pass in hardware-aware model optimization for NPUs, GPUs, and other accelerators, transforming a sequence of fine-grained operations into a more efficient, coarse-grained computational unit.
Glossary
Graph Fusion

What is Graph Fusion?
A core optimization in neural network compilers for hardware accelerators.
The compiler performs fusion by identifying fusion patterns—groups of operators that are legally and beneficially combinable, such as a convolution followed by a bias add and ReLU activation. This process is tightly coupled with graph lowering and operator clustering. Successful fusion directly improves latency and throughput while reducing power consumption, making it foundational for inference optimization and efficient edge AI deployment.
Key Benefits of Graph Fusion
Graph fusion is a critical compiler optimization that merges multiple adjacent operators into a single, compound kernel. This technique directly addresses core performance bottlenecks in neural network execution on specialized hardware.
Reduced Kernel Launch Overhead
Each independent operator in a computational graph requires a separate kernel launch, which involves significant runtime overhead from the host CPU to the accelerator (NPU/GPU). This includes scheduling, argument passing, and synchronization. Graph fusion eliminates this overhead by merging multiple operators, resulting in a single launch for the fused block. This is especially impactful for models with many small, sequential operations, where launch overhead can dominate execution time.
Minimized Intermediate Memory Traffic
A primary bottleneck in accelerator performance is moving data between global memory and compute cores. Without fusion, each operator writes its output tensor to global memory, only for the next operator to immediately read it back. Fusion creates a single kernel where intermediate results are passed directly between operators via fast registers or shared memory, bypassing slow global memory accesses. This dramatically reduces the memory bandwidth requirement and associated latency and power consumption.
Enhanced Data Locality & Cache Utilization
By keeping intermediate tensor data within the high-speed memory hierarchy of the accelerator, fused kernels achieve superior data locality. This allows for more effective use of L1/L2 caches and reduces cache thrashing. Operations like element-wise additions followed by activations (e.g., Add → ReLU) can compute on data while it is still 'hot' in registers, avoiding the need to evict and reload data from slower memory levels.
Enablement of Complex, Hardware-Specific Kernels
Fusion allows compiler engineers to hand-optimize complex, compound operations that are perfectly tailored to the underlying hardware. For example, a fused Conv2D + BiasAdd + ReLU kernel can be written to use vendor-specific intrinsics and memory access patterns that would be impossible if the operators were separate. This unlocks peak FLOP/s and TOPS (Tera Operations Per Second) by maximizing hardware utilization and minimizing pipeline stalls.
Reduced Framework & Runtime Dispatch Cost
High-level frameworks like PyTorch or TensorFlow have dispatching logic for each operator, checking device placement, data types, and selecting appropriate kernel implementations. Fusing operators reduces the number of dispatches the framework runtime must handle, lowering CPU overhead and simplifying the execution graph. This leads to more predictable latency and is a key enabler for ahead-of-time (AOT) compilation and deployment on resource-constrained edge devices.
Facilitation of Advanced Optimizations
A fused subgraph is treated as a single unit, enabling further compiler passes that are not possible on isolated operators. This includes:
- Constant folding within the fused block.
- Common subexpression elimination across operator boundaries.
- Aggressive layout transformations for the entire fused operation.
- Automatic kernel auto-tuning on the compound kernel as a whole. Fusion thus acts as a foundational optimization that creates larger, more optimization-friendly blocks for downstream passes.
Common Graph Fusion Patterns
A comparison of fundamental patterns for merging operators within a computational graph to reduce kernel launch overhead and improve memory locality for NPU execution.
| Fusion Pattern | Description | Primary Benefit | Typical Operators Fused | Complexity / Trade-off |
|---|---|---|---|---|
Elementwise Fusion | Merges two or more operators that perform independent computations on each element of a tensor without requiring data movement between elements. | Eliminates kernel launch overhead and intermediate tensor writes/reads. | ReLU, Sigmoid, Tanh, Add, Multiply | Low complexity. High benefit with minimal trade-off. |
Vertical Fusion (Producer-Consumer) | Merges a sequence of dependent operators where the output of one is the direct input to the next into a single compound kernel. | Eliminates intermediate memory allocation and data movement between stages. | Conv -> BiasAdd -> ReLU, MatMul -> Add -> GELU | Medium complexity. Must handle potential data layout conflicts between ops. |
Horizontal Fusion (Parallel Fusion) | Merges independent operators that consume the same input tensor(s) into a single kernel that computes multiple outputs. | Reduces redundant memory reads of the shared input tensor and kernel launches. | Branching paths from a single input, e.g., computing multiple attention heads in parallel. | High complexity. Requires careful scheduling and may increase register pressure. |
Reduction Fusion | Fuses an elementwise or other operation with a subsequent reduction operation (e.g., sum, max) across one or more tensor dimensions. | Avoids materializing a full intermediate tensor before the reduction, saving significant memory. | Softmax (exp, sum, division), LayerNorm (mean, variance calculation) | Medium-High complexity. The reduction pattern must be identified and the fused kernel must handle the reduction loop. |
Input Fusion | Fuses small, preparatory operations (like casting, padding, or simple slicing) directly into the consuming kernel, often a large compute-intensive operation like convolution. | Offloads minor data preparation to the compute unit, avoiding extra kernels and memory traffic. | Cast -> Conv2D, Pad -> Conv2D, Slice -> MatMul | Low-Medium complexity. Often limited by hardware support for the fused preparatory operation. |
Residual Connection Fusion | A specialized pattern for fusing the operations in a residual (skip) connection pathway, typically an identity or 1x1 convolution, with the main pathway's operations. | Enables the entire residual block to execute as a single unit, optimizing the critical path for networks like ResNet. | Main_Branch_Op -> Add -> Activation, where the second input to Add is from a skip connection. | Medium complexity. Requires matching tensor shapes and may involve horizontal fusion principles. |
Complex Pattern Fusion (Kernel Library) | Replaces a known, frequent subgraph (e.g., an entire attention block or a convolution block) with a hand-optimized, monolithic kernel from a vendor library. | Maximizes performance by leveraging hardware-specific, manually tuned implementations for entire complex patterns. | Multi-Head Attention block, Conv2D -> BatchNorm -> Activation | Vendor-dependent. High benefit but requires pre-existing library support for the specific pattern. |
Frameworks & Compilers Using Graph Fusion
Graph fusion is a critical optimization implemented across the machine learning stack, from high-level frameworks to low-level compilers. These tools apply fusion to reduce kernel launch overhead and improve memory locality for NPU execution.
Hardware-Specific SDKs (TensorRT, Core ML)
Vendor SDKs perform final-stage graph fusion tailored to their silicon.
- NVIDIA TensorRT applies layer and tensor fusion to minimize kernel launches on its GPUs, combining operations like scale, clip, and activation.
- Apple Core ML tools fuse operations in the mlmodel graph specifically for Apple Neural Engine execution, optimizing for the unique memory hierarchy and execution units of ANE.
Frequently Asked Questions
Graph fusion is a foundational compiler optimization for neural network acceleration. This FAQ addresses common technical questions about its mechanisms, benefits, and implementation.
Graph fusion is a compiler optimization technique that merges multiple adjacent operators or nodes within a neural network's computational graph into a single, compound kernel. It works by analyzing the dataflow graph, identifying sequences of operations where the output of one operator is the immediate input to the next without external dependencies. The compiler then generates a custom, fused kernel that executes the entire sequence in one pass, eliminating the need to write intermediate results back to main memory and reducing kernel launch overhead. For example, a common pattern like Conv2D -> BiasAdd -> ReLU is a prime candidate for fusion into a single ConvBiasReLU kernel.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
These core compiler techniques work in concert with graph fusion to optimize computational graphs for efficient execution on hardware accelerators.
Operator Clustering
A precursor to fusion that groups sets of operators within a computational graph into logical clusters. These clusters are typically defined by hardware constraints (e.g., must fit on a specific core) or fusion heuristics. Clustering simplifies the fusion pass by identifying candidate subgraphs for merging.
- Purpose: To partition the graph for targeted optimization or distribution.
- Example: Grouping all convolution, batch norm, and ReLU operations into a single cluster destined for an NPU's tensor core.
Common Subexpression Elimination (CSE)
A compiler optimization that identifies and eliminates redundant calculations of identical expressions within a computational graph. It replaces duplicate computations with a single stored value, reducing computational overhead. While graph fusion merges distinct operators, CSE removes identical copies of the same operator.
- Key Difference: Fusion combines different, adjacent ops; CSE removes identical, potentially non-adjacent ops.
- Benefit: Decreases FLOPs and kernel launch count, complementing fusion's memory bandwidth savings.
Loop Fusion
A classical compiler optimization that merges two or more adjacent loops iterating over the same range into a single loop. This improves data locality by keeping intermediate results in registers or cache, and reduces loop overhead. Graph fusion can be seen as a generalization of this concept from loop nests to dataflow graphs.
- Analogy: Loop fusion for
for(i){A[i]=...}andfor(i){B[i]=A[i]*...}is analogous to fusing element-wise operations in a graph. - Hardware Impact: Both techniques aim to amortize memory access costs and improve instruction-level parallelism.
Graph Partitioning
The strategy of dividing a large computational graph into smaller, manageable subgraphs. This is often done for distribution across multiple devices (e.g., model parallelism) or to fit subgraphs into limited on-chip memory. Graph fusion is typically applied within partitions to optimize each subgraph before partitioning decisions are finalized or after.
- Use Case: Splitting a large vision transformer model across four NPU chips.
- Interaction with Fusion: The partitioner must be aware of fusion opportunities, as fusing ops can change a subgraph's memory footprint and computational profile, affecting the optimal partition.
Peephole Optimization
A low-level compiler pass that examines short sequences of instructions (a 'peephole') and replaces them with more efficient sequences. In graph compilation, this can manifest as pattern matching on small subgraphs (e.g., a Mul node followed by an Add node) and replacing them with a single, hardware-intrinsic Fused Multiply-Add (FMA) node. This is a form of fine-grained, local graph fusion.
- Scope: Local, instruction-level patterns.
- Example: Replacing
(x * 2.0) + ywith a singleFMA(x, 2.0, y)operation in the graph IR.
Memory Planning
A compiler pass that allocates memory buffers for all tensors in a computational graph, aiming to minimize peak memory usage. Graph fusion directly influences memory planning by eliminating the need for intermediate buffers between fused operators. Effective memory planning enables more aggressive fusion by ensuring fused kernels do not exceed available on-chip memory.
- Synergy: Fusion reduces buffer count; memory planning reuses buffers across non-fused ops.
- Critical for NPUs: Determines if large fused kernels can fit in fast SRAM or must spill to slower DRAM.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us