Zhen Ye Claude Opus 4.6 commited on
Commit
64f68de
Β·
1 Parent(s): fc9835a

perf: eliminate CUDA sync points in SAM2 video propagation hot-path

Browse files

Replace per-object-per-frame torch.nonzero + .item() calls (7 CUDA
syncs each) with batched GPU-native argmax reductions (2 syncs per
segment). Move deepcopy from per-frame to once per segment on last
frame only. Reduces total CUDA sync points from ~28,700 to ~82 per
pipeline run.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

1 file changed +120 -36
models/segmenters/grounded_sam2.py+120-36