triton-kernels: make matmul_ogs_torch usable off CUDA and with default round_x - #1076
Draft
jiqing-feng wants to merge 1 commit into
Draft
triton-kernels: make matmul_ogs_torch usable off CUDA and with default round_x#1076jiqing-feng wants to merge 1 commit into
jiqing-feng wants to merge 1 commit into
Conversation
jiqing-feng
force-pushed
the
triton-kernels-matmul-ogs-torch
branch
from
August 13, 2026 07:25
6dccdf9 to
59b9527
Compare
…t round_x Two bugs in the reference implementation, both hit as soon as it is called with the documented defaults: - `device` defaulted to the string "cuda", so the internal `torch.arange(lo, hi, device=device)` raised "Torch not compiled with CUDA enabled" on an XPU-only build. Default to `x.device` instead, which is the same device on CUDA and therefore a no-op there. - the fallback `round_x = lambda x: x` takes one argument but the call site passes two (`round_x(x[batch, idx, :], torch.arange(lo, hi))`), so any caller that does not supply `round_x` got a TypeError regardless of backend.
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
Two bugs in the reference implementation, both hit with the documented defaults:
devicedefaulted to the string"cuda", so the internaltorch.arange(lo, hi, device=device)raised "Torch not compiled with CUDAenabled" on a build without CUDA. Default to
x.device, which is the samedevice on CUDA and therefore a no-op there. The annotation is widened to
match what the parameter now accepts.
the fallback
round_x = lambda x: xtakes one argument, but the call sitepasses two (
round_x(x[batch, idx, :], torch.arange(lo, hi))), so any callerthat does not supply
round_xgot aTypeErrorregardless of backend.Validation
matmul_ogs_torchnow runs with defaults and is usable as a reference to checkmatmul_ogsagainst. Checked on Intel Arc Pro B60,torch 2.13.0+xpu; theround_xarity bug is backend independent.