Skip to content

Benchmarks - Add ROCm TransferBench mem-bw backend and fix PyTorch DDP store init - #868

Draft
Nguyen Vuong (normanvuong) wants to merge 5 commits into
microsoft:mainfrom
normanvuong:nguyenvuong/rocm10_benchmarks
Draft

Nguyen Vuong (normanvuong) wants to merge 5 commits into
microsoft:mainfrom
normanvuong:nguyenvuong/rocm10_benchmarks

Conversation

@normanvuong

@normanvuong Nguyen Vuong (normanvuong) commented Oct 9, 2026 •

Copy link
Copy Markdown

Description
Split out of #867 at the reviewer's request. These changes are independent of the ROCm 10 image. The new options are opt-in and their defaults are unchanged. The one change to default behavior is a bug fix to how PyTorch model benchmarks create the DDP store.

Major Revision

  • mem-bw (ROCm): add a TransferBench backend, selected with SB_ROCM_MEM_BW_BACKEND=transferbench, for ROCm 10 images where the HIP 5.5 hipBusBandwidth sample is unavailable. It keeps the hipBusBandwidth policy: the same size sweep (64 B–512 MiB) and trial counts, one DMA engine on the visible GPU, pinned P0 or pageable H<worker NUMA node>, a per-size arithmetic mean, then the maximum across sizes. A sweep fails on any TransferBench error, missing iteration or unexpected route, with no fallback. The default backend is still hipbusbandwidth.
  • PyTorch model benchmarks (DDP): fix intermittent ResNet/BERT crashes under torchrun. _init_distributed_setting started a new TCPStore server on MASTER_PORT + 1 and also rewrote MASTER_PORT to that port. If that port was already in use (e.g. as an ephemeral port), torch ignored the bind failure because TORCHELASTIC_USE_AGENT_STORE was set and the port matched MASTER_PORT. Rank 0 then quietly connected to an unrelated socket. Now:
    • Under torchrun (TORCHELASTIC_USE_AGENT_STORE=True), every rank joins the agent's store on MASTER_PORT as a client, the same way torch.distributed.rendezvous does.
    • Otherwise, rank 0 hosts the store on MASTER_PORT.
    • MASTER_PORT is no longer modified, and a per-process sequence in the store prefix keeps the keys of successive benchmarks apart.

Minor Revision

  • Model benchmarks: add --optimizer_eps (default 1e-8; 1e-4 is needed for native FP16 Adam) and allow bfloat16 for BERT, GPT-2 and LLaMA.
  • megatron-gpt: without --code_base, default to $SB_MEGATRON_PATH when set; actually append --extra; fail on a nonzero training exit; restore OMPI_COMM_WORLD_LOCAL_RANK.
  • Tests: add TransferBench parser tests with synthetic v1.69.00 CSV-mode fixtures, Megatron launch and precision/epsilon tests, and a DDP store test covering agent-store and non-agent-store ranks, MASTER_PORT preservation and unique key prefixes.
  • Docs: document the new options in micro-benchmarks.md and model-benchmarks.md.

Validation

  • python3 -m pytest tests/benchmarks/model_benchmarks/test_pytorch_base.py tests/benchmarks/model_benchmarks/test_transformer_precisions.py tests/benchmarks/model_benchmarks/test_megatron_launch.py: 21 passed (Linux, CPU PyTorch 2.14.1). The new DDP store test fails against the previous pytorch_base.py.
  • yapf --diff and flake8 are clean on the changed files.
  • With this change, a ROCm 10.1 image (Dockerfile - Add ROCm 10.1 dockerfile with MI455X (gfx1250) support #867) passed the current (26.10) SuperBench configuration, including the ResNet and BERT DDP benchmarks that previously crashed.

… fixes

Split out of the ROCm 10 image PR (microsoft#867), ported from arsdragonfly/superbenchmark@rocm10.

- mem-bw: opt-in TransferBench backend (SB_ROCM_MEM_BW_BACKEND=transferbench)
  that keeps the hipBusBandwidth size sweep, trial counts and reduction.
- model-benchmarks: --optimizer_eps; bfloat16 for BERT/GPT-2/LLaMA.
- megatron-gpt: SB_MEGATRON_PATH default code base, apply --extra, fail on
  nonzero training exit and restore OMPI_COMM_WORLD_LOCAL_RANK.
- Add synthetic TransferBench fixtures and document the new options.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The TransferBench sweep does not work with the existing --log_flushing execution mode.

1 open finding
What changed in this PR

Adds an opt-in ROCm TransferBench memory-bandwidth backend and improves model benchmark configuration and reliability.

Changes:

  • Adds TransferBench command generation, parsing, NUMA handling, and tests.
  • Adds BF16 and optimizer epsilon support.
  • Improves Megatron path selection, argument forwarding, failure handling, and documentation.
File Description
tests/​data/​rocm_transferbench_unpinned_htod.log Adds pageable H2D fixture.
tests/​data/​rocm_transferbench_unpinned_dtoh.log Adds pageable D2H fixture.
tests/​data/​rocm_transferbench_pinned_htod.log Adds pinned H2D fixture.
tests/​data/​rocm_transferbench_pinned_dtoh.log Adds pinned D2H fixture.
tests/​benchmarks/​model_benchmarks/​test_transformer_precisions.py Tests BF16 and optimizer epsilon.
tests/​benchmarks/​model_benchmarks/​test_megatron_launch.py Tests Megatron launch behavior.
tests/​benchmarks/​micro_benchmarks/​test_rocm_memory_bw_performance.py Tests TransferBench behavior and parsing.
superbench/​benchmarks/​model_benchmarks/​pytorch_llama.py Enables BF16 for LLaMA.
superbench/​benchmarks/​model_benchmarks/​pytorch_gpt2.py Enables BF16 for GPT-2.
superbench/​benchmarks/​model_benchmarks/​pytorch_bert.py Enables BF16 for BERT.
superbench/​benchmarks/​model_benchmarks/​pytorch_base.py Adds configurable optimizer epsilon.
superbench/​benchmarks/​model_benchmarks/​megatron_gpt3.py Improves Megatron launching and failure handling.
superbench/​benchmarks/​micro_benchmarks/​rocm_memory_bw_performance.py Implements the TransferBench backend.
docs/​user-tutorial/​benchmarks/​model-benchmarks.md Documents model options.
docs/​user-tutorial/​benchmarks/​micro-benchmarks.md Documents TransferBench usage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

TransferBench sweeps fail when the supported --log_flushing option is enabled because shell chaining is not interpreted.

2 open findings

🧠 Review effort: Balanced

run_command(flush_output=True), used with --log_flushing, splits the command
without a shell, so the && chain was passed to the first TransferBench as
arguments. Wrap each direction's sweep in sh -c and test both paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A nonzero Megatron subprocess exit can still make the public benchmark runner return success.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Benchmark.run() records exceptions but still returns True, so raising on a
nonzero Megatron exit did not fail the run. Log the failure and return no
timings so ModelBenchmark.__train() takes its normal failure path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Megatron’s legacy path fallback remains unavailable during dataset generation, and optimizer epsilon lacks semantic validation.

0 open findings

1 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Apply legacy Megatron-LM path before dataset generation

superbench/​benchmarks/​model_benchmarks/​megatron_gpt3.py:663

This early default only handles the environment override. When SB_MEGATRON_PATH is unset, code_base remains empty while ModelBenchmark._preprocess() is still inside _generate_dataset(), so dataset generation invokes the relative tools/preprocess_data.py path before the legacy fallback at lines 243–245 is applied. Set the legacy Megatron-LM path here as well so the documented fallback works when preprocessing a missing dataset.

Medium severity Validate optimizer epsilon is finite and positive

superbench/​benchmarks/​model_benchmarks/​pytorch_base.py:138

type=float accepts invalid optimizer epsilons such as negative or infinite values. A negative value makes torch.optim.Adam/AdamW raise during _create_optimizer() (and the benchmark's exception path can still return success), while infinity silently prevents meaningful updates. Validate that this new public argument is finite and positive during argument preprocessing so invalid input returns INVALID_ARGUMENT.

🧠 Review effort: Balanced

Binding a TCPStore server on MASTER_PORT + 1 can collide with an ephemeral port. Because MASTER_PORT was also rewritten to that port, torch ignored the bind failure under TORCHELASTIC_USE_AGENT_STORE and rank 0 silently became a client of an unrelated socket, crashing ResNet/BERT DDP runs.

Under torchrun, join the agent's store on MASTER_PORT as a client, matching torch.distributed.rendezvous; otherwise rank 0 hosts it on MASTER_PORT. MASTER_PORT is no longer modified, and a per-process sequence keeps the store keys of successive benchmarks apart.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 21:38
@normanvuong Nguyen Vuong (normanvuong) changed the title Benchmarks - Add ROCm TransferBench mem-bw backend and model benchmark fixes Benchmarks - Add ROCm TransferBench mem-bw backend and fix PyTorch DDP store init Nov 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The rendezvous change lacks multi-process coverage for both store paths and repeated initialization, and the new test uses mock-call APIs unavailable in supported Python 3.7.

2 open issues

Review effort: Balanced

Comment on lines +375 to +379
# The store can outlive one benchmark in the same process, so give each init its own key prefix.
PytorchBase._store_seq += 1
store = PrefixStore(
self._name, TCPStore(addr, port, self._world_size, self._global_rank == 0, timedelta(seconds=300))
'{}/{}'.format(self._name, PytorchBase._store_seq),
TCPStore(addr, port, self._world_size, is_master, timedelta(seconds=300))
Comment on lines +268 to +269
assert (init_process_group.call_args.kwargs['store'] is prefix_store.return_value)
return tcp_store.call_args.args, prefix_store.call_args.args[0]

This branch has not been deployed

No deployments
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