SuperKernel is a binary fusion technology for operators. Different from source code fusion, SuperKernel focuses on the binary scheduling solution of kernel functions and performs in-depth optimization. Based on the compiled binary code, a super kernel function (SuperKernel) is created to call multiple other kernel functions (subkernels) by calling sub-functions. Compared with single-operator delivery, the SuperKernel technology can reduce the task scheduling waiting time and scheduling overhead, and further optimize the operator header overhead by utilizing the task gap resources.
The development process for custom operators to support SuperKernel is similar to that of common operators. However, you need to pay attention to some specific restrictions (as described below). Currently, the SuperKernel feature can be used only in the PyTorch framework. Therefore, after integrating operators into a GE graph, you need to integrate them into a PyTorch graph by referring to Integrating Custom Operators to a Graph in PyTorch Graph Mode User Guide (TorchAir). In addition, TorchAir provides the capability of calibrating the scope of SuperKernel. You can annotate operators and configure optimizations within the fusion scope based on actual service requirements. For details, see "GE Graph Mode > GE Graph Mode Features > Marking the SuperKernel Scope in a Graph" in PyTorch Graph Mode User Guide (TorchAir).
The specific restrictions during development are as follows:
Note: The number of cores launched by the SuperKernel is the maximum number of cores launched by the sub kernel. Assume that the SuperKernel includes operator a (launching four cores) and operator b (launching two cores). In this case, the number of cores launched by the SuperKernel is four.
For performance considerations, the cache update mechanism in the SuperKernel scenario is as follows:
If you call the GetValue and SetValue APIs of GlobalTensor to read and write scalars in the GM, the DataCacheCleanAndInvalid instruction is automatically inserted into the two APIs during SuperKernel compilation to update a single cache line, ensuring data cache consistency. The DataCacheCleanAndInvalid instruction is not inserted before and after the sub kernel is called.
However, note that excessive calls to GetValue and SetValue will cause performance deterioration in the SuperKernel scenario. Therefore, you should minimize the calls to these APIs. For operators with excessive deterioration, SuperKernel provides compilation options dcci-before-kernel-start, dcci-after-kernel-start, and dcci-disable-on-kernel. You can disable the cache update instruction automatically inserted into GetValue/SetValue of a specified operator to improve model performance. The model user determines whether to insert the instruction for updating the entire DCache before or after the SuperKernel calls the operator. For details about the compilation options, see the description of the compilation options in SuperKernel range calibration in the graph.
In particular, in the tiling offload scenario, binary reuse optimization is usually involved, and the preceding cache update mechanism cannot be selected online. The SuperKernel framework inserts the DataCacheCleanAndInvalid instruction before and after each sub kernel is called to update the entire DCache. Cache is not automatically updated in GetValue and SetValue.
The following figure shows the cache update mechanism.

In addition, during programming on the kernel, you can call SetNextTaskStart and WaitPreTaskEnd to further improve performance.