Skip to content

Commit 47b44aa

Browse files
committed
Add disaggregation calculator (agg vs disagg decision tool)
Architecture-first calculator for the agg-vs-disagg serving decision: derives the verdict from a model's config.json + GPU HBM/bandwidth + workload, reports memory fit, predicted TTFT/ITL/throughput, $/Mtok, and a verdict. Pure stdlib Python (no install) + two static HTML pages (no server). Companion planning tool to inference/agentic-ai/nemotron/ultra. - analyze/calc.py + calibration.py: the engine (calc lazily imports calibration; ships together so numbers are calibrated to live-measured, not roofline-only) - results/calibration/ledger.jsonl: measured datapoints (seeded on p5en/H200) - web/{index,calculator}.html: in-browser calculator, mirrors calc.py - docs/{PRODUCTION-GUIDE,METHODOLOGY}.md: when-to-disaggregate + the math Author: Anton Alexander
1 parent 9924007 commit 47b44aa

9 files changed

Lines changed: 2926 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
*.pyc
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Disaggregation Calculator — agg vs. disagg decision tool for LLM serving
2+
3+
Author: Anton Alexander
4+
5+
An architecture-first calculator that answers a single question for any model on any GPU:
6+
**should I serve it aggregated (prefill + decode on one worker) or disaggregated (prefill and decode
7+
split across workers, KV cache moved over the network)?** It derives the answer from the model's real
8+
architecture (`config.json`), the GPU's HBM and bandwidth, and your workload (input/output token lengths,
9+
SLO), then reports the memory fit, the predicted TTFT/ITL/throughput, the $/Mtok, and the verdict.
10+
11+
It is the planning companion to the [NVIDIA Nemotron 3 Ultra 550B](../nemotron/ultra) deployment in this
12+
project: use the calculator to pick a topology, then deploy it with the `agg` / `disagg` manifests there.
13+
14+
To stay aligned with the principles of the [do-framework](https://bit.ly/do-framework), this tool is pure
15+
Python standard library (no install) plus two static HTML pages (no server) — clone and run.
16+
17+
## What's here
18+
19+
```
20+
disagg-calculator/
21+
analyze/
22+
calc.py # the engine — architecture-aware agg/disagg math + verdict (CLI + importable)
23+
calibration.py # PREDICT → MEASURE → DELTA loop; corrects the math toward live-measured numbers
24+
results/
25+
calibration/
26+
ledger.jsonl # append-only measured datapoints the calculator calibrates against (seeded on p5en)
27+
web/
28+
index.html # interactive calculator (pick a model + GPU + workload → verdict), runs in-browser
29+
calculator.html # the same engine as a single-purpose page (shareable link)
30+
docs/
31+
PRODUCTION-GUIDE.md # when to disaggregate vs. scale aggregated replicas — rules of thumb + worked cases
32+
METHODOLOGY.md # the math, the physics assumptions, and how the calibration loop refines them
33+
```
34+
35+
> **Engine = two files.** `calc.py` lazily imports `calibration.py`; without it the calculator silently
36+
> falls back to the uncalibrated HBM-roofline numbers (e.g. decode ITL ~4 ms instead of the live-measured
37+
> ~80 ms). Always ship/run them together. `ledger.jsonl` is the measured data they calibrate against.
38+
39+
## Prerequisites
40+
41+
- Python 3.9+ (standard library only — nothing to `pip install`).
42+
- For the web pages: any modern browser. No server, no build step.
43+
44+
## Run (CLI)
45+
46+
From the `aws-do-eks` shell (or any shell with Python 3):
47+
48+
```bash
49+
cd /eks/deployment/inference/agentic-ai/disagg-calculator/analyze
50+
51+
# Self-test (proves the engine + calibration are wired correctly):
52+
python3 calc.py --selftest
53+
54+
# Score a model from its HuggingFace config.json on a given GPU + workload:
55+
python3 calc.py --config /path/to/config.json --gpu p5en --isl 8192 --osl 1024 --tp 8 --pp 1
56+
```
57+
58+
The output JSON includes the memory fit (weights + KV vs. HBM), the predicted timings
59+
(`prefill_compute`, `kv_transfer`, `decode_step_ITL`), the $/Mtok for agg vs. disagg, and the verdict
60+
(`aggregate` / `disaggregate` / `no-op`) with the reasoning.
61+
62+
## Run (web)
63+
64+
Open `web/index.html` in a browser (or serve the `web/` folder statically). Pick a model preset (or paste a
65+
`config.json`), choose the GPU and workload, and read the verdict. `web/calculator.html` is the same engine
66+
as a single shareable page. The browser pages mirror `analyze/calc.py` exactly — a parity harness in the
67+
source project asserts they agree on a model × workload grid, so the link you share computes what the CLI does.
68+
69+
## How it stays honest (calibration)
70+
71+
First-order math over-predicts throughput and under-predicts latency for hybrid (Mamba + attention) models —
72+
a naive HBM roofline says "fast" while the live system is decode-latency-bound. `calibration.py` records what
73+
we **predicted**, ingests what we **measured** on real GPUs (the seed datapoint is Nemotron-3 Ultra 550B on
74+
p5en/H200), computes the **delta**, and derives a per-(family, metric) **correction factor**. As more live
75+
runs land in `results/calibration/ledger.jsonl`, the corrections converge and the calculator gets more
76+
accurate **without changing the physics**. See [docs/METHODOLOGY.md](docs/METHODOLOGY.md).
77+
78+
## When to use which verdict
79+
80+
See [docs/PRODUCTION-GUIDE.md](docs/PRODUCTION-GUIDE.md) for the rules of thumb. In short:
81+
82+
- **Aggregated replicas** when: short-context chat, prefill cheap relative to decode, cost/throughput-bound,
83+
loose-to-moderate ITL SLO. At the 1P:1D floor, disaggregation buys little but costs ≥2× the GPUs.
84+
- **Disaggregate** when: long input contexts (RAG / agents / code), prefill-heavy, tight TPOT/ITL SLO, and you
85+
can right-size the prefill : decode pool ratio (asymmetric scaling via independent replica counts).
86+
87+
## References
88+
89+
- [do-framework](https://bit.ly/do-framework) · [aws-do-eks](https://bit.ly/do-eks)
90+
- Companion deployment: [Nemotron 3 Ultra 550B](../nemotron/ultra) (agg + disagg manifests)
91+
- [NVIDIA Dynamo](https://github.com/ai-dynamo/dynamo) · [NIXL](https://github.com/ai-dynamo/nixl)

0 commit comments

Comments
 (0)