fix(cutedsl): preserve FP32 CE output precision - #1372
Open
justinhh4 wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
justinhh4
marked this pull request as ready for review
August 11, 2026 19:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
With
nvidia-cutlass-dsl==4.6.0, FP32HAS_GRADspecializations that enable z-loss, softcap, or label smoothing store the public loss outputs at bf16 precision even though the CE math and gradients remain FP32-accurate. For example, the z-loss test produced8.7725instead of the Triton/PyTorch result8.8014; per-token values landed exactly on bf16 quantization points.Rebuilding the loss and z-loss views with explicit
Float32pointers keeps those stores FP32. FP16/BF16 paths retain their existing typed stores. This does not add launches, buffers, or API changes, and FLCE is unchanged.Validation
python -m pytest --confcutdir=test/cutedsl test/cutedsl/test_cross_entropy.py -q— 158 passed, 1 environment-gated skipLIGER_KERNEL_IMPL=cutedsl python -m pytest --confcutdir=test/cutedsl test/cutedsl/test_cross_entropy.py::test_liger_kernel_impl_cutedsl_selects_cutedsl_ce -q— 1 passedruff check src/liger_kernel/ops/cutedsl/ops/cross_entropy.pyruff format --check src/liger_kernel/ops/cutedsl/ops/cross_entropy.py