Skip to content

Adds Intel AMX TMUL hardware acceleration for FlashAttention using BF16 - #1039

Merged
copybara-service[bot] merged 1 commit into
devfrom
test_977877681
Sep 22, 2026
Merged

copybara-service[bot] merged 1 commit into
devfrom
test_977877681

Conversation

@copybara-service

Copy link
Copy Markdown

Adds Intel AMX TMUL hardware acceleration for FlashAttention using BF16
matrix multiplication:

  • Implements TileFlashAttentionAMX_BF16_Impl on top of Highway's AMX-BF16
    wrappers (Tile64BLoad / Tile64BStore / Tile64BMatMul), so the compiler
    allocates tile registers and emits the tile configuration rather than this
    kernel hand-rolling _tile_* intrinsics and a packed AMXTileConfig.
  • Gates the kernel on hwy::HaveTile64BMatMulBF16(), which additionally
    validates XSAVE/OSXSAVE and XCR0 before requesting XFEATURE_XTILEDATA.
  • Integrates AttentionImpl::kFlashAMX into gemma_cpp tiled attention dispatch and model forward passes.
  • Adds comprehensive unit tests (flash_attention_test, tiled_attention_test) and benchmarks.

About x4 speedup on supported hardware

matrix multiplication:
- Implements `TileFlashAttentionAMX_BF16_Impl` on top of Highway's AMX-BF16
  wrappers (`Tile64BLoad` / `Tile64BStore` / `Tile64BMatMul`), so the compiler
  allocates tile registers and emits the tile configuration rather than this
  kernel hand-rolling `_tile_*` intrinsics and a packed `AMXTileConfig`.
- Gates the kernel on `hwy::HaveTile64BMatMulBF16()`, which additionally
  validates XSAVE/OSXSAVE and XCR0 before requesting `XFEATURE_XTILEDATA`.
- Integrates `AttentionImpl::kFlashAMX` into gemma_cpp tiled attention dispatch and model forward passes.
- Adds comprehensive unit tests (`flash_attention_test`, `tiled_attention_test`) and benchmarks.

About x4 speedup on supported hardware

PiperOrigin-RevId: 985969928
@copybara-service
copybara-service Bot merged commit 94280dd into dev Sep 22, 2026
6 checks passed
@copybara-service
copybara-service Bot deleted the test_977877681 branch September 22, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant