Benchmark suite#
Primus ships microbenchmarks for GPU compute and distributed communication. They are exposed as the benchmark subcommand of the Primus CLI. Use them to validate a node or cluster before long training jobs.
Implementation: primus/cli/subcommands/benchmark.py (initializes distributed execution, runs the selected suite, then finalizes).
Related documentation: Preflight diagnostics (broader cluster checks), Memory and performance projection (training-scale estimates), Installation (environment setup).
Overview and command syntax#
primus-cli [global-options] <mode> [mode-args] -- benchmark <suite> [suite-specific-args]
<mode>is typicallydirect,container, orslurmso thatWORLD_SIZE,RANK,MASTER_ADDR, and related variables are set consistently.benchmarkruns inside the Primus Python CLI; the runner wires up the process environment the same way as training.
The CLI also registers an attention suite; the subsections below cover gemm, gemm-dense, gemm-deepseek, strided-allgather, and rccl.
Quick start#
Single-node GEMM:
primus-cli direct -- benchmark gemm --M 4096 --N 4096 --K 4096 --dtype bf16 --duration 10
Multi-node RCCL on Slurm:
primus-cli slurm srun -N 4 -- benchmark rccl --op all_reduce --min-bytes 1M --max-bytes 128M
Suite reference#
gemm#
Single-shape general matrix multiply (GEMM) microbenchmark.
Argument |
Description |
|---|---|
|
Matrix dimensions (defaults: 4096 / 4096 / 4096). |
|
Transpose the A matrix. |
|
Transpose the B matrix. |
|
|
|
Run duration in seconds (default: 10). |
|
Destination for results ( |
Example
primus-cli direct -- benchmark gemm --M 8192 --N 8192 --K 8192 --dtype bf16 --duration 10 --output-file ./gemm_report.md
gemm-dense#
Dense GEMM workload using Llama-like shape parameters (model-derived GEMMs).
Argument |
Description |
|---|---|
|
Optional label (for example |
|
Sequence length (default: 2048). |
|
Hidden size (default: 4096). |
|
FFN intermediate size (default: 11008). |
|
Attention heads (default: 32). |
|
KV heads (default: 32). |
|
Per-head dimension (default: 128). |
|
Vocabulary size (default: 32000). |
|
|
|
Microbatch size (default: 1). |
|
Seconds per shape (default: 3). |
|
Report path (default: |
Example
primus-cli direct -- benchmark gemm-dense --model Llama3.1_8B --seqlen 4096 --dtype bf16
gemm-deepseek#
Dense GEMM workload using DeepSeek-style shapes (MoE / MLA-related dimensions).
Argument |
Description |
|---|---|
|
Label (for example |
|
Sequence length (default: 4096). |
|
Hidden size (default: 4096). |
|
Dense FFN intermediate (default: 12288). |
|
KV LoRA rank (default: 512). |
|
MoE expert intermediate (default: 1536). |
|
Attention heads (default: 64). |
|
Experts per token (default: 6). |
|
Number of routed experts (default: 128). |
|
Shared experts (default: 2). |
|
Optional Q LoRA rank. |
|
Head dimensions for MLA-style attention (defaults: 128 / 64 / 128). |
|
Vocabulary size (default: 128256). |
|
|
|
Microbatch size (default: 1). |
|
Seconds per shape (default: 3). |
|
Report path (default: |
|
Append to an existing report instead of overwriting. |
Example
primus-cli direct -- benchmark gemm-deepseek --model Deepseek_V3 --dtype bf16 --append
strided-allgather#
Strided all-gather microbenchmark (useful for multi-rank communication patterns).
Argument |
Description |
|---|---|
|
Comma-separated message sizes in MB per rank (default: |
|
Rank stride for group formation (default: 8). |
|
Run multiple groups’ all-gathers in parallel. |
|
Timed iterations per size (default: 50). |
|
Warmup iterations per size (default: 10). |
|
|
|
|
Example
primus-cli slurm srun -N 2 -- benchmark strided-allgather --sizes-mb 64,128 --stride 8 --iters 50
rccl#
RCCL collective benchmark: sweeps message sizes and reports bandwidth and latency statistics.
Argument |
Description |
|---|---|
|
One or more of: |
|
Explicit size list (for example |
|
Minimum message size for generated sweep (default: |
|
Maximum message size (default: |
|
Number of points in generated sweep (default: 12). |
|
|
|
|
|
Warmup iterations (default: 20). |
|
Timed iterations (default: 100). |
|
Repeat each |
|
Emit an extra summary row aggregating repeat runs. |
|
Enable lightweight correctness checks. |
|
Report path ( |
|
Append instead of overwrite. |
|
Per-rank summary lines. |
|
Path for per-rank stats (if empty, derived from |
|
Emit per-iteration trace (can be large). |
|
Trace output path (if empty, derived from |
|
Max iterations to record per |
|
Comma-separated ops to include in trace (empty = all). |
|
Comma-separated sizes to include in trace (empty = all). |
|
Label for the report preamble. Defaults to |
Example
primus-cli slurm srun -N 4 -- benchmark rccl --op all_reduce --min-bytes 1M --max-bytes 128M --dtype bf16
Understanding results#
GEMM suites emit throughput-oriented metrics suitable for comparing dtypes, shapes, and durations across runs. Keep
durationlong enough to smooth variance on shared clusters.rcclreports collective latency and bandwidth across a size sweep; use it to verify inter-node behavior and to compare against expected NIC bandwidth.Markdown / CSV / TSV / JSONL output formats support post-processing in notebooks or CI; gzip JSONL is supported for large traces.
Tips#
Distributed initialization: If jobs hang or report uninitialized distributed state, launch through
primus-cli(direct/container/slurm) rather than calling Python entrypoints manually without the right environment.Paths: Prefer absolute paths for
--output-filewhen using containers or Slurm so the working directory matches your expectations.Multi-node: Use your scheduler integration (
primus-cli slurm …) so rank and address assignment matches your cluster.Full cluster validation: Combine targeted
benchmarkruns with Preflight for host, GPU, network, and integrated perf checks.