Validate QEmbed segment inputs - #32144
Open
Akshay Sonawane (apsonawane) wants to merge 2 commits into
Open
Conversation
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
August 18, 2026 00:41
Copilot started reviewing on behalf of
Akshay Sonawane (apsonawane)
August 18, 2026 00:43
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds all-or-none validation for quantized segment embedding inputs.
Changes:
- Rejects partial segment input configurations.
- Adds exhaustive tests for all partial combinations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
onnxruntime/contrib_ops/cpu/quantization/qembed_layer_norm.cc |
Validates segment inputs as a group. |
onnxruntime/test/contrib_ops/qembed_layer_norm_op_test.cc |
Tests partial segment input rejection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+203
to
+208
| const bool has_segment_embedding = segment_ids_tensor != nullptr; | ||
| ORT_RETURN_IF(has_segment_embedding != (segment_embedding_tensor != nullptr) || | ||
| has_segment_embedding != (segment_embedding_scale_tensor != nullptr) || | ||
| has_segment_embedding != (segment_embedding_zero_point_tensor != nullptr), | ||
| "segment_ids, segment_embedding, segment_embedding_scale, and segment_embedding_zero_point " | ||
| "must either all be provided or all be omitted"); |
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 pull request enhances the validation logic for segment embedding inputs in the quantized
QEmbedLayerNormoperator and significantly improves test coverage to ensure robustness against partial or inconsistent segment embedding input scenarios.Validation Logic Improvements:
segment_ids,segment_embedding,segment_embedding_scale,segment_embedding_zero_point) must be provided together or all omitted, preventing invalid partial configurations. [1] [2]Test Suite Enhancements:
RunTest) to allow fine-grained control over which segment embedding inputs are present, using a bitmask for flexible test scenarios.PartialSegmentInputsRejected, which systematically verifies that any partial provision of segment embedding inputs is correctly rejected by the operator, aligning with the new validation logic.