HBF profiling — where KV belongs when HBM holds a few percent of it
Overview
- What: per-position attention statistics from four sparse-attention models over the same 19 agentic coding traces, each with a full-attention oracle alongside. Not text — every file is a reduction over an attention matrix that was never stored.
- Why: decide which KV tokens live in HBM when HBM fronts a much larger High Bandwidth Flash tier. A query reads ~2,048 keys, not the whole context, but which 2,048 changes every step, so it is measured rather than derived.
- Scope: 19 sessions × 4 models = 76 measurements, 608 shards, 53 GB, exactly 154 files per model directory.
| directory | checkpoint | layers | heads | selector |
|---|---|---|---|---|
deepseek-v3.2-exp/ |
deepseek-ai/DeepSeek-V3.2-Exp |
61 | 128 | 2,048 tokens |
deepseek-v4-flash/ |
deepseek-ai/DeepSeek-V4-Flash |
43 | 64 | 512 C4 slots × 4 |
minimax-m3/ |
MiniMaxAI/MiniMax-M3 |
57 of 60 | 64 | 16 blocks × 128 |
glm-5.2-fp8/ |
zai-org/GLM-5.2-FP8 |
78, 21 with an indexer | 64 | 2,048 tokens |
Constant across the whole repo, so stated once here and in every manifest rather than repeated in paths: 8 × H200 141 GB, TP 8, vendor fp8 checkpoints with no post-hoc quantization, attention=native, DeepGEMM fp8 indexer, hist_row_stride 64.
Two things vary per model. Both are recorded in the manifest, and neither changes what was measured:
gpu_fractionis 0.9 for the first three and 0.78 for GLM-5.2, whose 91.9 GiB of weights per GPU leave a two-sided window: at 0.90 the KV pool claims memory the oracle's own buffers need and the run dies in vLLM's MoE reduction; at 0.72 vLLM cannot cover weights plus activation and refuses to allocate a KV cache at all.- One session is truncated, alone in the repo. FlashMLA's sparse kernel indexes its top-k buffer with int32 and overflows above a single-prefill width of = 58,254 tokens;
django-12713renders to 69,720 under GLM's tokenizer. It is collected at 58,000, truncated from the front, and carriestruncated: true. The other 18 are whole. V3.2 sits under the same ceiling and clears it by 1,536 tokens.
The same transcripts tokenise differently per checkpoint: 10,499–56,718 under V3.2, 10,689–71,322 under M3, 10,739–73,507 under V4, and 10,544–58,000 under GLM-5.2 — where the upper end is that truncation, not the session's own length.
Naming syntax
<model>/oracle_<session_id>.rank<r>.npz r in 0..7, one per tensor-parallel rank
<model>/oracle_manifest.json how each session was collected
<model>/oracle_placement.json the analysis tables — the results
sessions.json which sessions exist under which model
<model>is the checkpoint's HF repo name, lowercased. Nothing else is in the path because nothing else varies.<session_id>is lmcache's own key, verbatim — no prefix stripped, no field reordered. Its structure isswebench__{org}__{repo}-{issue}__{writer}.swebench__django__django-11451__deepseekis not a duplication: the GitHub org and repo share a name, whichsphinx-doc__sphinx-9658shows is not always so.{writer}is who produced the transcript, not the profiled model. Comparing writers compares traces; comparing directories compares models.
- There is no session index. A position in a sorted selection named two different sessions under two trace sources, so the identifier is the id.
- Every model directory holds the same 19 filenames, so a cross-model comparison is the same name in two directories.
Connecting to lmcache
Source corpus: sammshen/lmcache-agentic-traces. The join is the filename, both ways, with no lookup table:
sid = os.path.basename(path)[len("oracle_"):].split(".rank")[0] # file -> lmcache
row = dataset.filter(lambda r: r["session_id"] == sid)
paths = glob.glob(f"{model}/oracle_{row['session_id']}.rank*.npz") # lmcache -> files
- Each manifest records, per session, the
trace_sourceit was drawn from and thetrace_modelthat wrote it — both lmcache columns. - Two selections are present: 8 sessions filtered to
trace_model="deepseek-v3.1"out of shard 4 of 5, and 11 from an unfiltered read of the first hub shard. The latter carrytrace_model: null; that they are allminimax-m2.5is an observation from their ids, not a filter that was applied. - Only the most-accumulated turn of each session is profiled: earlier turns are prefixes of later ones, so one prefill covers every position.
- Token counts differ per model for the same session —
django-11451is 13,568 tokens under V3.2 and 13,567 under V4. Join onsession_id; compare positions only within a directory.
What was profiled
The object of study is the post-softmax attention weight over four axes — layer , head , query , key — causal, so :
with a learned sink belonging to no key position (zero except on V4). The joint is never stored — for one 43K-token V3.2 session it is
so every array is a marginal, and which axes collapse is the whole design. Three bucketings do the collapsing: places a query by its context length against edges ; places a key by distance ; is the message role.
| array | definition | ||||
|---|---|---|---|---|---|
mass |
kept | kept | summed out | kept | |
hist |
kept | kept | bucketed | bucketed | |
dsa_mass |
kept | kept | bucketed | summed over | |
sel_count |
kept | dropped | bucketed | kept | |
hist_by_qrole |
kept | kept | bucketed | bucketed | as hist, split by |
sink_mass |
kept | kept | summed out | — |
- is the model's own selection, the thing the oracle is measured against: per independent selection, with for all four models — reached as 2048×1, 512×4, 16×128 and 2048×1 respectively.
massandsel_countuse every query;histandhist_by_qrolesubsample queries at stride 64.dsa_rowsis the denominator that turnsdsa_massinto a fraction.sel_countcarries no head axis — one score per query-key pair, shared across the heads that consume it.
Why sel_count and not just mass
The simulator bills counts, not mass: 5% of the mass outside HBM could be two tokens or five hundred — indistinguishable in a mass marginal, 250× apart in traffic. For a resident set chosen offline, , and the bucket total is exact:
placement.hbf_read_counts(sel_count, resident_mask, rows=dsa_rows)
Exact: totals and per-bucket means. Not measurable here: the per-step spread of (\(R\) is chosen after the pass), dynamic placement, migration traffic.
Reading it
from huggingface_hub import snapshot_download
from sparse_attention.placement import load_merged
import glob, json
root = snapshot_download("FuriosaAI/hbf-profile", repo_type="dataset",
local_dir="/workspace/hbf-profile") # real files, not symlinks
d = f"{root}/deepseek-v3.2-exp"
for report in json.load(open(f"{d}/oracle_manifest.json"))["sessions"]:
layers, meta = load_merged(sorted(f"{d}/{s}" for s in report["shards"]))
layers[0]["mass"] # [head, position]
- Use
load_merged. The eight shards combine three different ways and getting it wrong is silent and off by an integer factor: head-indexed arrays concatenate,dsa_rowsis replicated, andsel_countneeds distinct selections deduplicated then summed — one independent selection for V3.2, V4 and GLM-5.2, four for M3. - Exact equality is not how replicas are detected: a tie at the -th score breaks differently per rank, so eight copies of one measurement differ in a handful of cells by one.
- GLM-5.2 repeats
sel_countdown the layer axis. IndexShare gives 21 of 78 layers an indexer; the other 57 arrays are bit-identical copies of the nearest preceding indexer layer. Summing all 78 gives exactly what the 21 distinct selections give, and both are right for different questions — HBF read traffic wants all 78, since each layer holds and reads its own KV at those positions, while index bytes and "how often the model chooses" want 21. Nothing in the file marks a layer as shared. oracle_placement.json's index column is not V4's or M3's. Their index is a per-block summary — V4 one 128-dim entry per 4 positions, M3 4×128 per 128-token block — so charging it per token would overstate it 4× and 32×;analyze_placementrefuses, warns, and falls back to V3.2's shape. The byte model is exact for V3.2 and GLM-5.2 only, so an equal-bytes token-vs-block comparison should be quoted from those two. The block-summary cost itself (Quest-style min/max, 2 vectors × 2 bytes) is a modelling assumption applied identically to all four, not a measurement.- Every session here passed
analyze_placement --verify: position count against prompt length, head and layer counts against the manifest, , and against forsel_groups, on every layer that carries a selection. DATASTRUCTURE.mdhas the per-array dtypes and shapes, the rank-merge rules, and the five ways to read this wrongly.
What is not here
- The A100 collection —
QuantTrio/DeepSeek-V3.2-Exp-AWQ, forced dense attention, bf16 reference indexer, 14 sessions over 112 shards — was a different machine and a different checkpoint, not comparable to anything above. Its arrays no longer exist: the bucket that held them,mjbooo/ai-research-hbf, was deleted on 2026-08-06 and now returns 404. Reproducing them needs 8 × A100 again.
- Downloads last month
- 6