Skip to content

Validate QEmbed segment inputs - #32144

Open
Akshay Sonawane (apsonawane) wants to merge 2 commits into
mainfrom
fix/qembed-optional-segment-inputs
Open

Validate QEmbed segment inputs#32144
Akshay Sonawane (apsonawane) wants to merge 2 commits into
mainfrom
fix/qembed-optional-segment-inputs

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

This pull request enhances the validation logic for segment embedding inputs in the quantized QEmbedLayerNorm operator and significantly improves test coverage to ensure robustness against partial or inconsistent segment embedding input scenarios.

Validation Logic Improvements:

  • Enforces that all segment embedding-related inputs (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:

  • Refactors the test harness (RunTest) to allow fine-grained control over which segment embedding inputs are present, using a bitmask for flexible test scenarios.
  • Updates test input logic to conditionally add each segment embedding input based on the bitmask, enabling the simulation of all possible partial input combinations. [1] [2] [3] [4]
  • Adds a new test, PartialSegmentInputsRejected, which systematically verifies that any partial provision of segment embedding inputs is correctly rejected by the operator, aligning with the new validation logic.
  • Modifies the test execution to expect failures with a clear error message when partial segment embedding inputs are provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants