Skip to content

M5: opt-in full-fp32 P x V for Nemotron's prompt attention (part of #1772) - #1882

Merged
ashhart merged 4 commits into
mainfrom
lead/attn-pv-fp32
Nov 2, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/attn-pv-fp32

Conversation

@ashhart

@ashhart ashhart commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Part of #1772.

TF_ATTENTION_PV_FP32=1 (off by default) keeps Nemotron's Metal prompt attention's P x V at full fp32 on the M5, instead of the tensor units' 10-mantissa-bit cut. Unset, every buffer, launch and output is unchanged.

On an M5 Ultra against a binary64 reference, output cells off the nearest bf16 value fall from 1,141,167 to 1,800 (of 8.6M) on ordinary inputs, and from 517,840 to 277 with P spread over [0, 1]. It's an FMA path, so prompts are 30% to 87% slower at 2K to 32K (MLX 4-bit). That's why it stays opt-in; a tensor-unit version follows. The kernel contract registers it with its own bound and controls. An independent review found the unset path byte-identical and #1748's operand-cut terms kept.

Keep the relaxed tensor product by default. Use FP32 FMA products under TF_ATTENTION_PV_FP32=1, separate prompt-state identities, and register both modes with the actual cut path as a precision control. Fixes #1772.
Build shared, paged and image attention libraries through the production source selector, and report which P x V mode each measured library uses. Refs #1772.
Preserve the measured one-sided operand cut for the default Nemotron prompt range. In full mode count its FMA chain and explicitly compile the cut product as the negative control. Keep masked-key findings separate in both modes.

Part of #1772.
@ashhart
ashhart merged commit 11998d8 into main Nov 2, 2026
13 checks passed
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