Skip to content

Fea distributed embedding dumping - #1

Merged
z52527 merged 0 commit into
z52527:fea-distributed-embedding-dumpingfrom
shijieliu:fea-distributed-embedding-dumping
Aug 26, 2025
Merged

z52527 merged 0 commit into
z52527:fea-distributed-embedding-dumpingfrom
shijieliu:fea-distributed-embedding-dumping

Conversation

@shijieliu

Copy link
Copy Markdown

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@z52527
z52527 merged commit 54d416d into z52527:fea-distributed-embedding-dumping Aug 26, 2025
@z52527
z52527 force-pushed the fea-distributed-embedding-dumping branch from e44c25b to 54d416d Compare August 26, 2025 02:24
z52527 added a commit that referenced this pull request May 11, 2026
Addresses the second-pass follow-up findings in
examples/sid_gr/docs/beam_decode_branch_audit_for_cc.md (the section
written against 59ecff5).

Changes
=======

P2 #1 — Validator now checks all three pairs symmetrically
(benchmark_beam_decode.py)
* `_validate_compare_outputs` previously checked top-K overlap only for
  A vs B, while top-1 / log-prob delta were checked across all pairs.
  That meant C(jagged) lower-rank beams could drift past 70% overlap
  without the validator noticing as long as the top-1 SID and lp delta
  stayed close. Now top-K overlap is computed for A vs B, B vs C, and
  A vs C.
* The summary string now includes the three lp deltas and the three
  worst-case overlap percentages even on PASS, so a passing config
  reports the actual numbers instead of just a green tag.

P2 #2 — `--compare_kv_modes` raises by default on validation failure
(benchmark_beam_decode.py)
* Previously `run_compare_kv_modes()` printed validation failures at
  the bottom of the output and exited normally. Since RESULTS.md
  documents this command as the ground-truth reproduction, a
  copy-pasted timing table could absorb broken numbers without the
  reader noticing the validation block.
* Default behavior now: raise RuntimeError after the table if any
  config failed (non-zero exit, CI-friendly).
* New `--allow_validation_fail` flag opts back into the diagnostic
  behavior for sweeps where you want to see timings of a path that's
  known to drift.
* Docstring on `run_compare_kv_modes` documents the contract.

P3 — RESULTS.md prose label synced with the code
(benchmark/RESULTS.md)
* The benchmark CLI now prints `B_ms / C_ms` but RESULTS.md still
  said `C/B median = 0.951x` from the previous label scheme. Updated
  to match: `B_ms / C_ms median = 0.951x` with explicit "B (dense)
  takes 95.1% of C (jagged)'s wallclock" prose so the ratio direction
  is unambiguous.

Tests
=====

New unit test in test_beam_decode_generate.py:
* test_compare_kv_modes_default_raises_on_validation_failure —
  exercises both:
   1. `_validate_compare_outputs` actually flags injected mismatches
      (top-1 disagreement on sample 0).
   2. The post-sweep raise path raises in strict mode and stays
      silent under `--allow_validation_fail`.

Verified: 57/57 tests in test_beam_decode_generate.py pass.

`--compare_kv_modes --sweep_hist 64 --sweep_beam 10 --sweep_dtype bf16`
on H100 PCIe prints the new "top-K overlap >= 70% on all 3 pairs"
language and the validation block.

Out of scope (still deferred from earlier audit rounds, codex agrees
these are the highest-leverage perf items but they live in another
MR):
* Per-step KJT.from_lengths_sync overhead in the decode loop.
* torch.cat for beam KV accumulation -> preallocated tensor.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Runchu Zhao <[email protected]>
z52527 added a commit that referenced this pull request May 26, 2026
…jagged-only)

Five fixes from codex review on the previous RESULTS rewrite:

1. Reproduce command was `--batch_size 16` only, but the bar chart
   covers four batches. Replaced with a 4-iteration shell loop so a
   reviewer can actually reproduce the figure.

2. Correctness verification was tagged "weakest to strongest" but the
   list runs kernel oracle → mask isolation → overlap guard, which is
   strongest to weakest. Flip the tag.

3. Restore benchmark provenance (date, branch, kernel pinned commit,
   flash-attention pinned commit, container torch / CUDA versions) on
   the hardware line.

4. Drop the entire "Jagged-native context K/V" section and the
   matching "use_jagged_kv=False kept as alternative" bullet from
   Known issues. The decision is settled — jagged + varlen is the
   default; dense path stays in code as a legacy fallback but doesn't
   need user-facing framing.

5. examples/sid_gr/README.md: drop the `use_jagged_kv` mention from
   the "see benchmark/RESULTS.md" pointer line so the upper-level doc
   doesn't reintroduce the same comparison framing.

Issue #1 from the codex audit (default flip + docstring refresh) was
addressed in the previous commit.

Signed-off-by: Runchu Zhao <[email protected]>
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.

2 participants