Skip to content

benchmark: update HSTU benchmark fixes and docs - #411

Merged
shijieliu merged 6 commits into
NVIDIA:mainfrom
JacoCheung:junzhang/benchmark_cont
Jun 1, 2026
Merged

shijieliu merged 6 commits into
NVIDIA:mainfrom
JacoCheung:junzhang/benchmark_cont

Conversation

@JacoCheung

@JacoCheung JacoCheung commented May 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary:

  • Fix HSTU FLOP/MFU accounting: dim_per_head in output projection, H100 BF16 peak = 989 TFLOPS, DP-group FLOP reduction.
  • Speed up shuffler load balancing with a C++ Karmarkar-Karp partitioner that releases the GIL.
  • Reduce Python hot-path stalls with pinned host copies in DynamicEmb and batch shuffler paths.
  • Fix benchmark data/timing: one-pass random dataset generation, log-overhead isolation, log/eval/sequence-length knobs, and shorter profiling windows.
  • Harden distributed runs: CUDA_DEVICE_MAX_CONNECTIONS default 8, per-rank tmp/cache dirs, DP collective warmup, and configurable GPU request flags.
  • Extend benchmark tooling: unified e2e/layer/kernel launch path, layer analyzers, and refreshed benchmark docs.

Validation:

  • Benchmark runs completed.
  • Pre-commit passed.

@JacoCheung JacoCheung changed the title docs: update HSTU benchmark docs benchmark: update HSTU benchmark fixes and docs May 29, 2026
@greptile-apps

greptile-apps Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes HSTU FLOP/MFU accounting (missing dim_per_head in the output projection, H100 BF16 datasheet peak corrected to 989 TFLOPS), speeds up load-balancing with a GIL-releasing C++ Karmarkar-Karp partitioner, reduces hot-path stalls with pinned host copies, and hardens benchmark infrastructure (timer isolation, DP warmup collective, per-rank directories, and a unified benchmark launch path).

  • FLOP/MFU accounting: cal_hstu_flops_single_rank output projection now correctly multiplies by dim_per_head; _KNOWN_GPU_SPECS always takes precedence over the formula-derived value for known GPUs; cal_hstu_flops switches from gather-to-rank-0 to per-rank compute + all_reduce, returning the same total on all DP ranks.
  • C++ KK partitioner: kk_partition.cpp releases the GIL for the entire compute, is validated to be bit-for-bit identical to the Python path by an extensive parity test suite, and is registered in setup.py as a pure-CPU extension buildable without CUDA toolchain.
  • HSTUBatch.slice + one-pass dataset: a new slice() method on HSTUBatch handles KJT row slicing with optional padding; HSTURandomDataset now generates one large combined batch and slices it instead of calling random() per batch, reducing RNG overhead.

Confidence Score: 5/5

The changes are safe to merge; all correctness-critical paths (FLOP accounting, KK parity, stream ordering) are well-tested and carefully guarded.

The FLOP/MFU fixes are straightforward arithmetic corrections with clear justification. The C++ KK extension comes with an exhaustive parity test suite (including adversarial tie-breaking cases and a GIL-release validation). Pinned-memory helpers synchronize before returning and document the caller's stream obligation. The timer reset change correctly isolates logging overhead, and the distributed warmup is guarded against non-initialized environments.

No files require special attention. The two minor observations are in analyze_layer_results.py (log-file selection) and partitioner.py (.so sort order), neither of which affects training correctness.

Important Files Changed

Filename Overview
examples/commons/utils/perf.py FLOP accounting fixes: output projection now multiplies by dim_per_head, H100 BF16 peak corrected to 989 TFLOPS, and DP gather replaced by per-rank compute + all_reduce.
examples/commons/perf_model/csrc/kk_partition.cpp New C++ Karmarkar-Karp partitioner that releases the GIL; tie-breaking rules mirror the Python implementation exactly, as validated by the parity test suite.
examples/commons/utils/tensor_transfer.py New utility for pinned-memory H2D/D2H transfers; non-blocking copies are correctly documented as caller-must-consume-on-same-stream.
examples/commons/distributed/batch_shuffler.py Hot-path GPU ops replaced with CPU-list equivalents; actual_bs counting now uses partitions_list instead of GPU fancy indexing.
examples/hstu/training/trainer/training.py Timer reset logic corrected (last_td=0 + restart instead of accumulation) to exclude log-overhead from the next measured interval; DP warmup collective added before the training loop.
examples/commons/datasets/hstu_batch.py New slice() method on HSTUBatch correctly handles KJT slicing, optional padding, and actual_batch_size propagation.
examples/commons/perf_model/partitioner.py Adds C++ extension resolution logic with KK_FORCE_PYTHON override; public karmarkar_karp dispatches to C++ or Python fallback; equal_size assertion moved to the public wrapper.
examples/hstu/training/benchmark/scripts/analyze_layer_results.py New script to parse layer benchmark logs and emit TFLOPS/time plots; only reads the first (alphabetically sorted) .log file per experiment directory.

Reviews (10): Last reviewed commit: "refactor(commons): generalize pinned ten..." | Re-trigger Greptile

Comment thread examples/commons/utils/perf.py Resolved
@JacoCheung
JacoCheung force-pushed the junzhang/benchmark_cont branch 3 times, most recently from d463e18 to 210b5c4 Compare May 29, 2026 09:00
@JacoCheung
JacoCheung requested a review from shijieliu May 29, 2026 09:15
@JacoCheung

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented May 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

✅ Pipeline #53043685 -- success

Job Status Log
pre_check ✅ success view
train_build ✅ success view
inference_build ✅ success view
tritonserver_build ✅ success view
build_whl ✅ success view
dynamicemb_test_fwd_bwd_8gpus ✅ success view
dynamicemb_test_load_dump_8gpus ✅ success view
unit_test_1gpu_a100 ✅ success view
unit_test_1gpu_h100 ✅ success view
unit_test_4gpu ✅ success view
unit_test_tp_4gpu ❌ failed view
L20_unit_test_1gpu ✅ success view
inference_unit_test_1gpu ✅ success view
inference_test_1gpu ✅ success view

Result: 13/14 jobs passed

View full pipeline

@JacoCheung
JacoCheung force-pushed the junzhang/benchmark_cont branch from 26b20d6 to aa2cbd7 Compare June 1, 2026 04:03
@shijieliu
shijieliu merged commit a84ae58 into NVIDIA:main Jun 1, 2026
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