Repository navigation
[Fix][Relax] Preserve attention semantics in ToMixedPrecision - #21071
Open
charan-rathore wants to merge 2 commits into
Open
charan-rathore wants to merge 2 commits into
charan-rathore wants to merge 2 commits into
Conversation
Retain the attention operator, arguments and semantic attributes while the mixed-precision rewriter handles dtype conversion. Developed with AI assistance.
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.
Fixes #21067.
The shared mixed-precision callback rebuilt every attention call as a plain three-input attention operation with default attributes. This dropped scale, causal_mask and window_size, changed attention_bias into plain attention while discarding its bias, and changed attention_var_len into plain attention while discarding sequence metadata.
Return the existing call instead. The mixed-precision rewriter already remaps and casts floating-point inputs, preserves integer inputs, and clears the inferred type before normalization. Attention has no separate accumulator or output dtype attribute to rewrite.
Add structural regression cases for plain, biased and variable-length attention, default and non-default attributes, and both ToMixedPrecision output dtype settings. The expected modules retain all operands and attributes while casting floating-point inputs to float16 and restoring the function output to float32. Integer sequence metadata remains int32.
Testing on current main 1091f2f with a native CPU build and supported apache-tvm-tirx 0.1.0:
These are structural compiler regression tests, not numerical attention execution or a performance benchmark.
This change was developed with AI assistance.