Skip to content

[Analysis] The DRAM bandwidth wall: decode performance ceiling for streaming MoE, measured paths forward #537

Description

@ZacharyZcR

Summary

Streaming MoE decode (S=1) on GLM-5.2 744B is DRAM-bandwidth-bound, not PCIe-bound and not compute-bound. This analysis quantifies the physical ceiling, shows we are already at 79–96% of it on a 6x RTX 5090 rig, identifies where the remaining 4–21% is lost, and proposes research directions — both software and hardware — for the community to discuss.

All numbers below are from controlled measurements on a 6x RTX 5090 + dual Xeon Silver 4510 (24 physical cores) + 251 GB DDR5 system, with GLM-5.2 int4 (gs=64), DRAFT=0, usage-snapshot-controlled placement, and PROF=1 instrumentation. PRs #429 (NUMA arena), #432 (device router), #433 (grouped kernels), #434 (resident accumulation), and #445 (pin budget fix) are all applied.


1. The bandwidth hierarchy — where the wall actually sits

For decode S=1, every expert evaluation is a GEMV: pure memory-bound, zero compute reuse. The only thing that matters is how fast weight bytes reach the arithmetic units.

Tier Theoretical peak Measured Time to read one expert (~20 MB)
GPU VRAM (GDDR7, per card) ~1,792 GB/s 0.011 ms
PCIe 5.0 x16 (per card) ~63 GB/s ~50 GB/s 0.4 ms
CPU DRAM (DDR5, dual-socket) ~120 GB/s 62–70 GB/s 0.3 ms
NVMe SSD (PCIe 4.0 x4) ~7 GB/s host-dependent ~3 ms

The critical ratio: VRAM bandwidth is 25–28x DRAM bandwidth. Once an expert lives in VRAM, it is effectively free. Once it lives in RAM, it costs 0.3 ms regardless of who computes it.

2. PCIe is not the bottleneck (and NVLink would not fix it)

A common intuition is that PCIe is the chokepoint between GPU and CPU memory. The data says otherwise:

PCIe 5.0 x16 throughput:   ~63 GB/s (measured ~50 GB/s)
DDR5 DRAM throughput:      ~120 GB/s theoretical, 62-70 GB/s measured

These are the same order of magnitude. Sending a RAM-resident expert to the GPU over PCIe (~0.4 ms) costs about the same as the CPU reading it directly from DRAM (~0.3 ms). The H2D transfer buys nothing — the GPU's 1,792 GB/s internal bandwidth advantage is gated by the DRAM egress rate, not by the interconnect.

Even replacing PCIe with NVLink-C2C (900 GB/s, as in Grace Hopper) only moves the bottleneck from the interconnect to the DRAM exit:

Interconnect GPU reads RAM expert at Bottleneck
PCIe 5.0 x16 ~63 GB/s PCIe ≈ DRAM (both limit)
NVLink-C2C min(900, 120) = 120 GB/s DRAM egress

That is a ~2x improvement, not a regime change. The wall is the DRAM itself.

We validated this experimentally: a "stream RAM experts to GPU" prototype (H2D + GPU compute per expert) ran 4x slower than CPU-direct (4.24 → 1.16 tok/s) due to per-expert H2D launch fragmentation — each of the ~4 RAM experts per layer is only ~20 MB, and the transfer setup overhead dominates. The branch is preserved at experiment/stream-ram-experts-FAILED.

3. Physical ceiling calculation

GLM-5.2 decode reads per token:

78 layers x topk=8 experts/layer x ~20 MB/expert = 12,480 MB ≈ 12.2 GB/token

Theoretical ceiling at various VRAM residency ratios (assuming 35 ms fixed attention + dense cost, measured):

Scenario CPU read volume At DDR5 measured (70 GB/s) At DDR5 theoretical (120 GB/s) Ceiling tok/s
100% RAM, 0% VRAM 12.2 GB 174 ms 102 ms 4.8 – 7.3
50% VRAM (our 6x5090) 6.1 GB 87 ms 51 ms 8.2 – 11.6
100% VRAM ~0 ~2 ms ~2 ms ~27

Our measurements vs. ceiling

Configuration Measured tok/s Ceiling (measured BW) Utilization
General workload, 6x5090 6.4–6.9 ~8.2 79–84%
Prompt-tuned placement, 6x5090 7.9 ~8.2 96%

The prompt-tuned result is essentially at the DRAM-bandwidth ceiling for this hardware. General workloads lose ~20% to placement inefficiency.

4. Why DDR5 utilization is only 58% (70 of 120 GB/s)

The ~50 GB/s gap between theoretical and measured DRAM bandwidth is the single largest source of lost performance. Root causes, in order of impact:

a) GEMV granularity is too fine

Each expert is ~20 MB. At S=1, the CPU scans each expert's weight matrix exactly once with a single-row dot product. The working set per OMP parallel region is ~200 KB per thread — too short for the memory controller to establish a sustained streaming pattern.

b) OMP fork/join fragmentation

The current execution model opens ~2 OpenMP parallel regions per expert (gate+up fused, then down projection). With ~4 CPU-tier experts per layer × 78 layers = ~312 expert evaluations per token, that is ~624 OMP fork/join cycles per token. Each cycle costs ~5–10 μs in barrier overhead and, more critically, invalidates the per-core prefetch state.

The XEXP=1 path (cross-expert single OMP region, colibri.c:3180) demonstrates the fix: one region across all experts in a 64-expert block, two internal barriers, verified byte-identical. It is currently CPU-only and gated on specific conditions (S==1, all int4, all resident, no CUDA).

c) NUMA non-uniformity

Dual-socket Xeon with DDR5 channels split across two NUMA nodes. Expert slabs allocated on node 0 and accessed by cores on node 1 pay a ~30% bandwidth penalty on the cross-UPI hop. PR #429's per-layer arenas stabilized bandwidth from ±21% variance to ±3%, but the mean is still ~70 GB/s, not 120 GB/s, because slab-to-core affinity is not yet optimized.

d) Memory controller occupancy

DDR5's peak bandwidth requires high outstanding-request counts to keep all banks busy. The short, sequential scan pattern of a single-expert GEMV does not generate enough concurrent requests — the memory controller's bank-level parallelism is underutilized.

5. Proposed research directions

Software optimizations (actionable now)

Direction Mechanism Expected impact Relevant work
Cross-expert single OMP region Generalize the XEXP=1 path to CUDA-enabled builds; one fork/join per block of 64, not per expert Reduce OMP overhead ~10x; improve prefetch continuity colibri.c:3180, #442
NUMA-aware expert scheduling Pin experts to arenas on the NUMA node whose cores will compute them; process same-node experts consecutively Eliminate ~30% cross-UPI bandwidth penalty #429 (arena foundation), #82
Larger effective GEMV granularity Batch adjacent-token expert sets (lookahead overlap is 36–41% at d=1–8); or fuse gate+up+down into a single streaming pass Better memory controller utilization #441, #442
E8/fmt=6 byte reduction int3-g64-e8-rot containers: −25% expert bytes, +3.3pp quality vs shipped int4 25% less DRAM traffic per token; more experts fit in VRAM #452 (ladder complete through converter)
Prefetch pipeline depth Increase PILOT queue depth beyond 1; overlap next-layer prefetch with current-layer compute Hide remaining disk latency; improve page-cache warmth #441, #480

Hardware paths (for discussion and community benchmarking)

Platform Unified BW Expert read time (20 MB) Projected ceiling (50% resident) Status
Our rig (DDR5 + 6x5090) 70 GB/s (DRAM) 0.3 ms ~8 tok/s Measured
NVIDIA Grace Hopper (GH200) ~500 GB/s (HBM3e CPU-side) 0.04 ms ~25 tok/s Available; needs benchmark
NVIDIA DGX Spark (Grace Blackwell) ~200 GB/s (unified) 0.1 ms ~15 tok/s Shipping; #161 has partial data
Apple M5 Max (unified) ~546 GB/s 0.037 ms ~27 tok/s Available; needs benchmark
CXL-attached HBM ~250–400 GB/s (CXL 3.0 pool) 0.05–0.08 ms ~18–25 tok/s Early availability (Samsung, SK Hynix CMM-H)
Processing-in-Memory (PIM) Eliminates data movement N/A Architectural change Research (Samsung HBM-PIM, UPMEM); not production-ready for MoE
Silicon photonics / optical I/O >1 TB/s chip-to-chip <0.02 ms >30 tok/s Research (Ayar Labs, Intel); 2026–2028 timeline

The key insight: unified high-bandwidth memory architectures (Grace Hopper, Apple Silicon) bypass the DRAM wall entirely by placing the expert weights in the same memory technology the compute units read at full speed. This is the only path to a regime change — software optimizations on DDR5 systems can recover the 58% → ~80–90% utilization gap, but cannot break the 120 GB/s ceiling.

6. Call for community contributions

We are opening this analysis to invite collaboration on three fronts:

  1. Cross-platform bandwidth benchmarks. If you have access to Grace Hopper, DGX Spark, Apple M-series (M4 Max/Ultra, M5 Max), or CXL-attached memory systems: run GLM-5.2 with PROF=1 and report the expert-matmul and bandwidth numbers. The ceiling calculation above can be validated or refined with real data from these platforms.

  2. Software optimization PRs. The XEXP cross-expert region and NUMA-aware scheduling directions above are concrete, measurable, and independently implementable. We would be happy to review and A/B any PR that targets the 70 → 120 GB/s gap.

  3. Architecture discussion. If you have domain expertise in memory systems, CXL, optical interconnects, or PIM: what is realistic on a 1–2 year timeline for a system that can hold ~300 GB of expert weights at >200 GB/s sustained random-read bandwidth? The streaming MoE use case (many small sequential reads, each ~20 MB, to different addresses) is not the typical HPC streaming pattern, and we would value informed perspective on which technologies actually fit.

The fundamental physical constraint is clear: DRAM bandwidth is the wall, and the wall is 15–28x below GPU memory bandwidth. The question is whether we optimize within it or build around it.


Measured on 6x RTX 5090 + dual Xeon Silver 4510, GLM-5.2 int4-gs64, DRAFT=0. Related: #431 (CUDA choreography analysis), #442 (scalar reduction), #441 (PILOT QD), #452 (E8 container), #429 (NUMA arena). All data from PRs #432/#433/#434/#445 applied.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceVelocità / tok-s / ottimizzazioni

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions