Repository navigation
Conversation
TfqInnerProductGradOp indexed maps[0] and downstream_grads[0] while validating input shapes, and ComputeSmall indexed other_fused_circuits[0]. All three vectors are empty when `programs` has batch size 0, so the op read out of bounds (a crash in practice, and an assertion failure under _GLIBCXX_ASSERTIONS). Skip the symbol-map size check when there are no maps, compare the downstream_grads width using the tensor shape so that mismatches are still rejected for empty batches, and return the zeroed output early when there are no programs or no other_programs.
mhucka
marked this pull request as ready for review
November 20, 2026 05:18
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 is a fix for b/510434594, "Out-of-Bounds Vector Access on Empty Batch Inputs".
TfqInnerProductGradOpindexedmaps[0]anddownstream_grads[0]while validating input shapes, andComputeSmallindexedother_fused_circuits[0]. All three vectors are empty whenprogramshas batch size 0, so the op was reading out of bounds (a crash in practice, and an assertion failure under_GLIBCXX_ASSERTIONS).This PR makes a number of changes to
tfq_inner_product_grad.ccto do more checks. In addition, this expands the test cases to cover more situations.