Adds Intel AMX TMUL hardware acceleration for FlashAttention using INT8 - #1043
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_977877682
branch
from
October 2, 2026 17:15
c9e5bb0 to
1fd4560
Compare
PiperOrigin-RevId: 992411459
copybara-service
Bot
force-pushed
the
test_977877682
branch
from
October 2, 2026 17:42
1fd4560 to
e52d655
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.
Adds Intel AMX TMUL hardware acceleration for FlashAttention using INT8
quantization:
TileFlashAttentionAMX_Int8_Impl(TileFlashAttentionAMX_Int8_ImplT)on top of Highway's AMX-INT8
Tile64BMatMulwrappers (ComputeQKPinQ256AMX_Int8,ComputeQKTileAMX_Int8,SoftmaxAndQuantizeAMX_Int8,ComputePVGroupAMX_Int8,AccumulatePVTileInt8). Theda/dbsignedness tags selectTDPBSSD(
int8 x int8) forQ*K^TandTDPBUSD(uint8 x int8) forP*V; tileconfig is compiler-managed via
__tile1024i, and runtime detection useshwy::HaveTile64BMatMulI8()(gated byGEMMA_HAVE_AMX_INT8).qkv_dim == 256(ComputeQKPinQ256AMX_Int8) by pinning a 16-queryhalf-block of
Qacrosstmm4..tmm7(4 x 64bytes) and streaming four32-token
Ktiles throughtmm2..tmm3, cuttingQtile loads by 4x andmaking post-
tilestoreddequantization contiguous.SoftmaxAndQuantizeAMX_Int8)with AVX-512 shuffle/permute intrinsics, and groups up to 4 query blocks
(128 queries) per 128-token KV macro-step (
ComputePVGroupAMX_Int8) withchannel-outer / query-inner loop ordering to keep
K,V, andP_vnnislicesin the 48 KB L1D cache and the KV step slice in the 2 MB L2 cache.
AttentionImpl::kFlashAMXInt8with quantized KV cache and querycompression.
flash_attention_test.ccandbenchmarks in
google_attention_benchmark_test.cc.helpers called
Tile64BRelease(), but once inlined into the kernel loop thecompiler does not reload the tile config after it, so the next iteration's
tile ops raised #UD. Release now happens once after the loop.
353597727402dfc7b28e5b1474766e366ceafd24, which adds the AMX-INT8 wrappers.