perf(eval): reuse contiguous prepared IDs - #579
Open
JESUSROYETH wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes evaluator ID remapping by directly reusing contiguous zero-based integer IDs while preserving searchsorted for arbitrary public inputs.
Changes:
- Adds contiguous-ID fast paths to CLEAR, HOTA, and Identity metrics.
- Retains fallback behavior for sparse, nonzero-based, or non-integer IDs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/trackers/eval/clear.py |
Reuses contiguous ground-truth IDs directly. |
src/trackers/eval/hota.py |
Reuses contiguous IDs across both HOTA passes. |
src/trackers/eval/identity.py |
Reuses contiguous IDs during global association. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
The MOT evaluator already remaps IDs to zero-based integers in
_prepare_mot_sequence. The metric functions then rebuild the mapping withnp.searchsortedin each frame: CLEAR, HOTA, and Identity.This patch checks each sorted unique-ID range once. If it has integer dtype, starts at zero and ends at
count - 1, the per-frame IDs are already the array indices, so the code can skip straight to them. Otherwise it falls back to the currentsearchsortedpath. This matters for public calls with arbitrary IDs, and also for prepared data where distractor removal can leave holes — three of the seven MOT17 tracker ranges hit that fallback in my tests.Validation
I compared develop against itself first, then against this patch, using exact dtype/shape/byte checks rather than tolerances.
int16/32/64,uint16/32/64,float32/64, contiguous and non-contiguous values, empty sides, and strided views: identical aggregate digest.pytest -m 'not integration': 1,564 passed, 3 skipped, 14 deselected.Performance
CPU-only on an i9-13900HX, Python 3.12.3 and NumPy 1.26.4. Inputs are loaded before kernel timing, order alternates, and garbage collection runs before each sample.
I also relabelled the real-shaped MOT17 inputs to non-contiguous IDs to time the fallback. CLEAR, HOTA and Identity moved by +0.24%, +0.30% and -0.33% — the three baseline/candidate ranges overlap, and the observed fallback cost is at most 0.30% of kernel time.
Zero-based preparation arrived in #214. #462 optimised HOTA's generic ID remapping, and #574 later carried that approach into Identity. Both kept the general path correct for arbitrary public inputs. This patch keeps that same behaviour and adds the prepared fast path only when the precondition is present.