Repository navigation
Feature/int8 w8a8 - #540
Open
YunseonShin wants to merge 13 commits into
Open
YunseonShin wants to merge 13 commits into
YunseonShin wants to merge 13 commits into
Conversation
…e npu torchao W8A8's mm(int32(i8), int32(i8)) ran as a CPU fallback; the post-grad rewrite int_mm makes it aten._int_mm.
…rdinate descent npu's mm decomposition is traced with coordinate descent off, and a 1-row int_mm sums in int32 (M 1 W8A8: 188208 -> 31281 cycles).
…prologue The mm template is offered beside the resident mm when the streamed operand is widened, so torchao weight-only compiles and fuses the widening.
… when it does arithmetic As XLA computes a row's scale in its own fusion; the W8A8 mm epilogue recomputed it per element (K1024 mm 12545 -> 10875 cycles).
…d, as before e0ba086d stored histc's ge mask, which mistral's decode kernel then read through an index: an i1 pointer bitcast the compiler front end refuses.
… as v6e keeps a W8A8 activation in VMEM autotune/on_chip.py elects them per graph within the resident budget; each kernel states them as on_chip in its spec, the JSON one included (PTB dcf3386b takes the field).
…epilogue, not recomputed by its reader Its reader (a row norm, SiLU(gate) * up) no longer reads the int32 accumulator back (Qwen3 W8A8 prefill 814.2 -> 664.5 us). New case rownorm in test_w8a8_linear.
…es a Linear with no bias rownorm's bias-free Linear crashed it before the skip; with torchao all three cases pass, without it dynamic and static.
…the W8A8 tests join the allowlist and the matrix diffusers 0.34 fails to import beside torchao 0.18 (its torchao quantizer logs before defining logger). Allowlist 59/62, the three failures as before (llama4, mllama, conv_decomposition).
… its precompile a finished future torch 2.14 precompiles template choices through async_compile.triton(kernel_name=, source_code=).future; test_graph_prefetch, test_graph_prefetch_xla and test_on_chip failed on it, upstream 28150cf included.
RoPE's cos/sin were stored transposed, so PTB rejected the 2D RoPE kernel (masked-box-before-tensor) in Llama3x and Gemma 3-1b. Both pass now; W8A8 Linear and Qwen3 W8A8 layer cycles are unchanged.
…hmarked Inductor maps each compile future to one pending fusion, so a W8A8 MLP's gate dropped its dequant epilogue when up's fused kernel was the same source. Qwen3 W8A8 MLP 128: 6 -> 5 kernels, 154.0 -> 141.0 us; prefill 128: 17 -> 14 kernels, 239.0 -> 220.1 us.
…t8 on the matrix unit, kernel format 11) and #408 (the JSON spec states on_chip)
YunseonShin
force-pushed
the
feature/int8-w8a8
branch
from
November 18, 2026 08:44
d34b416 to
0488118
Compare
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.
PyTorchSim: PR into
pytorchsim-triton-backendBranch: local
feature/int8-dequant-epiloguein.worktrees/pts-c. Push it asfeature/int8-w8a8→pytorchsim-triton-backend.pytorchsim-triton-backend.Depends on: the PyTorchSim-Triton-Backend PR. The pin must name a PTB commit whose image is published.
Title: [Frontend] W8A8 and W8A16 on the npu: int8 matmuls stay on the device, as the v6e runs them
Summary
This makes torchao's int8 quantization run on the npu, with no CPU fallback:
Int8DynamicActivationInt8WeightConfigand static per-tensor activations;The kernels are shaped the way XLA shapes them on a TPU v6e. The int8 matmul is
aten._int_mmon the matrix unit, the weight widening is the mm template's prologue, and the dequantized result is stored by the matmul's epilogue. An activation that only matmuls read stays in the scratchpad.Cycle and time figures are TOGSim simulations unless marked as hardware.
Changes
int8 matmuls on the device
aten._int_mmon the npu.mm(int32(int8), int32(int8)), which ran as a CPU fallback.int_mm(postgrad/gemm.py) makes itaten._int_mm.int_mmwhen torchao turns on coordinate descent.int_mmsums in int32.Values read again
gemask made mistral's decode kernel read it through an index.Placement
autotune/on_chip.pyelects such intermediates per graph, within the resident budget.KernelSpec.on_chip.Tests and CI
test_w8a8_linearruns without torchao: its own W8A8Linear takes a Linear with no bias.logger.thirdparty-b6d2a9b115c3.tests/ops/gemm/test_int_mm.pytests/ops/gemm/test_widened_weight_mm.pytests/ops/gemm/test_w8a8_linear.pytests/system/test_on_chip.pyCompiler pin
third_party/pytorchsim-triton-backend.jsonstep by step to b012d9e2. See "Before merge".Testing
Allowlist (
scripts/ci/triton_route_passing.txt, 59 entries) at 2f83e6b with PTB b012d9e2: 56/59.test_llama4test_mllamatest_conv_decomposition_depthwise_kernelreads below the DRAM base (padding column)Allowlist with the new image's packages (torchao 0.18.0, diffusers 0.37.1, 62 entries): 59/62.
test_int_mm,test_widened_weight_mmandtest_w8a8_linearpass.test_w8a8_linearruns all three cases, rownorm included.New tests without torchao:
test_w8a8_linearpasses dynamic and static and skips rownorm.test_on_chip(no kernel, matrix only) passes.CPU fallbacks: none in the W8A8 tests. The generated wrappers have no
torch.opsorextern_kernelsassignments.Timing against TPU v6e measurements (tpu-perf-archive)
Simulated time ÷ measured time:
Known differences, left for follow-up work:
Before merge
third_party/pytorchsim-triton-backend.jsonto its merge commit onmain, the one with a published image.