Skip to content

Honor e4m3_dtype/e5m2_dtype in Fp8DirectDotGeneralOp and Fp8Einsum - #5653

Open
vineethsaivs wants to merge 1 commit into
google:mainfrom
vineethsaivs:fix/fp8-direct-honor-fp8-dtypes
Open

vineethsaivs wants to merge 1 commit into
google:mainfrom
vineethsaivs:fix/fp8-direct-honor-fp8-dtypes

Conversation

@vineethsaivs

Copy link
Copy Markdown

What does this PR do?

Fp8DirectDotGeneralOp (nn.Fp8DotGeneral) and Fp8Einsum accept e4m3_dtype and e5m2_dtype from Fp8DotGeneralBase but ignore them. fp8_scaled_dot_general hardcodes float8_e4m3fn for the inputs, and the quantized_dot backward hardcodes float8_e5m2 for the output grad. So a NANOO config (e4m3fnuz/e5m2fnuz) runs with the OCP formats and nothing raises. Only the deprecated Fp8DotGeneralOp reads the fields.

This threads both dtypes through fp8_scaled_dot_general and quantized_dot. The defaults keep existing callers unchanged.

The new test test_fp8_direct_ops_honor_fp8_dtypes covers both ops. On main the new input and kernel scales are 4/448 = 0.00892857 instead of 4/240 = 0.01666667, and dx is 0 instead of 3 * 2**-17. All 13 Fp8 tests pass with the fix.

Fixes # (none)

Checklist

  • This PR fixes a minor issue (e.g.: typo or small bug) or improves the docs (you can dismiss the other checks if that's the case).
  • This change is discussed in a Github issue/discussion (please add a link).
  • The documentation and docstrings adhere to the documentation guidelines.
  • This change includes necessary high-coverage tests. (No quality testing = no merge!)

Both ops inherit e4m3_dtype and e5m2_dtype from Fp8DotGeneralBase, but
fp8_scaled_dot_general hardcoded float8_e4m3fn for the inputs and
quantized_dot's backward hardcoded float8_e5m2 for the output grad. A
NANOO config (e4m3fnuz/e5m2fnuz) was accepted and silently ran with the
OCP formats.

Thread both dtypes through fp8_scaled_dot_general and quantized_dot,
with defaults that keep existing callers unchanged.

This branch has not been deployed

No deployments
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