Repository navigation
Preserve low-precision rounding in gated residual mixing - #212
Open
yuchenwang3 wants to merge 1 commit into
Open
yuchenwang3 wants to merge 1 commit into
yuchenwang3 wants to merge 1 commit into
Conversation
Signed-off-by: Yuchen Wang <93700456+yuchenwang3@users.noreply.github.com>
yuchenwang3
marked this pull request as ready for review
October 3, 2026 20:42
Contributor
Author
|
@hjh0119 Could you take a look at the gated-residual rounding fix? The GPU run passes all 16 tests, including BF16/FP16 helper checks and the TELinear unit. The description includes the timing cost of the eager path; does that tradeoff look reasonable? |
Collaborator
|
Do we have additional empirical evidence supporting the necessity of casting to bf16? |
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.
The compiled gated-residual helpers can fuse away the low-precision rounding after division, sigmoid, and multiplication. Their outputs and gradients can then differ from the same gate chain evaluated as separate BF16/FP16 operations.
This keeps those operation boundaries for BF16/FP16 and retains the compiled helpers for FP32. The eager regions are also excluded from an outer
torch.compile. Projections, weights, and the gate formulas are unchanged. The existing GR unit tolerates compilation drift; this makes the low-precision helpers agree with its eager reference exactly, at the cost of fusion in that path.Validation:
_mix_and_reducereproduces the difference: with 17 rows, four streams, and width 64, BF16 output/input-gradient maximum absolute differences from eager are 0.00390625/0.00244140625. FP16 differs too. These are helper results, not full-model error bounds.pre-commit run --all-filespassed.Implementation and tests were generated with OpenAI Codex.