Repository navigation
Apply the RPBH pre-round inside the 8-bit activation kernel (0.16.1) - #26
Merged
Merged
Conversation
The absmax INT8 activation kernel now applies the first RPBH round of rotation_rounds="auto"/2 in its own row pass instead of a separate RPBHRotator kernel. It loads each row coalesced, permutes it in shared memory (tl.gather), applies the round in FP32 and rounds to bf16 once, as the separate pass did. Codes and scales match 0.16.0 bit for bit for plain, strided and fp32 inputs and every prologue variant. RTX 5090, torch 2.12.1+cu130, 4096-9216 tokens, per call: - d = 9536: two rounds 0.22-0.49 ms (0.16.0: 0.57-1.31 ms; 0.16.0 with one round: 0.22-0.48 ms). - d = 3840: two rounds 0.05-0.10 ms (0.16.0: 0.12-0.28 ms; one round 0.08-0.10 ms). - A norm or modulation prologue keeps its own kernel. With one, the two rounds take 15-22% longer than the 0.16.0 one-round quantizer at d = 9536 and d = 13568. Other changes: - The one-round absmax quantizer reads a plain bf16 row coalesced and skips the token-norm pass whose norms the scales overwrote: 19-38% less time at 4096-9216 tokens. - RPBHRotator runs blocks below 512 as one row per program (d = 9536, 4096 rows: 0.37 ms -> 0.10 ms), which speeds up the Lloyd-Max two-round path. - num_warps of the absmax row kernel follows the row width and the RPBH block (measured: 256-wide blocks run 6-31% faster on 4 warps). - OrbitQuantLinear hands the unrotated input to the CUDA absmax quantizer.
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.
The 8-bit absmax activation kernel now applies the first RPBH round of
rotation_rounds="auto"/2in its own row pass. 0.16.0 ran that round as a separateRPBHRotatorkernel, which wrote the rotated input back to memory. On Fibo 2.0 Dev W4A8 that pass cost 11% of the time per image.Changes
_rpbh_absmax_int8_kernelloads each row coalesced and permutes it in shared memory (tl.gather, Triton >= 3.2). With the pre-round it applies the first RPBH round in FP32 and rounds to bf16 once, asRPBHRotatordid, then applies the paper round, the absmax and the INT8 store. Inputs up to 16384 wide use it; wider inputs keepRPBHRotatorin front.RPBHRotatorruns blocks below 512 as one row per program. This affects the Lloyd-Max two-round path. At d = 9536 and 4096 rows the rotation time drops from 0.37 ms to 0.10 ms.num_warpsof the absmax row kernel depends on the row width and the RPBH block. The values come from a sweep on the RTX 5090.OrbitQuantLinearpasses the unrotated input to the CUDA absmax quantizer, and the quantizer applies both rounds.Bit identity
RPBHRotator, then the one-round kernel. They cover d = 1920, 3840, 9536 and 16640 with 9 input cases each: plain, strided, fp32,norm_modulate,rms_scale_indexed,rms_plain_shift_indexed,layer_one_plus,rms_torchandmultiply.Timing
RTX 5090, torch 2.12.1+cu130, Triton 3.7.1. Values are ms per call, the median of 5 batches of 50 calls.
At 4096-9216 rows and d = 1920, 3840, 9536 and 13568, the two-round quantizer takes at most 4% longer than the 0.16.0 one-round quantizer. In CUDA graph replay, which excludes the CPU launch cost, the difference is at most +8% (d = 1920).
Not reached
Gates
uv run ruff check .passes.uv run pytest -ra: 694 passed, 210 skipped.scripts/run_paper_methodology_checks.sh,scripts/run_hf_compat_checks.sh --mode alland the MPS gate on Apple Silicon pass.scripts/run_cuda_kernel_checks.shpasses, including the prebuilt native package.tests/test_shared_projection.py::test_real_cuda_projection_reuse_is_bit_identical. That test fails the same way on 0.16.0 on that host: no native packed-matmul package was provisioned, andauto_fusedfalls back to the per-forward dequant.