Repository navigation
Conversation
This branch has not been deployed
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.
Problem
StableEmbedding casts its embedding output to the current global default dtype before calling LayerNorm. After a normal
model.half(),model.bfloat16()ormodel.double(), the normalization parameters have a different dtype and forward fails with a mixed-dtype error. Changing the global default dtype after constructing the layer can also break an otherwise unchanged model.Change
Cast to the normalization parameters' actual dtype, then retain the existing conversion back to the embedding weight dtype. A normalization layer created in full precision stays in full precision unless the caller explicitly converts it. Its normal Module call and hooks are preserved.
Reproducer
On unchanged main this fails in LayerNorm with
RuntimeError: mixed dtype (CPU). The patch completes forward and backward.Validation
Base:
a616886cacf86701514f0cb1d6be760f967481c0; exact patch:df9928c5f5547da1a41148903fd62e09ab8e3c91.tests/test_modules.pyon CPU: 102 passed, 2 skipped.to(dtype)and convenience conversion methods.git diff --check, pass.GPU/distributed execution and the complete repository suite were not run. No model-quality or throughput improvement is claimed.
Checked all-state StableEmbedding/dtype/half/norm issues and PRs, the complete 132-entry module history, the latest PR catalog and current fork branches. The actual #87 patch introduces constructor dtype/device support and the global-default cast; it does not address subsequent module conversions or changes to the global default.