|
| 1 | +# DeepSeek Engram Offload — ByteDMD Verification |
| 2 | + |
| 3 | +You are contributing to the **Sutro Group**, a research lab studying energy-efficient AI training. Your task is to verify whether the DeepSeek Engram paper's "<3% offload overhead" claim survives when priced under ByteDMD (byte-level data movement), rather than wall-time. |
| 4 | + |
| 5 | +This is a **two-phase task**. Phase 1 is a paper-reading pass; Phase 2 is a microbenchmark. **Do Phase 1 first** — without the paper's actual `m:M` ratio and prefetch heuristic, Phase 2 models a strawman. |
| 6 | + |
| 7 | +## Project context |
| 8 | + |
| 9 | +Read these files first: |
| 10 | + |
| 11 | +- `DISCOVERIES.md` — what's already known |
| 12 | +- `LAB.md` — lab rules (important: do NOT modify measurement code: `tracker.py`, `cache_tracker.py`, `data.py`, `config.py`, `harness.py`, `fast.py`, `src/bytedmd/`) |
| 13 | +- `docs/research/bytedmd.md` — ByteDMD metric spec |
| 14 | +- `docs/tasks/011-engram-offload-bytedmd.md` — task spec and decision thresholds |
| 15 | +- `findings/_template.md` — expected report format |
| 16 | + |
| 17 | +Key context: |
| 18 | + |
| 19 | +- Our metric: **ByteDMD** — byte-granularity data movement. Reading a value at stack depth `d` costs `ceil(sqrt(d))` per byte. Writes are free. Reference: https://github.com/cybertronai/ByteDMD |
| 20 | +- The central suspicion: offloading to SSD means reads at stack depth ~`1e6`, which should cost `sqrt(1e6) = 1000` per byte — roughly 31× the cost of HBM reads at depth ~`1e3`. A 3% wall-time overhead claim is hard to reconcile with that unless the heuristic genuinely reduces *how many* deep reads happen (not just hides their latency via async prefetch). |
| 21 | + |
| 22 | +## Phase 1 — Paper extraction |
| 23 | + |
| 24 | +### Read the paper carefully |
| 25 | + |
| 26 | +Primary source: https://deepseek.ai/blog/deepseek-engram-v4-architecture |
| 27 | + |
| 28 | +Extract the following with quoted evidence from the paper where possible: |
| 29 | + |
| 30 | +1. **Overhead type** — does the paper report wall-time, FLOPs, energy, or tokens/sec? The "3%" figure applies to which metric specifically? |
| 31 | +2. **`m:M` ratio** — resident set size (in cache/HBM) vs offloaded set size. Can be tokens, KV entries, parameters — whatever the paper offloads. If not stated explicitly, infer from reported configurations. |
| 32 | +3. **Lookup frequency `p`** — fraction of forward-pass lookups that hit the offloaded set. |
| 33 | +4. **Prefetch heuristic** — random? LRU? model-guided prediction of hot entries? Learned routing? Copy-on-access? Describe the mechanism in enough detail to implement a reduced version. |
| 34 | +5. **What "offload" physically means** — CPU RAM? NVMe SSD? Remote tier? All of the above? |
| 35 | + |
| 36 | +### Write `docs/findings/engram-offload-paper-read.md` |
| 37 | + |
| 38 | +Use this structure: |
| 39 | + |
| 40 | +```markdown |
| 41 | +# DeepSeek Engram — Paper Extraction |
| 42 | + |
| 43 | +## Source |
| 44 | +[URL, date accessed, paper version] |
| 45 | + |
| 46 | +## Overhead claim |
| 47 | +[Exact quote. What metric does "3%" refer to?] |
| 48 | + |
| 49 | +## Offload configuration |
| 50 | +- m (resident): [size, units, quoted source] |
| 51 | +- M (offloaded): [size, units, quoted source] |
| 52 | +- m:M ratio: [derived] |
| 53 | +- p (lookup fraction): [quoted or inferred] |
| 54 | +- Physical tier: [CPU RAM / SSD / other] |
| 55 | + |
| 56 | +## Prefetch heuristic |
| 57 | +[2-4 paragraphs describing the mechanism, with code-level detail if possible] |
| 58 | + |
| 59 | +## Gaps |
| 60 | +[What the paper does NOT say that Phase 2 will have to assume. Be explicit.] |
| 61 | + |
| 62 | +## Implications for Phase 2 |
| 63 | +[What values to use for m, M, p, and which heuristic to model] |
| 64 | +``` |
| 65 | + |
| 66 | +**Do NOT proceed to Phase 2 if:** |
| 67 | +- The paper doesn't report concrete `m:M` or `p` (note gaps explicitly; flag for author follow-up) |
| 68 | +- The "overhead" metric is ambiguous (could be any of wall-time / FLOPs / tokens-per-sec) |
| 69 | + |
| 70 | +In that case, stop at Phase 1 and document the gaps. |
| 71 | + |
| 72 | +## Phase 2 — ByteDMD microbenchmark |
| 73 | + |
| 74 | +### Reduced model |
| 75 | + |
| 76 | +Create `experiments/engram-offload/model.py`: |
| 77 | +- Toy attention block: `d_model=64`, `seq_len=128`, 1 head |
| 78 | +- KV memory bank split into two tiers: |
| 79 | + - **resident tier** (size `m`): lives at top of ByteDMD stack (depth ~100-1000) |
| 80 | + - **offloaded tier** (size `M`): forced to depth ~`1e6` via padding/unused writes |
| 81 | +- Pure Python values so ByteDMD's tracer sees every read. No numpy in the inner loop (numpy escapes the tracer, see `docs/research/bytedmd.md`) |
| 82 | + |
| 83 | +### Three variants, same compute |
| 84 | + |
| 85 | +Create `experiments/engram-offload/run.py`: |
| 86 | + |
| 87 | +1. **`resident`** — all KV entries resident (baseline). Every lookup is shallow. |
| 88 | +2. **`offload_naive`** — `M` offloaded entries at depth `1e6`. Every lookup into the offloaded tier pays `sqrt(1e6) = 1000` per byte. No prefetching. |
| 89 | +3. **`offload_prefetch`** — paper's heuristic from Phase 1. Predicted-hot entries promoted to the top of the stack each step, reducing how many reads actually pay the deep cost. |
| 90 | + |
| 91 | +All three process the same `tokens × kv_bank` input and produce the same output (deterministic forward pass; only the memory layout differs). |
| 92 | + |
| 93 | +### Measurement |
| 94 | + |
| 95 | +For each variant: |
| 96 | + |
| 97 | +```python |
| 98 | +from bytedmd import bytedmd, traced_eval |
| 99 | + |
| 100 | +cost = bytedmd(forward, (tokens, kv_bank)) |
| 101 | +trace, out = traced_eval(forward, (tokens, kv_bank)) |
| 102 | +``` |
| 103 | + |
| 104 | +Record: |
| 105 | +- Total ByteDMD cost |
| 106 | +- Cost per token |
| 107 | +- Trace depth distribution (histogram of stack depths at each read) |
| 108 | +- Wall-time with `time.perf_counter()` for the same forward pass |
| 109 | + |
| 110 | +Save to `experiments/engram-offload/results.json`. |
| 111 | + |
| 112 | +### Findings |
| 113 | + |
| 114 | +Create `docs/findings/engram-offload-bytedmd.md` following `findings/_template.md`. Must include: |
| 115 | + |
| 116 | +- **Hypothesis** (from the paper-read + your prior) |
| 117 | +- **Config** (m, M, p, heuristic — reference Phase 1 extraction) |
| 118 | +- **Results table** (all three variants: cost, cost-per-token, wall-time, ratios) |
| 119 | +- **Classification** (WIN / LOSS / INVALID / INCONCLUSIVE / BASELINE) per the decision thresholds in `docs/tasks/011-engram-offload-bytedmd.md` |
| 120 | +- **Analysis** — what worked, what didn't, the surprise |
| 121 | +- **Impact on DISCOVERIES.md** (if any) — does this add to the ByteDMD-vs-wall-time story? |
| 122 | + |
| 123 | +## Decision thresholds |
| 124 | + |
| 125 | +From `docs/tasks/011-engram-offload-bytedmd.md`: |
| 126 | + |
| 127 | +| ByteDMD overhead (prefetch vs resident) | Classification | Action | |
| 128 | +|---|---|---| |
| 129 | +| **2-5×** | WIN for DeepSeek — claim is real | Positive case study; their heuristic genuinely works | |
| 130 | +| **>20×** | LOSS — wall-time gaming | Canonical case study for why SutroYaro uses ByteDMD | |
| 131 | +| **5-20×** | INCONCLUSIVE | Re-run with larger `M` and varying `p`; bandwidth-hiding advantage should shrink as working set grows | |
| 132 | + |
| 133 | +## Rules |
| 134 | + |
| 135 | +- **DO NOT** modify measurement code: `src/bytedmd/`, `src/harness.py`, `tracker.py`, `cache_tracker.py`, `data.py`, `config.py`, `fast.py` |
| 136 | +- **DO NOT** modify `DISCOVERIES.md`, `LAB.md`, `CLAUDE.md`, `CODEX.md`, or any other project configuration. Updates to `DISCOVERIES.md` are added separately via PR after findings review. |
| 137 | +- Pure Python in the inner loop. Numpy escapes ByteDMD; see `docs/research/bytedmd.md`. |
| 138 | +- All findings go under `docs/findings/` (the mkdocs-published location). Do NOT create files in the root-level `findings/` directory. |
| 139 | +- Phase 1 first. Do not start Phase 2 until the paper extraction is written. |
| 140 | + |
| 141 | +## Out of scope |
| 142 | + |
| 143 | +- Re-training or re-implementing the full DeepSeek model. We're testing the metric on a reduced analogue. |
| 144 | +- Modeling PCIe/NVMe energy directly. ByteDMD's `sqrt(depth)` is the proxy. |
| 145 | +- Modifying the ByteDMD tracer to "handle" offloading more cleverly. The metric is the spec; we're measuring against it, not tuning it. |
0 commit comments