Skip to content

[Pallas] Run kl_div at fp32 on the TPU bridge to match run_tpu.py - #3208

Open
norx1991 wants to merge 1 commit into
mainfrom
yifeixu/tpu-bridge-kl-div-fp32
Open

[Pallas] Run kl_div at fp32 on the TPU bridge to match run_tpu.py#3208
norx1991 wants to merge 1 commit into
mainfrom
yifeixu/tpu-bridge-kl-div-fp32

Conversation

@norx1991

Copy link
Copy Markdown
Contributor

The TPU bridge forced --precision bf16 for every bridged kernel, but run_tpu.py (and GPU) run kl_div at fp32 — its loss reduction stays fp32. Forcing bf16 made the bridge diverge from run_tpu for kl_div and produced an fp32-impl vs bf16-baseline accuracy mismatch (torch.testing.assert_close fails on dtype), so kl_div reported a spurious accuracy failure on the bridge.

Set --precision per kernel: fp32 for kl_div, bf16 for the rest (TPU-native and matching run_tpu.py). This fixes kl_div accuracy at the source and keeps its dashboard number consistent with both run_tpu.py and GPU — no change to the accuracy comparison needed.

The bridge forced --precision bf16 for every bridged kernel, but run_tpu.py
(and GPU) run kl_div at fp32 — its loss reduction stays fp32. Forcing bf16 made
the bridge diverge from run_tpu for kl_div and produced an fp32-impl vs
bf16-baseline accuracy mismatch (torch.testing.assert_close fails on dtype).

Set precision per kernel: fp32 for kl_div, bf16 for the rest (TPU-native, and
matching run_tpu.py). Fixes kl_div accuracy on the bridge at the source, with
no change to the accuracy comparison.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 30, 2026
@norx1991
norx1991 requested review from AmesingFlank and ethche July 30, 2026 21:40
@norx1991
norx1991 marked this pull request as ready for review July 30, 2026 21:41
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.

1 participant