Nandai AI
Sign In
GGF-38 · SINGLE-STREAM VS CONTINUOUS-BATCHING ROOFLINE: ARITHMETIC INTENSITY CROSSOVER

Single vs Batch GGUF Roofline: Arithmetic Intensity Ridge Points, Sparse MoE Batch Dispersion & Prefill FLOPs

Derive the exact hardware ridge point (TFLOPs / Bandwidth GB/s) showing why batch=1 decode is strictly bandwidth-bound, why dense batching hits free throughput multipliers, and how 256-expert MoEs behave differently.

Roofline Theory Disclosure: Hardware ridge points compare manufacturer peak FP16/Tensor specs against nominal DRAM bandwidth; real MoE batch dispersion varies by prompt similarity and token routing entropy.

GGF-38 · Roofline Theory · Compute vs Bandwidth⌘9 Model Manager

OS-Aware Studios & Tools

Verify memory fit before downloading weights, or launch zero-upload browser studios on macOS, Windows, and Linux:

02 · Hardware Memory-Bandwidth Roofline & KV Matrix

Exact Weight GiB, Active GB/Token, KV Scaling & Bandwidth Ceilings

Hardware compute-to-bandwidth ridge points (Peak FP16 TFLOPs / Memory Bandwidth TB/s) illustrating how many ops/byte saturate ALUs across Mac and RTX silicon.

Hardware TierQuant / ModeWeight GiBActive GB/tokKV @ 32KKV @ 128KKV @ 1MRoofline tok/sResidency Fit
Apple M4 Pro (273 GB/s · ~18 TF FP16)Ridge Point ≈ 66 FLOPs/Byte18.0–51.5 GiB1.95 – 16.2 GB1.00 – 1.50 GiB4.00 – 6.00 GiB40.25 GiB (Q4)78.62 (k=1) -> 93.37 (k=8) auditedBandwidth-bound <=32 batch
Apple M4 Max (546 GB/s · ~36 TF FP16)Ridge Point ≈ 66 FLOPs/Byte51.5–104 GiB2.95 – 28.0 GB1.50 GiB5.25 GiB40.25 GiB185.1 (k=1) -> scales w/ batchBalanced UMA batching
NVIDIA RTX 4090 (1,008 GB/s · 330 TF Tensor)Ridge Point ≈ 327 FLOPs/Byte22.5 GiB VRAM2.45 – 14.3 GB1.50 GiB5.25 GiBExceeds VRAM411.4 (k=1) -> >1,000+ batch agg.Massive Tensor headroom
NVIDIA RTX 5090 (1,792 GB/s · 419 TF FP16)Ridge Point ≈ 234 FLOPs/Byte30.2 GiB VRAM2.95 – 21.4 GB1.50 GiB5.25 GiB25.15 GiB total (IQ3)607.5 (k=1) -> >1,800+ batch agg.High-batch prefill leader
Variant / ModeMemory / ThroughputRecommended Hardware Configuration
Batch=1 Interactive Decode~1–2 FLOPs / Byte (Bandwidth-Bound)100% governed by Bus GB/s / Active_GB
Dense Batch=8 (LFM2 / 27B)1x Weight Read -> 8x Token OutputsAudited +18.8% on 8B-A1B (78.62 -> 93.37)
Long Prompt Prefill (N >= 16K)>100 FLOPs / Byte (Compute-Bound)Governed by GPU FP16/Int4 TFLOPs

Section 01 · GGF-38

The Hardware Ridge Point: Why Decode Ignores TFLOPs Until Batching Crosses 60+ Tokens

Dividing peak GPU TFLOPs by memory bandwidth reveals why 95% of Tensor cores sit idle at batch=1.

Every processor sits at a hardware ridge point equal to Peak_Compute_FLOPs_s divided by Peak_Memory_Bandwidth_Bytes_s. For an Apple M4 Pro (~18 TFLOPs FP16 / 273 GB/s), that ridge point sits near ~66 FLOPs per byte fetched from DRAM; for an NVIDIA RTX 4090 (~330 FP16 Tensor TFLOPs w/ FP16 accum / 1,008 GB/s), the ridge point reaches ~327 FLOPs per byte.

During batch=1 autoregressive decode on a Q4_K_M weight (0.61 bytes/parameter, 2 FLOPs per multiply-add), arithmetic intensity is roughly 2 / 0.61 ≈ 3.3 FLOPs/byte—less than 5% of the M4 Pro ridge point and barely 1% of the RTX 4090 ridge point! Thus batch=1 speed tracks DRAM bandwidth (GB/s) almost exclusively, while prompt prefill across N = 512–8,192 tokens boosts arithmetic intensity past 500+ FLOPs/byte and hits full compute saturation.

Understanding this exact roofline crossover helps capacity planners avoid mismatched upgrades: adding raw GPU TFLOPs helps massive prefill ingestion and high-concurrency batching, whereas upgrading DRAM bandwidth (GB/s) or shrinking active bytes per token via sparse MoE directly accelerates single-user interactive response speed.

Roofline / Allocation EquationRidge_Point (FLOPs/Byte) = Peak_FLOPs_s / Bus_Bytes_s | Achieved_TPS = min(Compute_TPS, Bus_Bytes_s / Active_Bytes_per_Step)

Section 02 · GGF-38

Why Batch=8 Scales Differently on Dense 27B vs 256-Expert Sparse MoE

Dense batching shares 100% of loaded weights; sparse MoE batching increases expert activation density.

When serving 8 concurrent sequences (--parallel 8) on a dense model like 27B Q4_K_M, all 8 streams execute the exact same weight matrices fetched once from DRAM—giving nearly an 8x aggregate tok/s boost before approaching the compute ridge point (minus increased KV cache scan bytes across 8 slots).

On a 256-expert sparse MoE like Qwen 4 35B-A3B (selecting 8 out of 256 experts per token), 8 simultaneous tokens from unrelated user prompts route to largely disjoint experts: probability math shows 8 tokens with 8 choices out of 256 activate ~57 unique experts instead of 8! Consequently, batching MoE increases total active DRAM traffic per step while raising Tensor core utilization—boosting aggregate server throughput cleanly, though less than linearly compared to dense models, and matching our audited LFM2-8B-A1B jump from 78.62 tok/s (k=1) to 93.37 tok/s (k=8).

To calculate exact expected expert activation count u across batch size B when choosing k=8 routed experts uniformly out of E=256 experts, apply the exact occupancy formula: E[unique] = 256 × (1 − (1 − 8/256)^B). At B=1, u=8; at B=4, u≈30.5; at B=8, u≈57.2—explaining mathematically why MoE batching trades slightly higher active DRAM reads for superior multi-user scaling.

Verification & Runtime Flagsllama-server -m Qwen4-35B-A3B-UD-IQ4_XS.gguf -np 4 -c 131072 -ctk q8_0 -ctv q8_0 -fa on -ngl 99

Section 03 · GGF-38

Memory Cost of Continuous Batching: Multiplying KV by n_parallel

Every concurrent batch slot reserves its own Key/Value slice unless sharing cached system prompts.

Remember that setting -np 4 or -np 8 divides total --ctx-size or multiplies KV allocation by n_parallel. Running 4 concurrent 32K slots (128K total allocated KV tokens) on Qwen 4 requires 5.00 GiB FP16 or 2.66 GiB Q8_0 KV (+0.25–1.0 GiB GDN state), fitting effortlessly inside 32 GB RTX 5090 or 48–64 GB M4 Max pools.

Notice the dual bottleneck when scaling continuous batching past n_parallel=16 on long contexts: not only does KV memory multiply by n_parallel, but every step’s attention scan must read all active KV pools across all concurrent requests—shifting long-context multi-user serving steadily back toward memory-bandwidth saturation even on RTX 5090.

Whenever serving shared studio pipelines with --parallel 4 or --parallel 8, enable unified prefix caching so identical system prompts, schema templates, and tool instructions occupy only one shared KV prefix block rather than duplicating static tokens across every concurrent sequence slot.

Interactive Sizing & Browser Studios

Verify Exact Memory Margins Before Downloading Multi-Gigabyte GGUFs

Plug your exact hardware SKU, KV quantization (--cache-type-k / -v), and context length into our zero-upload GGUF VRAM & Roofline Calculator. Explore full model cards at /models and Apple Silicon tier breakdowns at /apple-silicon, or draft and audit content inside /writing-engine and /seo-engine.

05 · Technical FAQ (1:1 JSON-LD Parity)

Single vs Batch Decode Roofline — Frequently Asked Questions

Why doesn’t a GPU with 2x more TFLOPs double single-stream GGUF tok/s?

Single-stream decode performs only ~1–3 FLOPs per byte loaded—sitting far below the 66–327 FLOPs/byte hardware ridge point—so DRAM bandwidth (GB/s) caps speed rather than shader compute.

Why does Destiny Swift (8B-A1B) scale from 78.62 tok/s at batch=1 to 93.37 tok/s at batch=8?

Shared projection weights and attention layers loaded once serve 8 parallel sequences simultaneously, lifting aggregate hardware utilization by +18.8%.

Why does batch=8 scale sub-linearly on 256-expert MoE models vs dense models?

Because 8 unrelated tokens trigger ~57 distinct routed experts out of 256 rather than reusing the exact same 8 experts, reading additional expert weights from DRAM per step.

Where can I simulate n_parallel memory and throughput on my hardware?

Open /tools/gguf-vram-calculator and adjust the Seqs (n_parallel) field from 1 to 64.

Founder Pro $9.99/mo · 67% Off1-tap Stripe Checkout · Instant ?ref= Free Months · 40% Recurring Partner Payouts
1. Subscribe in 1 TapFOUNDER_999_LOCK

Unlock All 19 Pro Studios + Mac App

Lock $9.99/mo Founder Pro (reg. $29.99 — 67% off), $119/yr Web Annual (-34%), or $299/yr 5-Mac + Web Pro.

Redeem Code
2. Get 6 Months FreeZERO OTP

Mint Your ?ref= Link Instantly

Give friends 67% off ($9.99/mo). Every paid friend adds 30 days of Pro free to your account (up to 6 months).

Dashboard: /refer · Rules

3. Creator & Publisher Cash90-DAY COOKIE

Earn 40% Monthly · 30% Annual

Earn 40% recurring monthly until cancel + 30% annual & every renewal, or embed our free tools with data-ref.