Fix for subfn, rope issue in Grok1 - #1236
Open
tv-karthikeya wants to merge 2 commits into
Open
Conversation
tv-karthikeya
marked this pull request as draft
August 4, 2026 08:08
Signed-off-by: vtirumal <vtirumal@qti.qualcomm.com>
tv-karthikeya
marked this pull request as ready for review
August 5, 2026 06:33
Contributor
Author
|
CI-Ready |
ochougul
reviewed
Aug 5, 2026
Comment on lines
+97
to
+98
| cos = cos[position_ids].unsqueeze(1) | ||
| sin = sin[position_ids].unsqueeze(1) |
Contributor
There was a problem hiding this comment.
this logic should go insdie the qeff_apply_rotary_pos_emb method I think. Why are we needing explicit unsqueeze here only?
ochougul
requested changes
Aug 5, 2026
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.
This PR fixes Grok1 export/runtime support by addressing two issues:
RoPE Compatibility Fix
Grok1 was still calling the shared RoPE helper with position_ids:
qeff_apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)The shared helper imported from the Llama wrapper now expects already-indexed RoPE tensors:
qeff_apply_rotary_pos_emb(q, k, cos, sin)This caused Grok1 QEff execution/export to fail with:
TypeError: qeff_apply_rotary_pos_emb() takes 4 positional arguments but 5 were given
The fix applies Grok1’s position_ids indexing locally before calling the shared helper:
This preserves Grok1’s original RoPE semantics and produces the broadcast shape expected by attention: [batch, 1, seq_len, head_dim].
Subfunction Export Support
Grok1 now declares its repeated decoder block as the ONNX subfunction boundary:
Grok1 support is implemented through external module mapping, so the original HF decoder layer is transformed by replacing its forward/init behavior rather than by instantiating a standalone QEff...DecoderLayer class everywhere in the model tree. Because of that, the subfunction exporter cannot rely on discovering a generic QEffDecoderLayer instance name from the original model structure.
updated :