Repository navigation
feat(vrt-xfeat): device-side keypoint count and pixel keypoints - #31
Conversation
Each XFeatResult now publishes, on the device and in stream order: - count_device(): the keypoint count clamped to capacity. A consumer on the same stream reads it without a host sync, e.g. kornia-3d's stereo matcher through KeypointCount::Device, so extraction -> stereo matching needs no sync in between. count() remains the host copy. - kpts_px(): keypoints in original-image pixels. `kpts` is model space (floor-32), which is off by up to 2% when a side is not a multiple of 32 (EuRoC 752 -> 736: 16 px at the right edge), wrong for matching against the rectified frames. Both are written by the existing xfeat_sample_descs launch (block 0 writes the clamped count; lane 0 writes x*sx, y*sy, the same single multiply kpts_to_host does on the host, so the two are bit-identical). No extra launches or copies. The scale is now stamped on the result before the post-processing launch. Tests: gpu_device_count_and_pixel_kpts (raw count 3 > capacity 2, clamped; mutation-checked: an unclamped write fails it), per-slot device count in the batch-2 test, and gpu_pair checks both on the real model at 1280x720 (720 -> 704 rows, y scale != 1). xfeat_stereo pair p50 5.43 ms vs 6.12 ms for 2x submit: unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughXFeat results now expose a device-side keypoint count and keypoints in original-image pixel coordinates. Batch post-processing sets each result’s scale before it writes these outputs. GPU tests check the device outputs against host results. ChangesXFeat device outputs
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant submit_batch
participant launch_topk_batch
participant xfeat_sample_descs
participant XFeatResult
submit_batch->>XFeatResult: Set result scale
submit_batch->>launch_topk_batch: Launch top-K post-processing
launch_topk_batch->>xfeat_sample_descs: Pass count buffers, pixel buffers, and scale
xfeat_sample_descs->>XFeatResult: Write clamped count and scaled keypoints
Merge Risk: ⚪ Minimal · up to The new device-side outputs appear ready to merge after normal checks; no actionable risk remains in the supplied evidence. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new outputs are capacity-bounded and use the existing GPU processing context. No introduced security attack path was established. Correct use still depends on stream ordering and successful submission; downstream integration and recovery behavior were not available for review. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Follow-up to #30. Lets a GPU consumer on the same stream use XFeat results without a host sync. The target is kornia-3d's stereo matcher (kornia/kornia-rs#1157), so extraction → stereo matching runs with no sync in between.
API (
XFeatResult)count_device()returns the keypoint count on the device, clamped to capacity, valid in stream order aftersubmit/submit_pair. It plugs straight into kornia-3d:KeypointCount::Device { count: res.count_device(), capacity: res.capacity() }.count()stays the host copy and is valid only after a sync.kpts_px()returns device keypoints in original-image pixels. The existingkptsare in model space (floor-32). That space is off by up to 2% when a side is not a multiple of 32: at EuRoC's 752 px width the model is 736 px, so the error reaches 16 px at the right edge, which is wrong for matching against the rectified frames.How
Both values are written by the existing
xfeat_sample_descslaunch, so there are no extra launches or copies:x*sx, y*sy. That is the same single multiplykpts_to_hostdoes on the host, so the two are bit-identical.The scale is now stamped on the result before the post-processing launch.
Testing (Orin Nano, JetPack 6, TRT 10.3)
gpu_device_count_and_pixel_kpts: raw atomic count 3 > capacity 2 is clamped to 2, andkpts_pxis bit-identical tokpts_to_host. Mutation-checked: writing the unclamped count fails it.gpu_batch2_routes_each_image_to_its_slot: each slot publishes its own device count.gpu_pairon the real model at 1280×720 (720 → 704 rows, y scale ≠ 1): device count ==count(),kpts_pxbit-identical to the host keypoints, for both single and pair results.xfeat_stereo640×480: pair p50 5.43 ms vs 6.12 ms for 2×submit(1.13×, unchanged).gpu_match_kernel_only_timingfails identically onmain(cudarc wantscuEventElapsedTime_v2, which this driver lacks).🤖 Generated with Claude Code
Summary by CodeRabbit