Skip to content

[Pallas] xsa TPU sweep: use bfloat16 (was float16, hit Mosaic vector-type bug) - #3204

Merged
norx1991 merged 1 commit into
mainfrom
yifeixu/xsa-bench-bf16
Jul 31, 2026
Merged

[Pallas] xsa TPU sweep: use bfloat16 (was float16, hit Mosaic vector-type bug)#3204
norx1991 merged 1 commit into
mainfrom
yifeixu/xsa-bench-bf16

Conversation

@norx1991

Copy link
Copy Markdown
Contributor

Summary

Change the xsa TPU sweep from float16 to bfloat16. Both xsa rows FAILed in the 2026-07-28 full sweep with:

mosaic failed to compile TPU kernel: Invalid vector type for load
%424 = "tpu.load"(...) : (memref<1x1024x256xf16, ...>) -> vector<8x128x2xf16>

fp16 at head_dim=256 forces the vector<8x128x2xf16> layout (2 elements per lane), which trips a Mosaic codegen path. bfloat16 avoids that layout and compiles fine. It's also the dtype test_examples.test_xsa uses on TPU (HALF_DTYPE resolves to bf16 there) and matches every other bf16-attention row in benchmarks/run_tpu.py.

Verified on TPU v7 with full autotune + --subprocess-per-shape:

Shape Helion (ms) Torch (ms) Helion vs eager vs torch.compile
[2,32,1024,256] 0.620 1.60 2.59× 1.74×
[4,32,2048,256] 1.603 8.73 5.45× 2.52×

…type bug)

The float16 shapes hit TPU Mosaic's "Invalid vector type for load" codegen
error (the vector<8x128x2xf16> layout fp16 forces on head_dim=256), FAILing
both xsa rows in the 07-28 sweep. bfloat16 sidesteps this, matches every
other bf16-attention row in benchmarks/run_tpu.py, and is what
test_examples.test_xsa uses (HALF_DTYPE resolves to bf16 on TPU).

Verified on TPU v7 with full autotune + subprocess-per-shape:
  [2,32,1024,256]: Helion 0.62 ms → 2.59x vs eager, 1.74x vs torch.compile
  [4,32,2048,256]: Helion 1.60 ms → 5.45x vs eager, 2.52x vs torch.compile
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 29, 2026
@norx1991
norx1991 marked this pull request as ready for review July 29, 2026 21:40
@norx1991
norx1991 requested review from AmesingFlank and ethche July 30, 2026 21:01
@norx1991
norx1991 merged commit 938b909 into main Jul 31, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants