Register activation kernel layers on XPU - #47858
Draft
jiqing-feng wants to merge 1 commit into
Draft
Conversation
kernels-community/activation now ships an XPU backend, so map the six layers it provides to XPU as well. They were previously registered for CUDA only, which left XPU on the eager fallback. FastGELU, NewGELU and QuickGELU have no native PyTorch operator and expand into several element-wise launches in eager mode, so the fused kernel is several times faster. SiLU, GeLU and GeluTanh are on par with eager and are mapped for parity with CUDA.
Contributor
CI recapDashboard: View test results in Grafana |
Member
IlyasMoutawwakil
approved these changes
Aug 15, 2026
Member
|
@jiqing-feng tell me when it's ready |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kernels-community/activationnow ships an XPU backend, so map the six layersit provides to XPU in addition to CUDA. They were previously registered for
CUDA only, which left XPU on the eager fallback.
Affected entries in
_KERNEL_MAPPING:FastGELU,QuickGELU,NewGELU,SiLU,GeLU,GeluTanh. Each reuses the CUDA repository, layer name andversion, under
Mode.INFERENCE | Mode.TORCH_COMPILE.FastGELU,NewGELUandQuickGELUhave no native PyTorch operator andexpand into several element-wise launches in eager mode, so the fused kernel is
several times faster.
SiLU,GeLUandGeluTanhread and write the sameamount of data as the corresponding PyTorch operator and are on par with it;
they are mapped for parity with CUDA.
Validation
Checked on Intel Arc Pro B60 with
torch 2.13.0+xpu. All six layers run ineager mode and under
torch.compile, with compiled and eager resultsidentical:
FastGELUNewGELUQuickGELUSiLUGeLUGeluTanhSpeedups are
float16at16384 x 8192. The differences for the threecomposite activations are inherent to their approximations, which do not match
the PyTorch operator they are compared against, and are the same on CUDA.
Dependencies
Requires huggingface/kernels-community#1071, which adds the XPU backend to
activation, and huggingface/kernels#752, which that backend depends on. Bothmust be merged and an
activationbuild carrying the XPU variant published onthe Hub before this mapping resolves.