Skip to content

fix(metrics): preserve caller-owned detection predictions - #4702

Merged
cragwolfe merged 2 commits into
Unstructured-IO:mainfrom
Afloat16:Afloat16/detection-preserve-predictions-20261112
Nov 13, 2026
Merged

cragwolfe merged 2 commits into
Unstructured-IO:mainfrom
Afloat16:Afloat16/detection-preserve-predictions-20261112

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Detection matching clips predicted boxes in place. On CPU the processor can share the caller's tensor storage, so evaluating one document changes the model predictions supplied by the caller. Reusing the same prediction tensor for a larger page then evaluates previously clipped coordinates and can turn a perfect match into a miss.

Clip a local copy of the four box-coordinate columns and use that copy for matching. Scores, classes, caller-owned tensors and their backing storage are preserved. The clipping and matching calculations are otherwise unchanged.

Validation

  • Added 11 native detection-evaluation cases: the unchanged base has 6 failures and 5 passes; all 11 pass after the fix.
  • Covers float32/float64 predictions, contiguous and strided tensors, shared backing storage, out-of-bounds and in-bounds boxes, reuse across both page-size orders, unchanged targets, and pages without targets.
  • Hand-calculated perfect-match metrics verify that local clipping still affects matching correctly.
  • Ruff 0.15.10 check/format and git diff --check pass. The full optional-dependency suite and GPU execution were not run.

Checklist

  • Added regression tests for input preservation and repeated evaluation.
  • Preserved matching and score semantics.
  • Apply the bug label.

View guided diff

@cragwolfe cragwolfe 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.

Reviewed the full change and relevant evaluator paths with GPT Pro. The coordinate copy preserves caller-owned predictions while retaining clipping for matching. I found no actionable Critical, High, or Medium issue in the change.

This was a static review; CI results are separate. The changelog and lockfile were excluded from the review bundle, and release-policy comparison was checked separately.

(authored by codex)

@cragwolfe
cragwolfe enabled auto-merge November 13, 2026 03:21
@cragwolfe
cragwolfe added this pull request to the merge queue Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the main-branch update. On current head 7319c067, repository CI, CodeQL and Security have passed; 51 checks are successful, including the version guard.

The only failing check is Partition Benchmark. It exits during Install system dependencies: the Tesseract PPA has no Ubuntu 26.04 resolute Release file (404 / apt exit 100). No benchmark measurement ran. The benchmark on the exact current main c47ef65e fails at the same step with the same error.

The change has your approval and the functional/security checks are green. Could you complete the merge once this shared benchmark infrastructure failure is accounted for?

Merged via the queue into Unstructured-IO:main with commit ad56303 Nov 13, 2026
51 of 52 checks passed
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