Repository navigation
Conversation
…-xpu On XPU, InklingAttention norms q in place on the packed [q | k | v | r] row through sgl-kernel-xpu's rmsnorm_heads_inplace, skipping the compaction copy and launch that reshaping the strided q slice for apply_qk_norm forces. The op is imported only on XPU; without it, or for a geometry it does not admit, apply_qk_norm runs as before. CUDA and ROCm take the unchanged path. Also fix two failures that stop Inkling on XPU at default settings: - inkling_common.attn failed to import (No module named 'cutlass'): is_batch_invariant's module eagerly imports the CUDA-only cutlass, so fall back to False, which is what it returns wherever cutlass is absent. - _get_inkling_ar_resources raised from torch.cuda.is_current_stream_capturing() on XPU; check is_cuda() first.
This was referenced Oct 5, 2026
jmunetong
marked this pull request as ready for review
October 6, 2026 22:47
This branch has not been deployed
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.
Motivation
This reworks #37323 so the q-norm optimization is XPU-only: the kernel-side trick moves to sgl-kernel-xpu (sgl-project/sgl-kernel-xpu#529), and this PR only calls it on XPU. Two fixes that stop Inkling on XPU at default settings are also carried over.
qis a strided slice of the packed[q | k | v | r]projection row.apply_qk_normreshapes it to(T*H, D), which forces a compaction copy and an extra launch. On XPU,qis now normed in place on the row withsgl_kernel.rmsnorm_heads_inplace.inkling_common.attndoesn't import on XPU.is_batch_invariant's module eagerly importscutlass, which is CUDA-only (absent frompyproject_xpu.toml), soimportfails withNo module named 'cutlass'._get_inkling_ar_resourcesraises on XPU. It callstorch.cuda.is_current_stream_capturing()before checkingis_cuda(), and that raisesTried to instantiate dummy base class _cuda_isCurrentStreamCapturing.Modifications
3 files, +240/−6.
inkling_common/attn.py:rmsnorm_heads_inplace/rmsnorm_heads_inplace_supportedare imported only underis_xpu(), insidetry/except ImportError. Against a wheel without them, the fast path is simply off.__init__decides once whether the row geometry is admitted, through the kernel repo's_supportedhelper (TP=16/32 are refused since their tail isn't whole heads).elif self._xpu_q_norm_ok and self._xpu_norm_q_inplace(q). It recovers the packed row fromq's own storage and declines (falling through toapply_qk_norm) ifqisn't the leading slice of a row of the expected width, or isn't bf16/fp16._project_qkvrand every CUDA/ROCm line are unchanged.is_batch_invariantimport falls back toFalseonImportError._batch_invariantis only ever set by the fa4 path, which needscutlassitself, soFalseis what the real module returns wherever this fallback can be reached. On CUDA the import succeeds as before.inkling_common/kernels/comm.py: checkis_cuda()beforetorch.cuda.is_current_stream_capturing(). On CUDA the first check passes, so behavior is unchanged; on ROCm both orders already returnedNone.Compared to #37323, this drops the
_project_qkvrsignature change, the inline pad arithmetic (nowrmsnorm_heads_inplace_supported), the position-id cache (now in the op), and the attention-backend assert-message edit.Accuracy Tests
test/registered/xpu/test_inkling_xpu_q_norm.py, registered tostage-b-test-1-gpu-xpu, 5 tests:attnimports,is_batch_invariant()isFalsecutlassimport failureNoneis_current_stream_capturingraisexpu_qkvr_widthand the init-time gateqmatchesF.rms_norm;k,v,rbit-identicalqin_xpu_norm_q_inplace, bf16/fp16, T ∈ {1, 8, 512}qand fp32qdeclined, row untouchedBoth regression cases fail on current
mainwith the exact errors above, and pass here. With the op injected from sgl-project/sgl-kernel-xpu#529, all 5 pass. The op's own contract (rotary off at nonzero positions, the tail never written, refusals) is tested in sgl-kernel-xpu. Intel Arc Pro B60, torch 2.15.0.dev20260912+xpu.Not yet verified: a full Inkling server run on this branch. #37323's end-to-end A/B used the same in-place call.
Speed Tests and Profiling
The native call is the same as #37323's, so these are that PR's numbers, not re-measured here. q+k norm device time (profiler self-time, min of 5 interleaved reps), Arc Pro B60, torch 2.12.0+xpu, Inkling TP=8 per-rank rows:
Kernel count per layer goes from 4 to 3. End to end, #37323's tp=4 A/B on a 6-layer reduced checkpoint found the win real but immaterial at that geometry: 0.010% of a 682 ms TTFT, well inside run-to-run noise.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #37543020377
Latest PR Test (Extra): ❌ Run #37543020094
Latest PR Test (AMD ROCm 10): ❌ Run #37543020471