What Is GPU Kernel Fusion? When It Helps and How to Spot the Costs
GPU kernel fusion combines consecutive operations so they run in one GPU kernel. It can avoid writing an intermediate result to memory only for the next kernel to read it, and it can reduce kernel submissions. Fusion often helps when operations are lightweight and the intermediate has only one consumer. It can slow the workload if the combined kernel uses too many registers or too much shared memory, or repeats a calculation for multiple consumers.
What Is GPU Kernel Fusion? When It Helps and How to Spot the Costs
GPU kernel fusion combines consecutive operations so they run in one GPU kernel. It can avoid writing an intermediate result to memory only for the next kernel to read it, and it can reduce kernel submissions. Fusion often helps when operations are lightweight and the intermediate has only one consumer. It can slow the workload if the combined kernel uses too many registers or too much shared memory, or repeats a calculation for multiple consumers.
Do not judge by whether the kernel count fell. Compare the removed data movement and submission cost with the added resource and compute cost on the same inputs. The TensorRT example below reflects the 11.5 documentation reviewed on 2026-11-23; automatic fusion patterns and tool options vary by framework and version.
How does fusion change the data path?
Suppose one kernel transforms each element as y = a × x + b, and a second computes z = max(y, 0). As two kernels, the first writes an intermediate array y, and the next reads it. A fused kernel can read x, continue the calculation, and write only the final z. The key opportunity is to pass a value from one operation to the next without materializing an intermediate in global memory.
If an intermediate has N elements of s bytes each, explicitly materializing it causes at least one logical write of N × s bytes and a later read of N × s, or about 2Ns bytes. This is an arithmetic illustration of the explicit intermediate round trip. Actual DRAM traffic depends on caching and implementation, and a compiler may already avoid materializing the intermediate, so this expression alone cannot predict a speedup.
The NVIDIA TensorRT 11.5 documentation gives patterns such as Conv→ReLU and consecutive elementwise operations: the builder can combine a supported pattern into one optimized kernel. This can reduce per-layer launches and avoid writing an intermediate tensor to DRAM. That describes supported graph patterns during the TensorRT build, not a guarantee that any two arbitrary operations can be fused. TensorRT 11.5: Enabling Layer Fusion TensorRT 11.5: Layer Fusion Catalog
When is fusion more likely to help?
The savings are clearer when these conditions hold:
**The operations are consecutive in the dataflow.** The earlier result feeds the later operation, and both can be computed in one execution unit.
**The intermediate has one consumer, or only a particular consumer path is fused.** If several later operations share a producer’s result, a fused implementation may duplicate producer work or still need to store the intermediate for other consumers.
**The intermediate is large while each operation is relatively lightweight.** The avoided memory round trip may outweigh the additional work created by combining the operations.
**Submission cost from short kernels is an actual bottleneck.** Separate CPU submission time from GPU kernel time in a profile. A high call count alone does not prove that submission dominates.
**Operation order and numerical behavior can be preserved.** Check data-type conversions, rounding, exception behavior, synchronization, and observable side effects.
These conditions are a starting point, not a performance guarantee. Fusion changes both data movement and execution shape, so the result depends on workload size, target GPU, and the implementation selected by the compiler.
What changes when fusion costs exceed its benefits?
Combining operations can extend the lifetime of intermediate values and increase the code and resources needed by one kernel. CUDA documentation explains that register and shared-memory use affects how many blocks and warps can reside on an SM, while higher occupancy does not automatically mean higher performance. NVIDIA’s fused-kernel guidance also recommends checking register/shared-memory pressure and spills. The point is not that fusion must lower occupancy, but that its resource changes need to be measured. CUDA C++ Best Practices Guide: Occupancy and Register Pressure NVIDIA nvCOMPDx: Achieving High Performance
| Graph shape or profile signal | Why fusion may help | Why it may hurt and what to check |
|---|---|---|
| Consecutive elementwise operations write a large intermediate that is consumed once. | It may remove the intermediate write/read and one kernel submission. | Check whether the existing implementation already avoids the round trip through caching or compiler optimization, and whether final kernel time falls. |
| Many small kernels appear, and Nsight Systems shows repeated CPU API submission time is material. | Combining operations can reduce individual submissions. | If GPU execution time already dominates, fewer submissions alone may have limited impact. Separate API, queue, and kernel intervals. |
| Several later operations reuse the intermediate tensor. | A particular consumer path may be able to receive the intermediate directly. | Producer work may be duplicated or code complexity may grow. Compare partial fusion with putting all consumers into one kernel. |
| Register/shared-memory use, spills, or kernel duration increase after fusion. | Removing data movement may still outweigh these costs. | Compare resource pressure, occupancy, execution time, and the concurrent work required. Do not decide from occupancy alone. |
| Operations favor different block sizes, tiles, or library paths, or their workloads differ greatly in size. | Selective fusion of only some stages may be useful. | One kernel configuration may block each stage’s best configuration or reduce available parallel work. Compare separate stages with partial fusion. |
A worked example and CUDA Graphs are different choices
Hypothetical example: Suppose a workload applies x → a×x+b → ReLU to one million 32-bit floating-point values, and no other operation uses the intermediate. A simple two-kernel implementation that writes and rereads the intermediate entails a logical round trip of 1,000,000 × 4 × 2 = 8,000,000 bytes. If one kernel can do the calculation, it may avoid that explicit round trip and one submission. This is an explanatory byte calculation, not measured DRAM traffic or a predicted speedup. Caches, existing compiler fusion, register pressure, and workload size all need to be included in measurement.
Kernel fusion is also different from a CUDA Graph. Fusion puts operations in the same kernel and can remove a kernel boundary and the intermediate materialization between stages. A CUDA Graph represents operations such as several kernels and their dependencies so they can be submitted repeatedly with lower host overhead. Do not assume a graph merges kernel boundaries or automatically eliminates intermediate tensors. If CPU submission is the main problem, graph replay may be a suitable alternative; if intermediate memory traffic is the main problem, fusion is a more direct hypothesis. CUDA Programming Guide: CUDA Graphs
Verify before and after under the same conditions
**Record a baseline.** Fix representative input sizes and data types, GPU and software versions, accuracy requirements, and synchronization boundaries. Warm up, measure multiple runs, and preserve whole-application time from the user’s perspective.
**Inspect the bottleneck and dataflow.** In Nsight Systems, separate CPU API submission, queue wait, GPU kernels, and copies. Trace which intermediate values are written and how many operations consume them. A queue interval is not automatically wasted time.
**Try one small fusion first.** Start with a clear opportunity such as consecutive operations with one consumer. Check that numerical results and data-type/rounding behavior match the original within the required tolerance.
**Compare kernel resources and device time.** Use compiler output or Nsight Compute to inspect register/shared-memory use, spills, occupancy, and relevant pipeline metrics. Also check whether both GPU kernel time and whole-application time improve. Profiling can introduce overhead, so confirm final timing with a separate representative run under matching settings.
**Recheck different input sizes and consumer patterns.** Compare small, representative, and large inputs under deployment conditions. If fusion helps only at one size or duplicates work for another consumer, choose partial fusion, separate kernels, or no fusion.
You can inspect fusion applied by a framework
You may not write the kernels yourself: a deep-learning engine can fuse an operation graph during its build. For TensorRT 11.5, NVIDIA recommends enabling kINFO messages in the build logger or running trtexec --profilingVerbosity=detailed --dumpLayerInfo to inspect which fusions were applied. A layer name that combines two names, such as ip1 + relu1, is one documented indicator. Other engines and frameworks may use different labels and support different patterns, so check the documentation for the version you use. TensorRT 11.5: Inspecting Layer Fusion
The final decision comes from the results, not the kernel count. Adopt fusion only when correctness is preserved on the same inputs and execution conditions, whole-application latency falls, and the device-resource cost is acceptable. If submission cost alone is the issue, another submission optimization such as CUDA Graphs may be simpler; if kernel compute time dominates, optimize the compute or memory bottleneck directly. NVIDIA Nsight Systems Analysis Guide
Sources
[TensorRT 11.5: Optimizing TensorRT Performance](https://docs.nvidia.com/deeplearning/tensorrt/11.5.0/performance/optimization.html)
[TensorRT 11.5: Layer Fusion Catalog](https://docs.nvidia.com/deeplearning/tensorrt/11.5.0/performance/fusion-catalog.html)
[CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/)
[NVIDIA Nsight Systems Analysis Guide](https://docs.nvidia.com/nsight-systems/AnalysisGuide/)
[CUDA Programming Guide: CUDA Graphs](https://docs.nvidia.com/cuda/cuda-programming-guide/04-special-topics/cuda-graphs.html)
[NVIDIA nvCOMPDx: Achieving High Performance](https://docs.nvidia.com/cuda/nvcompdx/highperformance.html)