Skip to content

chore: remove SAM2_DUMP_DIR dumps and dbg_ tensor markers - #22

Merged
PABannier merged 1 commit into
mainfrom
cleanup/remove-debug-dumps
Sep 16, 2026
Merged

PABannier merged 1 commit into
mainfrom
cleanup/remove-debug-dumps

Conversation

@PABannier

Copy link
Copy Markdown
Owner

What

Removes debug-session leftovers from production code paths in sam3.cpp:

  • SAM2_DUMP_DIR dumps in the Hiera PE precompute (bkg_interp / win_tiled) and in sam3_segment_pvs (sparse embeddings, image feats, decoder outputs and intermediates).
  • dbg_* tensor names and their ggml_set_output markers: Hiera patch embed / after-PE / blocks 0,1,2,5,21 / FPN laterals, the two-way block internals, and the decoder's dbg_dec_{queries,keys}_out.
  • The block-0 dump flag in sam2_hiera_block_forward and the block_idx parameter it used (nothing else read it).
  • The static _sa_call_count / _sa_merge_count counters in sam3_sam_attention. Besides being debug-only, they were hidden global state.
  • ggml_set_output on sam_dec_tokens_initial and sam_dec_block%d_{queries,keys}. Those names are kept because the test API still looks them up with ggml_get_tensor and sets its own outputs.

Why

These blocks only existed to compare against Python during debugging. The extra ggml_set_output markers also stopped the graph allocator from reusing those intermediate buffers.

Verification

Parity tool, byte-compared against deterministic origin/main baselines. It covers encode_image, segment_pvs with point and box prompts, and the visual tracker's add_instance + propagate_frame.

PARITY OK   edgetam_f16 gpu0
PARITY OK   edgetam_f16 gpu1
PARITY OK   sam2.1_hiera_tiny_q8_0 gpu0
PARITY OK   sam2.1_hiera_tiny_q8_0 gpu1

Full Release build: no errors. The only warnings come from ggml and stb, and they are already on main.

 1 file changed, 2 insertions(+), 155 deletions(-)

Caveats

  • No full SAM3 model was available locally, so the text/PCS path is only verified to compile. None of the removed code is on that path.
  • Out of scope on purpose (sibling PRs handle these): the test/debug API regions, including their own SAM2_DUMP_DIR blocks and lists of dbg_* names; the EdgeTAM profiler; and the #if 0 manual SDPA block. The Hiera dump in the test API skips missing tensors, so it still runs; it just finds nothing to dump.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M2qLmQ9ag49hT61V6i9qAq

Drop debug-session leftovers from production code paths:
- SAM2_DUMP_DIR file dumps in the Hiera PE precompute and sam3_segment_pvs
- dbg_* tensor names and their ggml_set_output markers (Hiera patch
  embed / blocks / FPN laterals, two-way block internals, decoder outputs)
- the block-0 dump flag (and now-unused block_idx param) in
  sam2_hiera_block_forward
- the static _sa_call_count/_sa_merge_count counters in sam3_sam_attention

sam_dec_tokens_initial / sam_dec_block%d_{queries,keys} keep their names
(the test API looks them up) but lose the ggml_set_output markers.
Numerics are unchanged (byte-identical parity on CPU and Metal).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M2qLmQ9ag49hT61V6i9qAq
@PABannier
PABannier merged commit 5ff23cf into main Sep 16, 2026
3 checks passed
@PABannier
PABannier deleted the cleanup/remove-debug-dumps branch September 16, 2026 18:53
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.

1 participant