Repository navigation
perf(kf): avoid bbox decoding during scale-aware noise refresh - #572
Merged
Borda merged 2 commits intoAug 20, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes scale-aware noise refresh while preserving bit-exact bounding-box arithmetic.
Changes:
- Adds allocation-free width/height fast paths for BoT-SORT and McByte.
- Adds regression coverage for exact arithmetic and estimator fallbacks.
- Documents the optimization in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/trackers/core/botsort/tracklet.py |
Adds the BoT-SORT fast path. |
src/trackers/core/mcbyte/tracklet.py |
Adds the McByte fast path. |
tests/core/test_botsort_tracklet.py |
Tests bit equivalence and fallback behavior. |
CHANGELOG.md |
Records the performance improvement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Changes: - Restrict BoT-SORT and McByte allocation-free width/height reconstruction to exact XCYCWH float64 state, falling back to decoder arithmetic for other dtypes and subclasses. - Add restored-float32, non-positive clamp, and fallback-output regression coverage for both tracklets; clarify the helper docstrings. Impact: - Restored non-float64 Kalman states retain the prior float64 decoder behavior and bit-equivalence contract. - The optimized float64 path remains allocation-free while tests protect clamp and estimator-dispatch behavior. Verification: - uv run pytest -m "not integration" — 1528 passed, 5 skipped, 14 deselected, 1108 warnings. - pre-commit run --all-files — passed. - git diff --check — passed. - Remediation artifact validation — passed. Residual limits: - Specialist provenance, codemap availability, PR benchmark claims, and non-finite state contract remain explicitly unresolved or deferred in the remediation artifact. --- Co-authored-by: Codex <[email protected]>
Borda
approved these changes
Aug 20, 2026
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.
BoTSORTTracklet._current_wh()andMcByteTracklet._current_wh()decode a full XYXY box during each scale-aware process/measurement-noise refresh, and then only use its width and height.The default estimator already stores
[x_center, y_center, width, height], so reading width and height straight from that looks like the simpler path. It isn't bit-equivalent though: the existing decoder builds both corners first, and with large centers that changes the rounded subtraction result. I checked this on 27,033 Kalman states captured from a DanceTrack replay, and direct reads changed bits in 25,943 of those calls.So the fix adds a fast path for the default estimator that reconstructs the same two corner pairs and keeps the original operation order, without allocating the XYXY array. The XYXY and XCYCSR estimators keep the existing decoder as a fallback, and C-BIoU also uses the BoT-SORT tracklet, so it goes through the same path.
Regression tests cover BoT-SORT and McByte, check the uint64 output bits, confirm the fast path does not call
state_to_bbox(), and check that the other two state representations — plus a subclass of the default estimator — still go through their decoder. The fast path is scoped to the exactXCYCWHStateEstimatorclass, notisinstance, so a subclass override isn't bypassed. The changelog records the optimisation.Validation:
_current_wh()method: 1,555.33 ns/call median[1,544.67, 1,573.07]to 545.43[528.89, 562.81], -64.93%. The measured ranges are disjoint.[8,299.91, 8,924.06]to 8,202.17[7,808.38, 8,326.87](-3.78%); McByte 10,149.26[10,116.37, 10,370.00]to 9,670.04[9,593.48, 10,400.23](-4.72%). Six of seven pairs were faster for each tracker. Paired deltas were[-12.46%, +0.32%]for BoT-SORT and[-6.88%, +2.47%]for McByte, so process variance is visible and the exact percentages depend on the machine and workload.pytest -m "not integration": 1,557 passed, 3 skipped, 14 deselected. Seventeen repository pre-commit hooks pass; one shebang hook skips because no matching file is present.