Add more checks and add functional coverage for bifurcation_detector#28068
Add more checks and add functional coverage for bifurcation_detector#28068yuslepukhin merged 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR tightens input validation for BifurcationDetector by rejecting negative prev_suffix_match_idx, and significantly increases functional test coverage across bifurcation and suffix-matching scenarios.
Changes:
- Enforce
prev_suffix_match_idx >= 0in the CPU kernel. - Add broad functional tests for bifurcation detection and suffix matching (including attribute-driven paths).
- Add negative/boundary input tests for
prev_suffix_match_idxand “no pred tokens” scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| onnxruntime/contrib_ops/cpu/bert/bifurcation_detector.h | Adds a non-negative validation check for prev_suffix_match_idx. |
| onnxruntime/test/contrib_ops/bifurcation_detector_op_test.cc | Adds many new tests covering bifurcation positions, suffix-match cases, attributes, and invalid inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Review generated with assistance from GitHub Copilot CLI. Fix looks correct and complete for the targeted bug — the non-negative check on Tests are solid — math verified, good coverage of bifurcation logic, suffix matching, boundary cases, and invalid inputs. A couple of minor coverage nits: 1. Missing "full match" test — The case where all predicted tokens match source tokens ( 2. Missing Neither is blocking — the security fix and core regression tests are good to go. |
tianleiwu
left a comment
There was a problem hiding this comment.
Overall: Solid defensive-hardening PR. The non-negative validation for prev_suffix_match_idx closes a real out-of-bounds read, and the test coverage (13 new tests) is thorough — covering happy paths, error rejection, boundary conditions, and attribute variations. The diagnostic messages with actual parameter values are a nice touch.
One suggestion below about ORT_ENFORCE vs ORT_RETURN_IF_NOT for input validation in Compute().
|
/azp run Windows ARM64 QNN CI Pipeline |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This pull request strengthens input validation and significantly expands test coverage for the
BifurcationDetectoroperator. The main logic change enforces thatprev_suffix_match_idxmust be non-negative, preventing invalid input. The test suite is enhanced with a wide range of scenarios, including edge cases, error handling, and attribute-based behaviors.Input validation improvements:
prev_suffix_match_idxis non-negative in theBifurcationDetectorkernel, improving robustness against invalid input values.Test coverage enhancements:
prev_suffix_match_idx.prev_suffix_match_idxvalues are correctly rejected.prev_suffix_match_idxexceeding the source token length is rejected.prev_suffix_match_idxequals the source token length is handled.