Repository navigation
Flag invalid ref_space_uid conversion in atom cross-attention - #740
Open
BangBang-afk wants to merge 2 commits into
Open
BangBang-afk wants to merge 2 commits into
BangBang-afk wants to merge 2 commits into
Conversation
keys_ref_space_uid was gathered from batch.ref_structure.ref_space_uid (token layout) via queries_to_keys, whose gather indices index the queries flat space. This mismatches input_shape and masks out almost all positions. Convert from queries_ref_space_uid instead, matching the pattern used for keys_ref_pos and other keys_* conversions. Fixes google-deepmind#730.
|
Given that the model was trained on the conversion as it was I think it might be problematic to just change the code. Without retraining, the change might deteriorate model performance. Maybe it would be a better idea to just flag the invalid conversion in the code? |
Per review: the model was trained with the token-layout source for keys_ref_space_uid, so changing the gather source would shift inference-time activations away from the training distribution. Keep behavior identical and document the known issue (see google-deepmind#730) in code instead.
Author
|
Agreed -- good catch. The mask feeds straight into pair_act, so flipping it would shift activations away from what the weights saw in training. I reverted the behavior change; the PR now only adds a NOTE(#730) comment at the conversion site documenting the mismatch and why it is intentionally left as-is. Diff is comment-only (+9/-1), outputs bit-identical by construction. |
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
Flags a known-invalid layout conversion in the atom cross-attention encoder (see #730) without changing behavior.
keys_ref_space_uidis converted frombatch.ref_structure.ref_space_uid(token layout, shape(num_tokens, num_dense)) usingbatch.atom_cross_att.queries_to_keys, whosegather_idxsindex the queries flat space(num_subsets, num_queries). The gathered values — and henceoffsets_valid— are therefore not meaningful (in practice almost allFalse).The two-step
token -> queries -> keysconversion used forkeys_ref_posjust above would be the correct pattern, but it is deliberately not applied here: the model was trained with this conversion, and changing it without retraining could deteriorate performance (per review discussion). The code now documents this with aNOTE(#730)comment at the conversion site so the next reader doesn't fix it blindly.Verification (no behavior change)
+9/-1, zero functional change, so inference outputs are bit-identical by construction.Batch.ref_structure.ref_space_uidshape(num_tokens, num_dense)(features.py:1685,1709).AtomCrossAtt.queries_to_keys.input_shapeis(num_subsets, num_queries); neighboringkeys_mask/keys_single_cond/pair_cond_keys_inputall gather fromqueries_*sources — this call is the sole inconsistency (confirmed by grep).atom_layout.convertvalidateslayout_shape[1:] == input_shape[1:](atom_layout.py:955-961).atom_cross_attentiontest in repo); nothing to regress since behavior is unchanged.Related to #730.
AI disclosure
Analysis assisted by AI and manually verified against
atom_layout.convertand neighboring conversions.