mkvn commited on
Commit
6ec9472
·
verified ·
1 Parent(s): 0f55885

Paper, codec, routing traces and measurements

Browse files
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ paper/main.pdf filter=lfs diff=lfs merge=lfs -text
LICENSE-NOTE.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licensing
2
+
3
+ **Code** (`code/`) and **measurement artefacts** (`results/`): Apache License 2.0.
4
+
5
+ **Paper** (`paper/`, including the PDF, LaTeX source and figures): © Kavin Kumar.
6
+ All rights reserved. Redistribution of the paper text is not granted here.
7
+
8
+ This split is deliberate. The accompanying arXiv submission uses the arXiv
9
+ perpetual, non-exclusive license, which does not grant third-party redistribution
10
+ rights; releasing the paper text under a Creative Commons license here would
11
+ contradict that choice and could complicate later journal submission. The code and
12
+ data carry a permissive license so the results can be reproduced and the routing
13
+ traces reused.
README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: paper-reserved-code-apache-2.0
4
+ license_link: https://huggingface.co/datasets/mkvn/quantization-cache-amplification/blob/main/LICENSE-NOTE.md
5
+ pretty_name: Quantization as Cache Amplification
6
+ tags:
7
+ - mixture-of-experts
8
+ - quantization
9
+ - llm-inference
10
+ - systems
11
+ - moe-routing
12
+ - expert-offloading
13
+ language:
14
+ - en
15
+ size_categories:
16
+ - n<1K
17
+ ---
18
+
19
+ # Quantization as Cache Amplification
20
+
21
+ **Trillion-Parameter Mixture-of-Experts Inference on a Commodity Laptop**
22
+
23
+ Kavin Kumar, Neural Metrics
24
+
25
+ 📄 **[Read the paper](paper/main.pdf)** — 11 pages
26
+
27
+ ---
28
+
29
+ ## What this is
30
+
31
+ Weight quantization is usually justified as footprint reduction. This work argues
32
+ that for *offloaded* mixture-of-experts inference that framing misses the leverage.
33
+ The binding resource is not storage capacity but the fraction of expert slots
34
+ resident in DRAM — and storage traffic depends on that fraction through a cache
35
+ hit rate that is both concave and, for recency-based policies, **discontinuous**.
36
+
37
+ The central measured result: a least-recently-used expert cache hits **exactly
38
+ zero** whenever its capacity falls below the `k·L` expert slots a single token
39
+ touches. A token routes to `k` experts in each of `L` layers and revisits none of
40
+ them until the next token — a cyclic reference string, the classical worst case
41
+ for LRU. On real OLMoE-1B-7B traces (`k=8`, `L=16`, so 128 slots) we measure 0.0%
42
+ hit rate at 2%, 5% and 10% capacity, jumping to 25.3% the moment capacity reaches
43
+ 128. Quantization is what carries a system across that threshold.
44
+
45
+ Everything here was measured on one laptop: NVIDIA RTX A500 (4 GB VRAM), 32 GB
46
+ DRAM, consumer NVMe, Windows 11.
47
+
48
+ ## Headline numbers
49
+
50
+ | Result | Value |
51
+ |---|---|
52
+ | LRU hit rate below per-token working set | **0.0%** (measured, all capacities tested) |
53
+ | LRU hit rate at working set (128 slots) | 25.3% |
54
+ | Popularity-pinned hit rate at 10% capacity | 22.9% (vs 0.0% for LRU) |
55
+ | Codec @ 2.01 bits, WikiText-2 PPL | **12.17** (bf16 reference: 8.11) |
56
+ | Frequency-conditioned allocation @ 1.51 bits | 22.02 vs 25.54 uniform — **13.8% better at identical rate** |
57
+ | NVMe random read @ expert-block granularity | 6.01 GB/s (≥ sequential) |
58
+ | GPU device bandwidth | 88.2 GB/s |
59
+
60
+ ### Ablations (all at 1.51 bits, WikiText-2 PPL)
61
+
62
+ | Configuration | PPL |
63
+ |---|---|
64
+ | RVQ + RHT + LDLQ (full codec) | 25.54 |
65
+ | — without block-LDL error feedback | 7,701.98 |
66
+ | — without incoherence processing | 352.10 |
67
+ | RTN uniform @ 2.25 bits (scalar baseline) | 22,793.90 |
68
+
69
+ Both codec components are load-bearing, and error feedback matters more than
70
+ rotation.
71
+
72
+ ## Contents
73
+
74
+ | Path | Contents |
75
+ |---|---|
76
+ | `paper/` | Paper PDF + full LaTeX source and figures |
77
+ | `code/codec.py` | Sub-2-bit codec: randomized Hadamard transform, residual VQ, block-LDL error feedback |
78
+ | `code/quant_model.py` | Layer-sequential quantization + perplexity for OLMoE-1B-7B |
79
+ | `code/trace_routing.py` | Captures per-token expert routing traces |
80
+ | `code/cache_policy.py` | LRU / popularity-pinned / hybrid cache simulation |
81
+ | `code/bench_io.py` | Page-cache-bypassing NVMe, PCIe and DRAM benchmarks |
82
+ | `code/project_1t.py` | 1T reference configuration and throughput roofline |
83
+ | `results/routing_trace.npy` | **Raw routing traces**: `int16[16, 49152, 8]` — the top-8 expert indices selected at every layer for 49,152 held-out tokens |
84
+ | `results/*.json` | Every measurement artefact behind the paper's numbers |
85
+
86
+ ### Using the routing traces
87
+
88
+ ```python
89
+ import numpy as np
90
+ T = np.load("results/routing_trace.npy") # [layers=16, tokens=49152, topk=8]
91
+ # distinct expert slots touched by one token:
92
+ print(T.shape[0] * T.shape[2]) # 128 -> the LRU threshold
93
+ ```
94
+
95
+ Every number in the paper is generated programmatically from `results/` via
96
+ `code/gen_numbers.py` and `code/gen_tables.py`; nothing is transcribed by hand.
97
+
98
+ ## Scope — please read
99
+
100
+ **No trillion-parameter model was executed.** No 1T checkpoint was downloaded,
101
+ quantized, or run. The 1T figures (196 GB at 1.5 bits, 1.81–3.08 tokens/s) are an
102
+ *analytical projection* composing measured host parameters with a cache model
103
+ validated against real 7B-scale routing traces. They are not benchmark results
104
+ and should not be cited as such. The paper's Limitations section states this, and
105
+ identifies the weakest assumption: that the Zipf exponent of expert popularity
106
+ (measured `s = 0.65` at 64 experts/layer) is scale-invariant up to 320
107
+ experts/layer. A full sensitivity curve across the entire hit-rate range is
108
+ included precisely because that assumption cannot be foreclosed.
109
+
110
+ The paper also reports a negative result that constrains any system in this class:
111
+ sustaining the storage stream while materializing fp16 weights would require
112
+ ~116 GB/s of device bandwidth against 88.2 GB/s measured, so dequantization must
113
+ be fused into the GEMM rather than staged through VRAM. No fused kernel was
114
+ implemented here.
115
+
116
+ Quality cost is stated plainly rather than buried: sub-2-bit operation on a
117
+ 1.3B-active-parameter MoE is expensive (8.11 → 22.02 PPL at 1.51 bits), which is
118
+ why the systems analysis is parameterized by rate rather than asserting a single
119
+ favourable operating point.
120
+
121
+ ## Model used
122
+
123
+ [`allenai/OLMoE-1B-7B-0924`](https://huggingface.co/allenai/OLMoE-1B-7B-0924) —
124
+ 6.9B total / 1.3B active, 16 layers, 64 experts/layer, top-8. Evaluation on
125
+ WikiText-2.
code/bench_decode.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Throughput of on-GPU weight reconstruction (codebook gather) and of the
2
+ online activation-side Hadamard transforms, which is what an inference engine
3
+ must sustain to keep the storage stream busy.
4
+ """
5
+ import json, os, sys, time
6
+ import torch
7
+
8
+ sys.path.insert(0, os.path.dirname(__file__))
9
+ import codec
10
+
11
+ DEV = "cuda"
12
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
13
+
14
+
15
+ def bench_decode(stages, nweights=1 << 24, reps=20):
16
+ C = torch.randn(stages, 256, codec.D_SUB, device=DEV, dtype=torch.float16)
17
+ n = nweights // codec.D_SUB
18
+ idx = torch.randint(0, 256, (stages, n), device=DEV, dtype=torch.uint8)
19
+ scale = torch.randn(nweights // 2048, 1, device=DEV, dtype=torch.float16)
20
+
21
+ def run():
22
+ acc = C[0][idx[0].long()]
23
+ for s in range(1, stages):
24
+ acc = acc + C[s][idx[s].long()]
25
+ return (acc.view(-1, 2048) * scale).view(-1)
26
+
27
+ for _ in range(3):
28
+ run()
29
+ torch.cuda.synchronize()
30
+ t0 = time.perf_counter()
31
+ for _ in range(reps):
32
+ run()
33
+ torch.cuda.synchronize()
34
+ dt = (time.perf_counter() - t0) / reps
35
+ packed = nweights * stages * codec.CB_BITS / codec.D_SUB / 8
36
+ return dict(stages=stages, bits=stages * codec.BITS_PER_STAGE,
37
+ weights_per_s=nweights / dt,
38
+ fp16_equiv_GBs=nweights * 2 / dt / 1e9,
39
+ packed_GBs=packed / dt / 1e9)
40
+
41
+
42
+ def bench_hadamard(dim=8192, batch=1, reps=200):
43
+ x = torch.randn(batch, dim, device=DEV)
44
+ for _ in range(3):
45
+ codec._fwht(x)
46
+ torch.cuda.synchronize()
47
+ t0 = time.perf_counter()
48
+ for _ in range(reps):
49
+ codec._fwht(x)
50
+ torch.cuda.synchronize()
51
+ return (time.perf_counter() - t0) / reps * 1e6 # microseconds
52
+
53
+
54
+ def bench_matmul():
55
+ out = {}
56
+ for m, k, n in [(1, 8192, 2048), (32, 8192, 2048), (2048, 8192, 2048)]:
57
+ a = torch.randn(m, k, device=DEV, dtype=torch.float16)
58
+ b = torch.randn(k, n, device=DEV, dtype=torch.float16)
59
+ for _ in range(3):
60
+ a @ b
61
+ torch.cuda.synchronize()
62
+ reps = 50
63
+ t0 = time.perf_counter()
64
+ for _ in range(reps):
65
+ a @ b
66
+ torch.cuda.synchronize()
67
+ dt = (time.perf_counter() - t0) / reps
68
+ out[f"{m}x{k}x{n}"] = dict(tflops=2 * m * k * n / dt / 1e12, ms=dt * 1e3)
69
+ return out
70
+
71
+
72
+ if __name__ == "__main__":
73
+ res = {"decode": [bench_decode(s) for s in [2, 3, 4]],
74
+ "hadamard_us": {str(d): bench_hadamard(d) for d in [2048, 4096, 8192]},
75
+ "matmul": bench_matmul(),
76
+ "gpu": torch.cuda.get_device_name(0)}
77
+ for d in res["decode"]:
78
+ print(f"decode {d['bits']:.1f} bit: {d['weights_per_s']/1e9:.2f} Gweight/s "
79
+ f"= {d['fp16_equiv_GBs']:.1f} GB/s fp16-equivalent, "
80
+ f"{d['packed_GBs']:.2f} GB/s of packed bytes consumed")
81
+ print("hadamard (us):", {k: round(v, 1) for k, v in res["hadamard_us"].items()})
82
+ for k, v in res["matmul"].items():
83
+ print(f"matmul {k}: {v['tflops']:.2f} TFLOP/s")
84
+ json.dump(res, open(os.path.join(RES, "decode_bench.json"), "w"), indent=2)
code/bench_io.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Unbuffered (page-cache-bypassing) NVMe random-read benchmark + PCIe H2D + RAM copy.
2
+
3
+ Uses Win32 CreateFileW with FILE_FLAG_NO_BUFFERING so measurements reflect true
4
+ device behaviour at MoE-expert block granularity rather than page-cache hits.
5
+ """
6
+ import ctypes, ctypes.wintypes as wt
7
+ import json, mmap, os, random, sys, time
8
+ from concurrent.futures import ThreadPoolExecutor
9
+
10
+ GENERIC_READ = 0x80000000
11
+ GENERIC_WRITE = 0x40000000
12
+ FILE_SHARE_READ = 0x00000001
13
+ OPEN_EXISTING = 3
14
+ CREATE_ALWAYS = 2
15
+ FILE_FLAG_NO_BUFFERING = 0x20000000
16
+ FILE_FLAG_WRITE_THROUGH = 0x80000000
17
+ FILE_FLAG_RANDOM_ACCESS = 0x10000000
18
+ FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
19
+ INVALID_HANDLE = ctypes.c_void_p(-1).value
20
+
21
+ k32 = ctypes.WinDLL("kernel32", use_last_error=True)
22
+ k32.CreateFileW.restype = wt.HANDLE
23
+ k32.CreateFileW.argtypes = [wt.LPCWSTR, wt.DWORD, wt.DWORD, ctypes.c_void_p,
24
+ wt.DWORD, wt.DWORD, wt.HANDLE]
25
+ k32.ReadFile.argtypes = [wt.HANDLE, ctypes.c_void_p, wt.DWORD,
26
+ ctypes.POINTER(wt.DWORD), ctypes.c_void_p]
27
+ k32.WriteFile.argtypes = [wt.HANDLE, ctypes.c_void_p, wt.DWORD,
28
+ ctypes.POINTER(wt.DWORD), ctypes.c_void_p]
29
+ k32.SetFilePointerEx.argtypes = [wt.HANDLE, ctypes.c_longlong,
30
+ ctypes.POINTER(ctypes.c_longlong), wt.DWORD]
31
+ k32.CloseHandle.argtypes = [wt.HANDLE]
32
+
33
+ SECTOR = 4096
34
+
35
+
36
+ def aligned_buf(nbytes):
37
+ n = (nbytes + SECTOR - 1) // SECTOR * SECTOR
38
+ mm = mmap.mmap(-1, n)
39
+ ptr = ctypes.addressof(ctypes.c_char.from_buffer(mm))
40
+ assert ptr % SECTOR == 0, "buffer not sector aligned"
41
+ return mm, ptr
42
+
43
+
44
+ def open_unbuffered(path, write=False):
45
+ access = (GENERIC_READ | GENERIC_WRITE) if write else GENERIC_READ
46
+ create = CREATE_ALWAYS if write else OPEN_EXISTING
47
+ flags = FILE_FLAG_NO_BUFFERING | (FILE_FLAG_WRITE_THROUGH if write
48
+ else FILE_FLAG_RANDOM_ACCESS)
49
+ h = k32.CreateFileW(path, access, FILE_SHARE_READ, None, create, flags, None)
50
+ if h == INVALID_HANDLE:
51
+ raise ctypes.WinError(ctypes.get_last_error())
52
+ return h
53
+
54
+
55
+ def make_file(path, size_gb):
56
+ if os.path.exists(path) and os.path.getsize(path) >= size_gb * (1 << 30):
57
+ return
58
+ h = open_unbuffered(path, write=True)
59
+ chunk = 32 << 20
60
+ mm, ptr = aligned_buf(chunk)
61
+ mm.write(os.urandom(1 << 20) * (chunk >> 20))
62
+ written = wt.DWORD(0)
63
+ n = size_gb * (1 << 30) // chunk
64
+ for i in range(n):
65
+ if not k32.WriteFile(h, ptr, chunk, ctypes.byref(written), None):
66
+ raise ctypes.WinError(ctypes.get_last_error())
67
+ k32.CloseHandle(h)
68
+ del mm
69
+
70
+
71
+ def read_worker(path, offsets, block):
72
+ h = open_unbuffered(path)
73
+ mm, ptr = aligned_buf(block)
74
+ got = wt.DWORD(0)
75
+ newpos = ctypes.c_longlong(0)
76
+ total = 0
77
+ for off in offsets:
78
+ k32.SetFilePointerEx(h, ctypes.c_longlong(off), ctypes.byref(newpos), 0)
79
+ if not k32.ReadFile(h, ptr, block, ctypes.byref(got), None):
80
+ raise ctypes.WinError(ctypes.get_last_error())
81
+ total += got.value
82
+ k32.CloseHandle(h)
83
+ del mm
84
+ return total
85
+
86
+
87
+ def bench_random(path, fsize, block, nthreads, target_bytes=1 << 30):
88
+ nreads = max(nthreads * 4, int(target_bytes // block))
89
+ rng = random.Random(1234 + block + nthreads)
90
+ maxoff = (fsize - block) // SECTOR
91
+ offs = [rng.randrange(maxoff) * SECTOR for _ in range(nreads)]
92
+ parts = [offs[i::nthreads] for i in range(nthreads)]
93
+ t0 = time.perf_counter()
94
+ with ThreadPoolExecutor(nthreads) as ex:
95
+ tot = sum(ex.map(lambda o: read_worker(path, o, block), parts))
96
+ dt = time.perf_counter() - t0
97
+ return dict(block_kb=block // 1024, threads=nthreads,
98
+ mb_s=tot / dt / 1e6, iops=nreads / dt,
99
+ lat_ms=dt / nreads * nthreads * 1000)
100
+
101
+
102
+ def bench_sequential(path, fsize):
103
+ h = open_unbuffered(path)
104
+ block = 32 << 20
105
+ mm, ptr = aligned_buf(block)
106
+ got = wt.DWORD(0)
107
+ n = min(64, fsize // block)
108
+ t0 = time.perf_counter()
109
+ for _ in range(n):
110
+ k32.ReadFile(h, ptr, block, ctypes.byref(got), None)
111
+ dt = time.perf_counter() - t0
112
+ k32.CloseHandle(h)
113
+ del mm
114
+ return n * block / dt / 1e6
115
+
116
+
117
+ def bench_pcie():
118
+ import torch
119
+ if not torch.cuda.is_available():
120
+ return {}
121
+ out = {}
122
+ for mb in [1, 4, 16, 64]:
123
+ n = mb * (1 << 20)
124
+ cpu = torch.empty(n, dtype=torch.uint8).pin_memory()
125
+ gpu = torch.empty(n, dtype=torch.uint8, device="cuda")
126
+ for _ in range(3):
127
+ gpu.copy_(cpu, non_blocking=True)
128
+ torch.cuda.synchronize()
129
+ reps = max(5, 512 // mb)
130
+ t0 = time.perf_counter()
131
+ for _ in range(reps):
132
+ gpu.copy_(cpu, non_blocking=True)
133
+ torch.cuda.synchronize()
134
+ dt = time.perf_counter() - t0
135
+ out[f"h2d_{mb}MB_GBs"] = n * reps / dt / 1e9
136
+ del gpu, cpu
137
+ torch.cuda.empty_cache()
138
+ return out
139
+
140
+
141
+ def bench_ram():
142
+ import numpy as np
143
+ a = np.empty(1 << 28, dtype=np.uint8)
144
+ b = np.empty(1 << 28, dtype=np.uint8)
145
+ a[:] = 7
146
+ for _ in range(2):
147
+ b[:] = a
148
+ t0 = time.perf_counter()
149
+ reps = 8
150
+ for _ in range(reps):
151
+ b[:] = a
152
+ dt = time.perf_counter() - t0
153
+ return a.nbytes * reps / dt / 1e9
154
+
155
+
156
+ if __name__ == "__main__":
157
+ scratch = sys.argv[1]
158
+ path = os.path.join(scratch, "iobench.bin")
159
+ FSIZE_GB = 8
160
+ print("creating test file...", flush=True)
161
+ make_file(path, FSIZE_GB)
162
+ fsize = os.path.getsize(path)
163
+ res = {"file_gb": FSIZE_GB, "random": [], "host": {}}
164
+
165
+ res["host"]["seq_read_mb_s"] = bench_sequential(path, fsize)
166
+ print(f"sequential unbuffered read: {res['host']['seq_read_mb_s']:.0f} MB/s", flush=True)
167
+
168
+ for block_kb in [64, 256, 1024, 4096, 16384]:
169
+ for nt in [1, 2, 4, 8]:
170
+ r = bench_random(path, fsize, block_kb * 1024, nt,
171
+ target_bytes=512 << 20)
172
+ res["random"].append(r)
173
+ print(f" {block_kb:>6} KB x {nt} thr: {r['mb_s']:8.1f} MB/s "
174
+ f"{r['iops']:8.1f} IOPS {r['lat_ms']:.3f} ms", flush=True)
175
+
176
+ res["host"]["ram_copy_GBs"] = bench_ram()
177
+ print(f"RAM copy: {res['host']['ram_copy_GBs']:.2f} GB/s", flush=True)
178
+ res["host"].update(bench_pcie())
179
+ for k, v in res["host"].items():
180
+ if k.startswith("h2d"):
181
+ print(f"{k}: {v:.2f} GB/s", flush=True)
182
+
183
+ with open(os.path.join(os.path.dirname(__file__), "..", "results",
184
+ "io_bench.json"), "w") as f:
185
+ json.dump(res, f, indent=2)
186
+ os.remove(path)
187
+ print("saved results/io_bench.json")
code/cache_policy.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Expert-cache policy comparison on the real OLMoE routing trace.
2
+
3
+ Key structural fact: a single token touches k*L distinct expert slots. Under a
4
+ purely recency-based policy this is a cyclic reference pattern, so any cache
5
+ smaller than the per-token working set evicts every entry before it is reused
6
+ and the hit rate collapses to zero. Popularity-pinned policies do not have this
7
+ failure mode, and their hit rate is exactly the popularity mass of the pinned
8
+ set -- which is analytically extrapolable.
9
+ """
10
+ import json, os, sys
11
+ from collections import OrderedDict
12
+ import numpy as np
13
+
14
+ sys.path.insert(0, os.path.dirname(__file__))
15
+ from project_1t import zipf_fit, zipf_pmf
16
+
17
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
18
+
19
+
20
+ def flat_trace(T, E):
21
+ L = T.shape[0]
22
+ return (np.arange(L)[:, None, None] * E + T) # [L, N, K] global ids
23
+
24
+
25
+ def lru_like(F, cap, pinned=None):
26
+ """LRU over the true interleaved access order, optionally with a pinned set
27
+ that is never evicted. F is [L, N, K] of global slot ids."""
28
+ L, N, K = F.shape
29
+ pinned = pinned if pinned is not None else np.zeros(0, dtype=np.int64)
30
+ pin = set(pinned.tolist())
31
+ dyn_cap = max(0, cap - len(pin))
32
+ cache = OrderedDict()
33
+ hits = tot = 0
34
+ for t in range(N):
35
+ for l in range(L):
36
+ for s in F[l, t]:
37
+ s = int(s)
38
+ tot += 1
39
+ if s in pin:
40
+ hits += 1
41
+ continue
42
+ if s in cache:
43
+ hits += 1
44
+ cache.move_to_end(s)
45
+ elif dyn_cap > 0:
46
+ if len(cache) >= dyn_cap:
47
+ cache.popitem(last=False)
48
+ cache[s] = True
49
+ return hits / tot
50
+
51
+
52
+ def static_hits(F, cap, p_global):
53
+ keep = np.zeros(p_global.shape[0], dtype=bool)
54
+ keep[np.argsort(-p_global)[:cap]] = True
55
+ return float(keep[F].mean())
56
+
57
+
58
+ def analytic_static(p, cap):
59
+ """Hit rate of a popularity-pinned cache = mass of the top-`cap` slots."""
60
+ q = np.sort(np.asarray(p, dtype=np.float64))[::-1]
61
+ q = q / q.sum()
62
+ return float(q[:cap].sum())
63
+
64
+
65
+ def main():
66
+ T = np.load(os.path.join(RES, "routing_trace.npy")).astype(np.int64)
67
+ L, N, K = T.shape
68
+ E = int(T.max()) + 1
69
+ freq = json.load(open(os.path.join(RES, "routing_freq.json")))
70
+ Fq = np.array([freq[str(l)] for l in range(L)])
71
+ p_global = (Fq / L).reshape(-1)
72
+ F = flat_trace(T, E)
73
+ n_slots = L * E
74
+ ws = K * L # per-token working set in slots
75
+ s_hat = float(np.median([zipf_fit(Fq[l]) for l in range(L)]))
76
+
77
+ out = {"layers": L, "experts": E, "topk": K, "tokens": int(N),
78
+ "n_slots": n_slots, "token_working_set": ws, "zipf_s": s_hat,
79
+ "ws_frac": ws / n_slots}
80
+ print(f"L={L} E={E} K={K} slots={n_slots} per-token working set={ws} "
81
+ f"({ws/n_slots*100:.1f}% of slots); Zipf s={s_hat:.3f}")
82
+
83
+ # analytic static model validated against the trace
84
+ p_zipf = np.tile(zipf_pmf(E, s_hat) / L, L)
85
+ rows = []
86
+ for frac in [0.02, 0.05, 0.10, 0.125, 0.15, 0.25, 0.40, 0.60, 0.80]:
87
+ cap = max(1, int(frac * n_slots))
88
+ h_lru = lru_like(F, cap)
89
+ h_st = static_hits(F, cap, p_global)
90
+ h_an = analytic_static(p_global, cap)
91
+ h_az = analytic_static(p_zipf, cap)
92
+ npin = int(0.75 * cap)
93
+ pin = np.argsort(-p_global)[:npin]
94
+ h_hy = lru_like(F, cap, pin)
95
+ rows.append(dict(frac=frac, cap=cap, lru=h_lru, static=h_st,
96
+ hybrid=h_hy, analytic_static=h_an, analytic_zipf=h_az))
97
+ print(f" cap {frac*100:5.1f}% ({cap:5d}): LRU {h_lru:.4f} | static {h_st:.4f} "
98
+ f"| hybrid75 {h_hy:.4f} | analytic {h_an:.4f} | analytic-Zipf {h_az:.4f}")
99
+ out["policies"] = rows
100
+ out["mae_analytic_static"] = float(np.mean(
101
+ [abs(r["static"] - r["analytic_static"]) for r in rows]))
102
+ out["mae_analytic_zipf"] = float(np.mean(
103
+ [abs(r["static"] - r["analytic_zipf"]) for r in rows]))
104
+ out["best_gain_hybrid"] = float(max(r["hybrid"] - r["lru"] for r in rows))
105
+ print(f"analytic static model MAE vs measured: "
106
+ f"{out['mae_analytic_static']*100:.2f} pp "
107
+ f"(Zipf-parameterised: {out['mae_analytic_zipf']*100:.2f} pp)")
108
+ json.dump(out, open(os.path.join(RES, "cache_policy.json"), "w"), indent=2)
109
+ print("saved results/cache_policy.json")
110
+
111
+
112
+ if __name__ == "__main__":
113
+ main()
code/codec.py ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Sub-2-bit weight codec: randomised Hadamard incoherence processing followed by
2
+ multi-stage residual vector quantisation on a shared (amortised-free) codebook.
3
+
4
+ Rate is controlled in 0.5 bit/weight steps by the number of residual stages:
5
+ each stage codes a d=16 subvector with an 8-bit index -> 0.5 bit/weight/stage.
6
+ """
7
+ import math
8
+ import torch
9
+
10
+ D_SUB = 16 # subvector dimension
11
+ CB_BITS = 8 # bits per stage index
12
+ CB_SIZE = 1 << CB_BITS
13
+ BITS_PER_STAGE = CB_BITS / D_SUB # 0.5 bit/weight
14
+
15
+
16
+ # ---------------------------------------------------------------- Hadamard
17
+ def _fwht(x):
18
+ """In-place fast Walsh-Hadamard transform over the last dim (power of 2)."""
19
+ n = x.shape[-1]
20
+ assert n & (n - 1) == 0, f"dim {n} not a power of two"
21
+ h = 1
22
+ orig = x.shape
23
+ x = x.reshape(-1, n).clone()
24
+ while h < n:
25
+ x = x.view(-1, n // (2 * h), 2, h)
26
+ a = x[:, :, 0, :].clone()
27
+ b = x[:, :, 1, :].clone()
28
+ x[:, :, 0, :] = a + b
29
+ x[:, :, 1, :] = a - b
30
+ x = x.view(-1, n)
31
+ h *= 2
32
+ return (x / math.sqrt(n)).reshape(orig)
33
+
34
+
35
+ def _signs(n, seed, device, dtype):
36
+ g = torch.Generator(device="cpu").manual_seed(seed)
37
+ return (torch.randint(0, 2, (n,), generator=g).to(device=device,
38
+ dtype=dtype) * 2 - 1)
39
+
40
+
41
+ def rht_forward(W, seed):
42
+ sr = _signs(W.shape[1], seed, W.device, W.dtype)
43
+ sl = _signs(W.shape[0], seed + 1, W.device, W.dtype)
44
+ X = _fwht(W * sr) # right transform
45
+ X = _fwht((X * sl.unsqueeze(1)).t().contiguous()).t().contiguous()
46
+ return X
47
+
48
+
49
+ def rht_inverse(X, seed):
50
+ sr = _signs(X.shape[1], seed, X.device, X.dtype)
51
+ sl = _signs(X.shape[0], seed + 1, X.device, X.dtype)
52
+ W = _fwht(X.t().contiguous()).t().contiguous() * sl.unsqueeze(1)
53
+ W = _fwht(W) * sr
54
+ return W
55
+
56
+
57
+ # ---------------------------------------------------------------- codebook
58
+ _CN = {}
59
+
60
+
61
+ def _cnorm(C):
62
+ k = id(C)
63
+ if k not in _CN or _CN[k][0] is not C:
64
+ _CN[k] = (C, (C * C).sum(1).unsqueeze(0))
65
+ return _CN[k][1]
66
+
67
+
68
+ def _assign(X, C, chunk=1 << 20):
69
+ if X.shape[0] <= chunk:
70
+ return (_cnorm(C) - 2.0 * (X @ C.t())).argmin(1)
71
+ out = torch.empty(X.shape[0], dtype=torch.long, device=X.device)
72
+ Cn = _cnorm(C)
73
+ for s in range(0, X.shape[0], chunk):
74
+ e = min(s + chunk, X.shape[0])
75
+ out[s:e] = (Cn - 2.0 * (X[s:e] @ C.t())).argmin(1)
76
+ return out
77
+
78
+
79
+ def rht_hessian(H, seed):
80
+ """Transform an input-side Hessian into the RHT basis: H' = T^T H T with
81
+ T = diag(s_r) * Hadamard (orthogonal, symmetric Hadamard)."""
82
+ s = _signs(H.shape[0], seed, H.device, H.dtype)
83
+ A = H * s.unsqueeze(0) * s.unsqueeze(1)
84
+ A = _fwht(A)
85
+ A = _fwht(A.t().contiguous()).t().contiguous()
86
+ return A
87
+
88
+
89
+ # ---------------------------------------------------------------- quantiser
90
+ def vq(V, codebooks, stages, refine=1):
91
+ """Multi-stage residual VQ of [N, D_SUB] rows, with optional coordinate
92
+ refinement: each stage index is re-solved against the residual left by all
93
+ the other stages, which recovers part of the greedy-encoding loss."""
94
+ Q = torch.zeros_like(V)
95
+ parts = []
96
+ for s in range(stages):
97
+ C = codebooks[s]
98
+ idx = _assign(V - Q, C)
99
+ p = C[idx]
100
+ parts.append(p)
101
+ Q = Q + p
102
+ for _ in range(refine):
103
+ for s in range(stages):
104
+ Q = Q - parts[s]
105
+ idx = _assign(V - Q, codebooks[s])
106
+ parts[s] = codebooks[s][idx]
107
+ Q = Q + parts[s]
108
+ return Q
109
+
110
+
111
+ def _block_ldl(H, blk):
112
+ """H = L D L^T with L block-unit-lower-triangular (blocks of size blk).
113
+
114
+ The per-block inverses are batched into a single call rather than looped.
115
+ """
116
+ n = H.shape[0]
117
+ C = torch.linalg.cholesky(H)
118
+ K = n // blk
119
+ diag = torch.stack([C[k * blk:(k + 1) * blk, k * blk:(k + 1) * blk]
120
+ for k in range(K)])
121
+ dinv = torch.linalg.inv(diag)
122
+ Binv = torch.zeros_like(C)
123
+ idx = torch.arange(blk, device=H.device)
124
+ for k in range(K):
125
+ Binv[k * blk + idx[:, None], k * blk + idx[None, :]] = dinv[k]
126
+ return C @ Binv
127
+
128
+
129
+ def prepare_hessian(H, seed, rht_on=True, blk=D_SUB, damp=0.01):
130
+ """Rotate, damp and block-LDL-factorise a Hessian once, so that every linear
131
+ sharing this input reuses the factorisation."""
132
+ dev = H.device
133
+ Hf = H.float().clone()
134
+ dead = torch.diag(Hf) <= 0
135
+ if dead.any():
136
+ Hf[dead, dead] = 1.0
137
+ Hf += torch.eye(Hf.shape[0], device=dev) * (damp * torch.diag(Hf).mean())
138
+ Hr = rht_hessian(Hf, seed) if rht_on else Hf
139
+ return _block_ldl(Hr, blk), dead
140
+
141
+
142
+ def ldlq_quantize(W, L, dead, codebooks, stages, seed=1234, rht_on=True,
143
+ blk=D_SUB, refine=0):
144
+ """Hessian-aware quantisation: minimise ||(W-What) X||_F with H = X X^T,
145
+ by block-LDL error feedback over blk-column groups, each group coded by the
146
+ residual VQ. `L`/`dead` come from `prepare_hessian` and are shared by all
147
+ linears reading the same input."""
148
+ dt = W.dtype
149
+ Wf = W.float()
150
+ if dead is not None and dead.any():
151
+ Wf = Wf.clone()
152
+ Wf[:, dead] = 0.0
153
+
154
+ X = rht_forward(Wf, seed) if rht_on else Wf
155
+ scale = X.pow(2).mean(dim=1, keepdim=True).sqrt().clamp_min(1e-8)
156
+ Xn = X / scale
157
+
158
+ o, i = Xn.shape
159
+ K = i // blk
160
+ Q = torch.zeros_like(Xn)
161
+ E = torch.zeros_like(Xn)
162
+ for k in range(K - 1, -1, -1):
163
+ s = slice(k * blk, (k + 1) * blk)
164
+ tgt = Xn[:, s]
165
+ if k + 1 < K:
166
+ tgt = tgt + E[:, (k + 1) * blk:] @ L[(k + 1) * blk:, s]
167
+ Q[:, s] = vq(tgt.reshape(-1, D_SUB), codebooks, stages,
168
+ refine).reshape(o, blk)
169
+ E[:, s] = Xn[:, s] - Q[:, s]
170
+
171
+ Xq = Q * scale
172
+ What = rht_inverse(Xq, seed) if rht_on else Xq
173
+ bits = stages * BITS_PER_STAGE + 16.0 / i
174
+ return What.to(dt), dict(bits=bits, stages=stages)
175
+
176
+
177
+ def quantize(W, codebooks, stages, seed=1234, rht_on=True, refine=1):
178
+ """Quantise [out,in] weight matrix at `stages`*0.5 bits/weight, ignoring
179
+ activation statistics (the data-free ablation of `ldlq_quantize`)."""
180
+ Wf = W.float()
181
+ X = rht_forward(Wf, seed) if rht_on else Wf
182
+ o, i = X.shape
183
+ scale = X.pow(2).mean(dim=1, keepdim=True).sqrt().clamp_min(1e-8)
184
+ Xn = X / scale
185
+ Q = vq(Xn.reshape(-1, D_SUB), codebooks, stages, refine).reshape(o, i)
186
+ Xq = Q * scale
187
+ What = rht_inverse(Xq, seed) if rht_on else Xq
188
+ bits = stages * BITS_PER_STAGE + 16.0 / i # + fp16 row scale
189
+ return What.to(W.dtype), dict(bits=bits, stages=stages)
190
+
191
+
192
+ def build_codebooks(max_stages=6, device="cpu", seed=0):
193
+ """Stage-0 codebook on Gaussian data; each later stage on the residual
194
+ distribution produced by the preceding stages (so shapes adapt)."""
195
+ g = torch.Generator(device="cpu").manual_seed(seed)
196
+ X = torch.randn(400_000, D_SUB, generator=g).to(device)
197
+ cbs, R = [], X.clone()
198
+ for s in range(max_stages):
199
+ C = _kmeans(R, CB_SIZE, iters=35, seed=seed + s, device=device)
200
+ cbs.append(C)
201
+ R = R - C[_assign(R, C)]
202
+ return cbs
203
+
204
+
205
+ def _kmeans(X, size, iters, seed, device):
206
+ g = torch.Generator(device="cpu").manual_seed(seed)
207
+ n = X.shape[0]
208
+ C = X[torch.randperm(n, generator=g)[:size]].clone()
209
+ for _ in range(iters):
210
+ idx = _assign(X, C)
211
+ C_new = torch.zeros_like(C)
212
+ cnt = torch.zeros(size, device=device)
213
+ C_new.index_add_(0, idx, X)
214
+ cnt.index_add_(0, idx, torch.ones(n, device=device))
215
+ dead = cnt == 0
216
+ C_new[~dead] /= cnt[~dead].unsqueeze(1)
217
+ if dead.any():
218
+ C_new[dead] = X[torch.randint(0, n, (int(dead.sum()),),
219
+ generator=g)]
220
+ C = C_new
221
+ return C
222
+
223
+
224
+ # ---------------------------------------------------------------- baseline
225
+ def rtn(W, bits, group=128):
226
+ """Round-to-nearest uniform baseline with per-group asymmetric scales."""
227
+ o, i = W.shape
228
+ Wf = W.float().reshape(o, i // group, group)
229
+ mn = Wf.amin(-1, keepdim=True)
230
+ mx = Wf.amax(-1, keepdim=True)
231
+ n = 2 ** bits - 1
232
+ s = ((mx - mn) / n).clamp_min(1e-9)
233
+ q = ((Wf - mn) / s).round().clamp(0, n)
234
+ Wq = (q * s + mn).reshape(o, i)
235
+ eff = bits + 2 * 16.0 / group
236
+ return Wq.to(W.dtype), dict(bits=eff)
code/data.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io, os
2
+ import torch
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ _CACHE = {}
6
+
7
+
8
+ def _wikitext(split):
9
+ if split in _CACHE:
10
+ return _CACHE[split]
11
+ import pandas as pd
12
+ fn = hf_hub_download("Salesforce/wikitext", repo_type="dataset",
13
+ filename=f"wikitext-2-raw-v1/{split}-00000-of-00001.parquet")
14
+ txt = "\n\n".join(pd.read_parquet(fn)["text"].tolist())
15
+ _CACHE[split] = txt
16
+ return txt
17
+
18
+
19
+ def calib_batches(tok, nsamples, seqlen, seed=0):
20
+ ids = tok(_wikitext("train"), return_tensors="pt").input_ids
21
+ g = torch.Generator().manual_seed(seed)
22
+ out = []
23
+ for _ in range(nsamples):
24
+ i = torch.randint(0, ids.shape[1] - seqlen - 1, (1,), generator=g).item()
25
+ out.append(ids[:, i:i + seqlen])
26
+ return out
27
+
28
+
29
+ def test_tokens(tok, seqlen):
30
+ ids = tok(_wikitext("test"), return_tensors="pt").input_ids
31
+ n = ids.shape[1] // seqlen
32
+ return [ids[:, i * seqlen:(i + 1) * seqlen] for i in range(n)]
code/fast_ops.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Optimised GPU primitives for the decode path.
2
+
3
+ * `fwht_kron` - Walsh-Hadamard transform as two dense GEMMs via the Kronecker
4
+ factorisation H_{ab} = H_a (x) H_b, which replaces O(log n) kernel launches
5
+ with two cuBLAS calls.
6
+ * `decode` - multi-stage codebook reconstruction using int32 index_select
7
+ and a preallocated accumulator, avoiding the int64 promotion and the
8
+ per-stage temporaries of the naive gather.
9
+ """
10
+ import math
11
+ import torch
12
+
13
+ _HCACHE = {}
14
+
15
+
16
+ def hadamard_matrix(n, device, dtype):
17
+ key = (n, device, dtype)
18
+ if key not in _HCACHE:
19
+ H = torch.ones(1, 1, device=device, dtype=dtype)
20
+ while H.shape[0] < n:
21
+ H = torch.cat([torch.cat([H, H], 1), torch.cat([H, -H], 1)], 0)
22
+ _HCACHE[key] = H / math.sqrt(n)
23
+ return _HCACHE[key]
24
+
25
+
26
+ def _factor(n):
27
+ a = 1 << (int(math.log2(n)) // 2)
28
+ return a, n // a
29
+
30
+
31
+ def fwht_kron(x):
32
+ """Normalised WHT over the last dimension (power of two)."""
33
+ n = x.shape[-1]
34
+ a, b = _factor(n)
35
+ Ha = hadamard_matrix(a, x.device, x.dtype) * math.sqrt(a)
36
+ Hb = hadamard_matrix(b, x.device, x.dtype) * math.sqrt(b)
37
+ y = x.reshape(-1, a, b)
38
+ y = Ha @ y @ Hb
39
+ return (y / math.sqrt(n)).reshape(x.shape)
40
+
41
+
42
+ def decode(idx32, codebooks, scale=None, out=None, row=2048):
43
+ """idx32: [stages, N] int32 codebook indices; codebooks: [stages][256, D]."""
44
+ S, N = idx32.shape
45
+ D = codebooks[0].shape[1]
46
+ acc = torch.index_select(codebooks[0], 0, idx32[0])
47
+ for s in range(1, S):
48
+ acc.add_(torch.index_select(codebooks[s], 0, idx32[s]))
49
+ if scale is not None:
50
+ acc = acc.view(-1, row) * scale
51
+ return acc.reshape(-1)
code/fetch.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import sys, time
2
+ from huggingface_hub import snapshot_download
3
+
4
+ repo = sys.argv[1]
5
+ t0 = time.time()
6
+ p = snapshot_download(repo, allow_patterns=["*.json", "*.safetensors", "*.txt", "*.model"],
7
+ max_workers=8)
8
+ print(f"DONE {repo} -> {p} in {time.time()-t0:.0f}s", flush=True)
code/gen_numbers.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Emit paper/numbers.tex so every quantity quoted in the paper is read
2
+ directly from the measurement artefacts rather than transcribed by hand."""
3
+ import glob, json, os, sys
4
+
5
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
6
+ OUT = os.path.join(os.path.dirname(__file__), "..", "paper", "numbers.tex")
7
+
8
+
9
+ def load(n, default=None):
10
+ p = os.path.join(RES, n)
11
+ return json.load(open(p)) if os.path.exists(p) else default
12
+
13
+
14
+ def fmt(x, d=2):
15
+ return f"{x:,.{d}f}"
16
+
17
+
18
+ def main():
19
+ M = {}
20
+ io = load("io_bench.json")
21
+ if io:
22
+ rnd = io["random"]
23
+ best = max(rnd, key=lambda r: r["mb_s"])
24
+ M["SeqRead"] = fmt(io["host"]["seq_read_mb_s"] / 1000, 2)
25
+ M["RandBest"] = fmt(best["mb_s"] / 1000, 2)
26
+ M["RandBestBlock"] = str(best["block_kb"] // 1024)
27
+ M["RandBestThreads"] = str(best["threads"])
28
+ one = [r for r in rnd if r["block_kb"] == 1024 and r["threads"] == 1][0]
29
+ M["RandOneThread"] = fmt(one["mb_s"] / 1000, 2)
30
+ M["RamCopy"] = fmt(io["host"]["ram_copy_GBs"], 1)
31
+ M["PCIe"] = fmt(io["host"]["h2d_16MB_GBs"], 2)
32
+ r64 = [r for r in rnd if r["block_kb"] == 64 and r["threads"] == 1][0]
33
+ M["RandSmall"] = fmt(r64["mb_s"] / 1000, 2)
34
+
35
+ db = load("decode_bench.json")
36
+ if db:
37
+ d = [x for x in db["decode"] if abs(x["bits"] - 1.5) < 1e-6][0]
38
+ M["DecodePacked"] = fmt(d["packed_GBs"], 2)
39
+ M["DecodeFpEquiv"] = fmt(d["fp16_equiv_GBs"], 1)
40
+ M["DecodeGw"] = fmt(d["weights_per_s"] / 1e9, 2)
41
+ M["PeakTflops"] = fmt(max(v["tflops"] for v in db["matmul"].values()), 2)
42
+ M["GPUName"] = db["gpu"]
43
+
44
+ pr = load("projection.json")
45
+ if pr:
46
+ P = pr["params"]
47
+ M["TotalParams"] = fmt(P["total"] / 1e9, 1)
48
+ M["ActiveParams"] = fmt(P["active"] / 1e9, 1)
49
+ M["ExpertSlots"] = f"{int(P['n_slots']):,}"
50
+ amp = {round(a["bits"], 2): a for a in pr["amplification"]}
51
+ M["FootprintFP"] = fmt(amp[16]["model_gb"], 0)
52
+ M["FootprintOnePFive"] = fmt(amp[1.5]["model_gb"], 0)
53
+ M["FootprintTwo"] = fmt(amp[2.0]["model_gb"], 0)
54
+ M["FootprintOne"] = fmt(amp[1.0]["model_gb"], 0)
55
+ M["ExpertMBfp"] = fmt(amp[16]["expert_mb"], 1)
56
+ M["ExpertMB"] = fmt(amp[1.5]["expert_mb"], 2)
57
+ M["CacheFracFP"] = fmt(amp[16]["frac"] * 100, 2)
58
+ M["CacheFrac"] = fmt(amp[1.5]["frac"] * 100, 2)
59
+ M["CacheExpertsFP"] = f"{amp[16]['dram_experts']:,}"
60
+ M["CacheExperts"] = f"{amp[1.5]['dram_experts']:,}"
61
+ M["Amplification"] = fmt(amp[1.5]["frac"] / amp[16]["frac"], 1)
62
+ M["ZipfS"] = fmt(pr["zipf_s"], 2)
63
+ rows = {(r["rate_bits"], r["batch"]): r for r in pr["projection"]}
64
+ b1 = rows[(1.5, 1)]
65
+ M["HitRate"] = fmt(b1["hit_rate"] * 100, 1)
66
+ M["TokSecOne"] = fmt(b1["tok_s"], 2)
67
+ M["MBperTok"] = fmt(b1["bytes_per_token_mb"], 0)
68
+ M["IOatExpert"] = fmt(b1["io_bw_gbs"], 2)
69
+ M["ResidentGB"] = fmt(b1["resident_gb"], 2)
70
+ M["TokSecEight"] = fmt(rows[(1.5, 8)]["tok_s"], 2)
71
+ M["TokSecBatch"] = fmt(rows[(1.5, 32)]["tok_s"], 2)
72
+ M["TokSecTwoBit"] = fmt(rows[(2.0, 1)]["tok_s"], 2)
73
+ M["TokSecOneBit"] = fmt(rows[(1.0, 1)]["tok_s"], 2)
74
+ M["TokSecOneBitBatch"] = fmt(rows[(1.0, 32)]["tok_s"], 2)
75
+ fp16 = rows[(16.0, 1)]
76
+ M["TokSecFP"] = fmt(fp16["tok_s"], 2)
77
+ M["HitRateFP"] = fmt(fp16["hit_rate"] * 100, 1)
78
+ M["SlotsFP"] = f"{fp16['cap_slots']:,}"
79
+ M["SpeedupOverFP"] = fmt(b1["tok_s"] / fp16["tok_s"], 1)
80
+ M["AmpFactor"] = fmt(b1["tok_s"] / fp16["tok_s"] / (16.0 / 1.5), 2)
81
+ M["ReqDecode"] = fmt(b1["io_bw_gbs"], 2)
82
+ if "DecodePacked" in M:
83
+ M["DecodeGap"] = fmt(b1["io_bw_gbs"] / float(M["DecodePacked"]), 0)
84
+ M["FusedBw"] = fmt(b1["io_bw_gbs"] / 1.5 * 16 * 2, 0)
85
+ M["FusedRatio"] = fmt(b1["io_bw_gbs"] / 1.5 * 16 * 2 / 88.2, 2)
86
+ M["ZipfBias"] = fmt(pr.get("zipf_bias_pp", 0), 2)
87
+
88
+ cv = load("cache_validation.json")
89
+ if cv:
90
+ M["TraceTokens"] = f"{cv['tokens']:,}"
91
+ M["MassTopQ"] = fmt(cv["mass_top25pct"] * 100, 1)
92
+ M["ReuseMean"] = fmt(sum(cv["reuse_prev_token"]) / len(cv["reuse_prev_token"]) * 100, 1)
93
+ d = {r["batch"]: r for r in cv["distinct_per_batch"]}
94
+ for b, w_ in [(1, "One"), (8, "Eight"), (32, "ThirtyTwo")]:
95
+ if b in d:
96
+ M["Distinct" + w_] = fmt(d[b]["measured"], 1)
97
+ ws = cv["working_set"]
98
+ for k in ("1", "16", "64", "1024"):
99
+ if k in ws:
100
+ M["WorkSet" + {"1": "One", "16": "Sixteen", "64": "SixtyFour",
101
+ "1024": "Kilo"}[k]] = fmt(ws[k], 1)
102
+
103
+ cp = load("cache_policy.json")
104
+ if cp:
105
+ M["ZipfSmeas"] = fmt(cp["zipf_s"], 2)
106
+ M["TokenWS"] = f"{cp['token_working_set']:,}"
107
+ M["TokenWSFrac"] = fmt(cp["ws_frac"] * 100, 1)
108
+ M["Slots"] = f"{cp['n_slots']:,}"
109
+ M["StaticMAE"] = fmt(cp["mae_analytic_static"] * 100, 2)
110
+ M["ZipfMAE"] = fmt(cp["mae_analytic_zipf"] * 100, 2)
111
+ h = {round(r["frac"], 3): r for r in cp["policies"]}
112
+ for k, name in [(0.02, "Two"), (0.05, "Five"), (0.10, "Ten"),
113
+ (0.125, "Twelve"), (0.15, "Fifteen"), (0.25, "TwentyFive"),
114
+ (0.40, "Forty")]:
115
+ if k in h:
116
+ M["Lru" + name] = fmt(h[k]["lru"] * 100, 1)
117
+ M["Static" + name] = fmt(h[k]["static"] * 100, 1)
118
+ M["Hybrid" + name] = fmt(h[k]["hybrid"] * 100, 1)
119
+
120
+ fp = load("fp16_ppl.json")
121
+ if fp:
122
+ M["PPLfp"] = fmt(fp["ppl"], 2)
123
+
124
+ runs = {}
125
+ for p in glob.glob(os.path.join(RES, "quant_*.json")):
126
+ r = json.load(open(p))
127
+ runs[r["config"]["tag"]] = r
128
+ for tag, name in [("main15", "Ours"), ("main20", "OursTwo"),
129
+ ("main10", "OursOne"), ("main25", "OursTwoFive"),
130
+ ("noldlq15", "NoLdlq"), ("northt15", "NoRht"),
131
+ ("rtn2", "RtnTwo"), ("rtn3", "RtnThree"),
132
+ ("freq15", "Freq")]:
133
+ if tag in runs:
134
+ M["PPL" + name] = fmt(runs[tag]["ppl"], 2)
135
+ M["Bits" + name] = fmt(runs[tag]["avg_bits"], 2)
136
+ M["NumRuns"] = str(len(runs))
137
+
138
+ os.makedirs(os.path.dirname(OUT), exist_ok=True)
139
+ with open(OUT, "w") as f:
140
+ f.write("% auto-generated by code/gen_numbers.py -- do not edit\n")
141
+ for k, v in sorted(M.items()):
142
+ f.write("\\newcommand{\\n%s}{%s}\n" % (k, v))
143
+ print(f"wrote {OUT} with {len(M)} macros")
144
+ for k, v in sorted(M.items()):
145
+ print(f" {k} = {v}")
146
+
147
+
148
+ if __name__ == "__main__":
149
+ main()
code/gen_tables.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate the paper's LaTeX tables directly from the measurement artefacts."""
2
+ import glob, json, os
3
+
4
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
5
+ PAP = os.path.join(os.path.dirname(__file__), "..", "paper")
6
+
7
+
8
+ def load(n, d=None):
9
+ p = os.path.join(RES, n)
10
+ return json.load(open(p)) if os.path.exists(p) else d
11
+
12
+
13
+ def w(name, s):
14
+ open(os.path.join(PAP, name), "w").write(s)
15
+ print("wrote", name)
16
+
17
+
18
+ def tab_quality():
19
+ runs = {}
20
+ for p in glob.glob(os.path.join(RES, "quant_*.json")):
21
+ r = json.load(open(p))
22
+ runs[r["config"]["tag"]] = r
23
+ fp = load("fp16_ppl.json")
24
+ order = [
25
+ ("bf16 (reference)", None, None),
26
+ ("RTN uniform, group 128", "rtn3", "scalar baseline"),
27
+ ("RTN uniform, group 128", "rtn2", "scalar baseline"),
28
+ ("RVQ, data-free", "noldlq15", "no LDLQ"),
29
+ ("RVQ + LDLQ, no rotation", "northt15", "no incoherence proc."),
30
+ ("RVQ + RHT + LDLQ (ours)", "main10", ""),
31
+ ("RVQ + RHT + LDLQ (ours)", "main15", ""),
32
+ ("RVQ + RHT + LDLQ (ours)", "main20", ""),
33
+ ("\\quad + frequency-cond. alloc.", "freq15", "rate-matched"),
34
+ ]
35
+ L = ["\\begin{tabular}{llrr}", "\\toprule",
36
+ "Method & Note & Bits/weight & PPL $\\downarrow$ \\\\", "\\midrule"]
37
+ for name, tag, note in order:
38
+ if tag is None:
39
+ if fp:
40
+ L.append(f"{name} & --- & 16.00 & {fp['ppl']:.2f} \\\\")
41
+ L.append("\\midrule")
42
+ continue
43
+ if tag in runs:
44
+ r = runs[tag]
45
+ L.append(f"{name} & {note} & {r['avg_bits']:.2f} & {r['ppl']:.2f} \\\\")
46
+ L += ["\\bottomrule", "\\end{tabular}"]
47
+ w("tab_quality.tex", "\n".join(L))
48
+
49
+
50
+ def tab_amp():
51
+ pr = load("projection.json")
52
+ if not pr:
53
+ return
54
+ L = ["\\begin{tabular}{rrrrrl}", "\\toprule",
55
+ "Rate & Footprint & Expert & Resident & Cache & Fits \\\\",
56
+ "(bits) & (GB) & (MB) & slots & fraction & 294\\,GB? \\\\", "\\midrule"]
57
+ for a in pr["amplification"]:
58
+ fits = "yes" if a["model_gb"] < 294 else "\\textbf{no}"
59
+ L.append(f"{a['bits']:.1f} & {a['model_gb']:,.0f} & {a['expert_mb']:.2f} & "
60
+ f"{a['dram_experts']:,} & {a['frac']*100:.2f}\\% & {fits} \\\\")
61
+ L += ["\\bottomrule", "\\end{tabular}"]
62
+ w("tab_amp.tex", "\n".join(L))
63
+
64
+
65
+ def tab_proj():
66
+ pr = load("projection.json")
67
+ if not pr:
68
+ return
69
+ ws = pr.get("token_working_set", 512)
70
+ rows = [r for r in pr["projection"] if r["batch"] in (1, 32)]
71
+ L = ["\\begin{tabular}{rrrrrrr}", "\\toprule",
72
+ "Rate & Cache & Recency & Hit & Fetch & \\multicolumn{2}{c}{Tokens/s} \\\\",
73
+ "\\cmidrule(lr){6-7}",
74
+ "(bits) & slots & viable? & rate & MB/token & batch 1 & batch 32 \\\\",
75
+ "\\midrule"]
76
+ seen = set()
77
+ for r in sorted(rows, key=lambda x: -x["rate_bits"]):
78
+ if r["rate_bits"] in seen:
79
+ continue
80
+ seen.add(r["rate_bits"])
81
+ b32 = next(x for x in pr["projection"]
82
+ if x["rate_bits"] == r["rate_bits"] and x["batch"] == 32)
83
+ ok = "yes" if r["cap_slots"] >= ws else "\\textbf{no}"
84
+ L.append(f"{r['rate_bits']:.1f} & {r['cap_slots']:,} & {ok} & "
85
+ f"{r['hit_rate']*100:.1f}\\% & {r['bytes_per_token_mb']:,.0f} & "
86
+ f"{r['tok_s']:.2f} & {b32['tok_s']:.2f} \\\\")
87
+ L += ["\\bottomrule", "\\end{tabular}"]
88
+ w("tab_proj.tex", "\n".join(L))
89
+
90
+
91
+ def tab_policy():
92
+ cp = load("cache_policy.json")
93
+ if not cp:
94
+ return
95
+ ws = cp["token_working_set"]
96
+ L = ["\\begin{tabular}{rrrrrr}", "\\toprule",
97
+ "Capacity & Slots & LRU & Static-freq. & Hybrid & Analytic \\\\",
98
+ "\\midrule"]
99
+ for r in cp["policies"]:
100
+ mark = "$^\\dagger$" if r["cap"] < ws else ""
101
+ L.append(f"{r['frac']*100:.1f}\\%{mark} & {r['cap']:,} & "
102
+ f"{r['lru']*100:.1f}\\% & {r['static']*100:.1f}\\% & "
103
+ f"{r['hybrid']*100:.1f}\\% & {r['analytic_static']*100:.1f}\\% \\\\")
104
+ L += ["\\bottomrule", "\\end{tabular}"]
105
+ w("tab_policy.tex", "\n".join(L))
106
+
107
+
108
+ if __name__ == "__main__":
109
+ for f in [tab_quality, tab_amp, tab_proj, tab_policy]:
110
+ try:
111
+ f()
112
+ except Exception as e:
113
+ print("skip", f.__name__, type(e).__name__, e)
code/make_arxiv.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Build the arXiv submission tarball: LaTeX source + PDF figures only.
3
+ set -eu
4
+ cd "$(dirname "$0")/.."
5
+ OUT=arxiv
6
+ rm -rf $OUT && mkdir -p $OUT/figs
7
+
8
+ cp paper/main.tex paper/numbers.tex $OUT/
9
+ cp paper/tab_*.tex $OUT/
10
+ cp paper/figs/*.pdf $OUT/figs/
11
+
12
+ cd $OUT
13
+ export PATH="$PATH:/c/Users/kavin.kum016/AppData/Local/Programs/MiKTeX/miktex/bin/x64"
14
+ pdflatex -interaction=nonstopmode main.tex > /dev/null 2>&1 || true
15
+ pdflatex -interaction=nonstopmode main.tex > /dev/null 2>&1 || true
16
+ PAGES=$(pdfinfo main.pdf 2>/dev/null | awk '/^Pages/{print $2}')
17
+ if grep -qE "^! " main.log; then
18
+ echo "LaTeX ERRORS:"; grep -A3 -E "^! " main.log | head -30; exit 1
19
+ fi
20
+ UNDEF=$(grep -c "Undefined control sequence" main.log || true)
21
+ echo "compiled OK: ${PAGES:-?} pages, undefined-control-sequence errors: $UNDEF"
22
+
23
+ rm -f main.aux main.log main.out main.toc
24
+ cd ..
25
+ tar -czf arxiv-submission.tar.gz -C $OUT main.tex numbers.tex $(cd $OUT && ls tab_*.tex) figs
26
+ echo "wrote arxiv-submission.tar.gz ($(du -h arxiv-submission.tar.gz | cut -f1))"
27
+ tar -tzf arxiv-submission.tar.gz
code/make_figs.py ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json, os, sys
2
+ import numpy as np
3
+ import matplotlib
4
+ matplotlib.use("Agg")
5
+ import matplotlib.pyplot as plt
6
+
7
+ sys.path.insert(0, os.path.dirname(__file__))
8
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
9
+ FIG = os.path.join(os.path.dirname(__file__), "..", "paper", "figs")
10
+
11
+ plt.rcParams.update({
12
+ "font.size": 8, "axes.labelsize": 8, "axes.titlesize": 8.5,
13
+ "legend.fontsize": 7, "xtick.labelsize": 7, "ytick.labelsize": 7,
14
+ "figure.dpi": 200, "savefig.dpi": 200, "axes.grid": True,
15
+ "grid.alpha": 0.25, "grid.linewidth": 0.5, "lines.linewidth": 1.3,
16
+ "axes.spines.top": False, "axes.spines.right": False,
17
+ "font.family": "serif", "mathtext.fontset": "cm",
18
+ })
19
+ C = ["#1b3a6b", "#c1440e", "#2e7d32", "#6a1b9a", "#c98a00", "#00695c"]
20
+
21
+
22
+ def load(n):
23
+ p = os.path.join(RES, n)
24
+ return json.load(open(p)) if os.path.exists(p) else None
25
+
26
+
27
+ def fig_amplification():
28
+ pr = load("projection.json")
29
+ if not pr:
30
+ return
31
+ a = pr["amplification"]
32
+ bits = [x["bits"] for x in a]
33
+ frac = [x["frac"] * 100 for x in a]
34
+ size = [x["model_gb"] for x in a]
35
+ fig, ax = plt.subplots(1, 2, figsize=(6.9, 2.35))
36
+ ax[0].plot(bits, size, "o-", color=C[0])
37
+ ax[0].axhline(294, ls="--", c=C[1], lw=1)
38
+ ax[0].text(9, 320, "free NVMe (294 GB)", color=C[1], fontsize=6.5)
39
+ ax[0].axhline(24, ls=":", c=C[2], lw=1)
40
+ ax[0].text(9, 27, "usable DRAM (24 GB)", color=C[2], fontsize=6.5)
41
+ ax[0].set_yscale("log"); ax[0].set_xlabel("weight rate (bits/parameter)")
42
+ ax[0].set_ylabel("model footprint (GB)")
43
+ ax[0].set_title("(a) 1.05T-parameter footprint")
44
+ ax[1].plot(bits, frac, "o-", color=C[0])
45
+ ax[1].set_xlabel("weight rate (bits/parameter)")
46
+ ax[1].set_ylabel("expert slots resident in 24 GB (%)")
47
+ ax[1].set_title("(b) DRAM cache capacity")
48
+ for b, f in zip(bits, frac):
49
+ if b in (16, 1.5):
50
+ ax[1].annotate(f"{f:.1f}%", (b, f), textcoords="offset points",
51
+ xytext=(4, 4), fontsize=6.5)
52
+ fig.tight_layout(); fig.savefig(os.path.join(FIG, "amplification.pdf"))
53
+ plt.close(fig)
54
+
55
+
56
+ def fig_io():
57
+ io = load("io_bench.json")
58
+ if not io:
59
+ return
60
+ fig, ax = plt.subplots(figsize=(3.4, 2.35))
61
+ for i, t in enumerate([1, 2, 4, 8]):
62
+ pts = sorted([(r["block_kb"], r["mb_s"] / 1000) for r in io["random"]
63
+ if r["threads"] == t])
64
+ ax.plot([p[0] for p in pts], [p[1] for p in pts], "o-", color=C[i],
65
+ label=f"{t} thread" + ("s" if t > 1 else ""), ms=3)
66
+ ax.set_xscale("log", base=2)
67
+ ax.set_xlabel("read block size (KiB)")
68
+ ax.set_ylabel("random-read bandwidth (GB/s)")
69
+ ax.axhline(io["host"]["seq_read_mb_s"] / 1000, ls="--", c="k", lw=0.9)
70
+ ax.text(80, io["host"]["seq_read_mb_s"] / 1000 + 0.15, "sequential",
71
+ fontsize=6.5)
72
+ ax.legend(loc="lower right")
73
+ fig.tight_layout(); fig.savefig(os.path.join(FIG, "io.pdf")); plt.close(fig)
74
+
75
+
76
+ def fig_cache():
77
+ cp = load("cache_policy.json")
78
+ cv = load("cache_validation.json")
79
+ if not cp or not cv:
80
+ return
81
+ fr = load("routing_freq.json")
82
+ fig, ax = plt.subplots(1, 3, figsize=(6.9, 2.25))
83
+
84
+ F = np.array([fr[str(l)] for l in range(cp["layers"])])
85
+ for l in range(0, cp["layers"], 3):
86
+ ax[0].plot(np.arange(1, F.shape[1] + 1), np.sort(F[l])[::-1],
87
+ color=C[0], alpha=0.35, lw=0.8)
88
+ s = cp["zipf_s"]
89
+ r = np.arange(1, F.shape[1] + 1)
90
+ z = r ** (-s); z = z / z.sum()
91
+ ax[0].plot(r, z, "--", color=C[1], lw=1.4, label=f"Zipf $s$={s:.2f}")
92
+ ax[0].set_xscale("log"); ax[0].set_yscale("log")
93
+ ax[0].set_xlabel("expert rank"); ax[0].set_ylabel("activation probability")
94
+ ax[0].set_title("(a) expert popularity"); ax[0].legend()
95
+
96
+ h = cp["policies"]
97
+ x = [r["frac"] * 100 for r in h]
98
+ ax[1].plot(x, [r["lru"] * 100 for r in h], "o-", color=C[0],
99
+ label="LRU", ms=3)
100
+ ax[1].plot(x, [r["static"] * 100 for r in h], "^-", color=C[2],
101
+ label="popularity-pinned", ms=3)
102
+ ax[1].plot(x, [r["hybrid"] * 100 for r in h], "d-", color=C[4],
103
+ label="hybrid (75% pinned)", ms=3)
104
+ ax[1].plot(x, [r["analytic_static"] * 100 for r in h], "s:", color=C[1],
105
+ label="analytic model", ms=3)
106
+ ws = cp["ws_frac"] * 100
107
+ ax[1].axvline(ws, ls="--", c=C[3], lw=1)
108
+ ax[1].text(ws + 2, 72, "per-token\nworking set", color=C[3], fontsize=6)
109
+ ax[1].set_xlabel("cache capacity (% of expert slots)")
110
+ ax[1].set_ylabel("hit rate (%)")
111
+ ax[1].set_title("(b) replacement policy"); ax[1].legend(loc="lower right")
112
+
113
+ d = cv["distinct_per_batch"]
114
+ ax[2].plot([r["batch"] for r in d], [r["measured"] for r in d], "o-",
115
+ color=C[0], label="measured", ms=3)
116
+ ax[2].plot([r["batch"] for r in d], [r["irm_measured_pop"] for r in d],
117
+ "s--", color=C[1], label="IRM model", ms=3)
118
+ ax[2].set_xscale("log", base=2)
119
+ ax[2].set_xlabel("tokens per batch")
120
+ ax[2].set_ylabel("distinct experts / layer")
121
+ ax[2].set_title("(c) batch amortisation"); ax[2].legend(loc="lower right")
122
+ fig.tight_layout(); fig.savefig(os.path.join(FIG, "cache.pdf")); plt.close(fig)
123
+
124
+
125
+ def fig_quality():
126
+ import glob
127
+ runs = []
128
+ for p in glob.glob(os.path.join(RES, "quant_*.json")):
129
+ runs.append(json.load(open(p)))
130
+ if not runs:
131
+ return
132
+ fig, ax = plt.subplots(figsize=(5.0, 3.05))
133
+ base = [r for r in runs if r["config"].get("tag", "").startswith("rtn")]
134
+ ours = sorted([r for r in runs if r["config"]["tag"].startswith("main")],
135
+ key=lambda r: r["avg_bits"])
136
+ abl = sorted([r for r in runs if r["config"]["tag"].startswith("northt")],
137
+ key=lambda r: r["avg_bits"])
138
+ noldl = sorted([r for r in runs if r["config"]["tag"].startswith("noldlq")],
139
+ key=lambda r: r["avg_bits"])
140
+ freq = sorted([r for r in runs if r["config"]["tag"].startswith("freq")],
141
+ key=lambda r: r["avg_bits"])
142
+ fp = load("fp16_ppl.json")
143
+ for grp, lab, st, c in [(ours, "RVQ + RHT + LDLQ (ours)", "o-", C[0]),
144
+ (freq, "+ frequency-conditioned alloc.", "D-", C[4]),
145
+ (noldl, "no LDLQ (data-free)", "s--", C[1]),
146
+ (abl, "no incoherence processing", "^--", C[2]),
147
+ (base, "RTN uniform", "v:", C[3])]:
148
+ if grp:
149
+ ax.plot([r["avg_bits"] for r in grp], [r["ppl"] for r in grp], st,
150
+ label=lab, color=c, ms=3)
151
+ if fp:
152
+ ax.axhline(fp["ppl"], ls="--", c="k", lw=0.9)
153
+ ax.text(3.32, fp["ppl"] * 1.12, f"bf16 = {fp['ppl']:.2f}", fontsize=6.5,
154
+ ha="right", va="bottom")
155
+ ax.set_yscale("log")
156
+ ax.set_xlim(0.85, 3.45)
157
+ ax.set_xlabel("average weight rate (bits/parameter)")
158
+ ax.set_ylabel("WikiText-2 perplexity")
159
+ ax.legend(loc="upper center", bbox_to_anchor=(0.5, -0.24), ncol=2,
160
+ frameon=False, fontsize=7)
161
+ fig.tight_layout()
162
+ fig.savefig(os.path.join(FIG, "quality.pdf"), bbox_inches="tight")
163
+ plt.close(fig)
164
+
165
+
166
+ def fig_throughput():
167
+ pr = load("projection.json")
168
+ if not pr:
169
+ return
170
+ fig, ax = plt.subplots(1, 2, figsize=(6.9, 2.35))
171
+ s = pr["sensitivity_1p5bit"]
172
+ ax[0].plot([x["hit_rate"] * 100 for x in s], [x["tok_s"] for x in s], "-",
173
+ color=C[0])
174
+ hr = pr["projection"][0]["hit_rate"] * 100
175
+ ax[0].set_xlabel("expert-cache hit rate (%)")
176
+ ax[0].set_ylabel("decode throughput (tokens/s)")
177
+ ax[0].set_yscale("log")
178
+ ax[0].set_title("(a) sensitivity at 1.5 bit, batch 1")
179
+ rows = pr["projection"]
180
+ bits = sorted(set(r["rate_bits"] for r in rows))
181
+ for i, B in enumerate([1, 8, 32]):
182
+ y = [next(r["tok_s"] for r in rows if r["rate_bits"] == b and r["batch"] == B)
183
+ for b in bits]
184
+ ax[1].plot(bits, y, "o-", color=C[i], label=f"batch {B}", ms=3)
185
+ ax[1].set_xlabel("weight rate (bits/parameter)")
186
+ ax[1].set_ylabel("decode throughput (tokens/s)")
187
+ ax[1].set_yscale("log"); ax[1].legend()
188
+ ax[1].set_title("(b) projected 1.05T throughput")
189
+ fig.tight_layout(); fig.savefig(os.path.join(FIG, "throughput.pdf"))
190
+ plt.close(fig)
191
+
192
+
193
+ if __name__ == "__main__":
194
+ os.makedirs(FIG, exist_ok=True)
195
+ for f in [fig_amplification, fig_io, fig_cache, fig_quality, fig_throughput]:
196
+ try:
197
+ f()
198
+ print("ok", f.__name__)
199
+ except Exception as e:
200
+ print("skip", f.__name__, type(e).__name__, e)
code/project_1t.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Projection of a 1T-parameter sparse MoE onto the measured machine.
2
+
3
+ Methodology: every hardware quantity is measured on the host; the expert-cache
4
+ behaviour is modelled with the Che approximation for LRU under an
5
+ independent-reference model, *validated against the real OLMoE trace at E=64*
6
+ before being extrapolated to the 1T configuration's E=320.
7
+ """
8
+ import json, os, sys
9
+ import numpy as np
10
+
11
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
12
+
13
+ # ---------------------------------------------------------------- 1T config
14
+ T1 = dict(name="T1-1046B", layers=64, d_model=8192, n_experts=320, topk=8,
15
+ d_ff_expert=2048, n_shared=1, kv_dim=1024, vocab=129280)
16
+
17
+
18
+ def config_params(c):
19
+ attn = 2 * c["d_model"] ** 2 + 2 * c["d_model"] * c["kv_dim"]
20
+ expert = 3 * c["d_model"] * c["d_ff_expert"]
21
+ per_layer = attn + expert * (c["n_experts"] + c["n_shared"])
22
+ total = per_layer * c["layers"] + 2 * c["vocab"] * c["d_model"]
23
+ active = (attn + expert * (c["topk"] + c["n_shared"])) * c["layers"] \
24
+ + c["vocab"] * c["d_model"]
25
+ return dict(total=total, active=active, expert=expert,
26
+ attn_total=attn * c["layers"],
27
+ shared_total=expert * c["n_shared"] * c["layers"],
28
+ routed_total=expert * c["n_experts"] * c["layers"],
29
+ n_slots=c["n_experts"] * c["layers"])
30
+
31
+
32
+ # ---------------------------------------------------------------- cache model
33
+ def che_hit_rate(p, capacity):
34
+ """LRU hit rate under IRM via Che's approximation."""
35
+ p = np.asarray(p, dtype=np.float64)
36
+ p = p / p.sum()
37
+ if capacity >= len(p):
38
+ return 1.0
39
+ if capacity <= 0:
40
+ return 0.0
41
+ lo, hi = 1e-6, 1e12
42
+ for _ in range(200):
43
+ t = (lo * hi) ** 0.5
44
+ occ = (1.0 - np.exp(-p * t)).sum()
45
+ if occ < capacity:
46
+ lo = t
47
+ else:
48
+ hi = t
49
+ t = (lo * hi) ** 0.5
50
+ return float((p * (1.0 - np.exp(-p * t))).sum())
51
+
52
+
53
+ def zipf_fit(freq):
54
+ """Least-squares Zipf exponent of a measured popularity vector."""
55
+ f = np.sort(np.asarray(freq, dtype=np.float64))[::-1]
56
+ f = f[f > 0]
57
+ r = np.arange(1, len(f) + 1)
58
+ a, _ = np.polyfit(np.log(r), np.log(f), 1)
59
+ return float(-a)
60
+
61
+
62
+ def zipf_pmf(n, s):
63
+ r = np.arange(1, n + 1, dtype=np.float64)
64
+ p = r ** (-s)
65
+ return p / p.sum()
66
+
67
+
68
+ def distinct_per_layer(p, n_draws):
69
+ """Expected distinct experts touched by n_draws independent selections."""
70
+ p = np.asarray(p, dtype=np.float64)
71
+ p = p / p.sum()
72
+ return float((1.0 - (1.0 - p) ** n_draws).sum())
73
+
74
+
75
+ # ---------------------------------------------------------------- throughput
76
+ def io_bandwidth(io, block_bytes, threads=4):
77
+ """Interpolate measured unbuffered random-read bandwidth at a block size."""
78
+ pts = [(r["block_kb"] * 1024, r["mb_s"]) for r in io["random"]
79
+ if r["threads"] == threads]
80
+ pts.sort()
81
+ xs = np.log2([p[0] for p in pts]); ys = [p[1] for p in pts]
82
+ return float(np.interp(np.log2(block_bytes), xs, ys)) * 1e6
83
+
84
+
85
+ def analytic_static(p, cap):
86
+ """Hit rate of a popularity-pinned cache: mass of the top-`cap` slots.
87
+ Exact given the popularity vector (validated to 0.00 pp on the real trace)."""
88
+ q = np.sort(np.asarray(p, dtype=np.float64))[::-1]
89
+ q = q / q.sum()
90
+ return float(q[:min(cap, len(q))].sum())
91
+
92
+
93
+ def hit_rate_for(cfg, cap_slots, zipf_s, bias_pp=0.0):
94
+ """Popularity-pinned hit rate for a configuration with E experts per layer."""
95
+ p = np.tile(zipf_pmf(cfg["n_experts"], zipf_s) / cfg["layers"], cfg["layers"])
96
+ return max(0.0, analytic_static(p, cap_slots) - bias_pp / 100.0)
97
+
98
+
99
+ def project(rate_bits, hit_rate, io, cfg=T1, dram_gb=24.0, vram_gb=3.4,
100
+ batch=1, zipf_s=None):
101
+ P = config_params(cfg)
102
+ Bpp = rate_bits / 8.0
103
+ expert_bytes = P["expert"] * Bpp
104
+ total_bytes = P["total"] * Bpp
105
+
106
+ resident = (P["attn_total"] + P["shared_total"]) * Bpp
107
+ vram_free = max(0.0, vram_gb * 1e9 - resident)
108
+ dram_slots = int(dram_gb * 1e9 // expert_bytes)
109
+ vram_slots = int(vram_free // expert_bytes)
110
+
111
+ bw = io_bandwidth(io, expert_bytes)
112
+ if zipf_s is not None:
113
+ p = zipf_pmf(cfg["n_experts"], zipf_s)
114
+ u = distinct_per_layer(p, cfg["topk"] * batch)
115
+ else:
116
+ u = cfg["topk"] * batch
117
+ fetch_per_token = cfg["layers"] * u * (1.0 - hit_rate) / batch
118
+ bytes_per_token = fetch_per_token * expert_bytes
119
+ t_io = bytes_per_token / bw
120
+ return dict(rate_bits=rate_bits, hit_rate=hit_rate, batch=batch,
121
+ total_gb=total_bytes / 1e9, expert_mb=expert_bytes / 1e6,
122
+ dram_slots=dram_slots, vram_slots=vram_slots,
123
+ cache_frac=dram_slots / P["n_slots"],
124
+ resident_gb=resident / 1e9,
125
+ io_bw_gbs=bw / 1e9,
126
+ bytes_per_token_mb=bytes_per_token / 1e6,
127
+ tok_s=1.0 / t_io if t_io > 0 else float("inf"))
128
+
129
+
130
+ def main():
131
+ io = json.load(open(os.path.join(RES, "io_bench.json")))
132
+ P = config_params(T1)
133
+ out = {"config": T1, "params": {k: float(v) for k, v in P.items()}}
134
+ print(f"{T1['name']}: {P['total']/1e9:.1f}B total, {P['active']/1e9:.1f}B active/token, "
135
+ f"{P['n_slots']} expert slots")
136
+
137
+ # ---- cache-capacity amplification from quantisation
138
+ amp = []
139
+ for r in [16, 4, 3, 2, 1.5, 1.0]:
140
+ eb = P["expert"] * r / 8
141
+ amp.append(dict(bits=r, model_gb=P["total"] * r / 8 / 1e9,
142
+ expert_mb=eb / 1e6,
143
+ dram_experts=int(24e9 // eb),
144
+ frac=int(24e9 // eb) / P["n_slots"]))
145
+ out["amplification"] = amp
146
+ print("\nrate model_GB expert_MB experts_in_24GB cache_frac")
147
+ for a in amp:
148
+ print(f"{a['bits']:>4.1f} {a['model_gb']:8.0f} {a['expert_mb']:9.2f} "
149
+ f"{a['dram_experts']:15d} {a['frac']*100:9.2f}%")
150
+
151
+ # ---- cache policy calibrated on the measured trace, then extrapolated
152
+ cp = json.load(open(os.path.join(RES, "cache_policy.json")))
153
+ s_hat = cp["zipf_s"]
154
+ bias = cp["mae_analytic_zipf"] * 100 # Zipf-fit optimism, in points
155
+ out["zipf_s"] = s_hat
156
+ out["zipf_bias_pp"] = bias
157
+ ws = T1["topk"] * T1["layers"] # per-token working set, in slots
158
+ out["token_working_set"] = ws
159
+ print(f"\nper-token working set: {ws} expert slots; Zipf s={s_hat:.3f}; "
160
+ f"Zipf-fit optimism {bias:.2f} pp")
161
+
162
+ rows = []
163
+ for r in [1.0, 1.5, 2.0, 3.0, 4.0, 16.0]:
164
+ eb = P["expert"] * r / 8
165
+ cap = int(24e9 // eb)
166
+ h = hit_rate_for(T1, cap, s_hat, bias_pp=bias)
167
+ for B in [1, 8, 32]:
168
+ x = project(r, h, io, batch=B, zipf_s=s_hat)
169
+ x["cap_slots"] = cap
170
+ x["lru_viable"] = cap >= ws
171
+ rows.append(x)
172
+ out["projection"] = rows
173
+ print("\nbits batch slots LRUok hit% model_GB expert_MB IO_GB/s MB/token tok/s")
174
+ for x in rows:
175
+ print(f"{x['rate_bits']:>4.1f} {x['batch']:>5d} {x['cap_slots']:>5d} "
176
+ f"{str(x['lru_viable']):>5} {x['hit_rate']*100:4.1f} "
177
+ f"{x['total_gb']:8.0f} {x['expert_mb']:9.2f} {x['io_bw_gbs']:7.2f} "
178
+ f"{x['bytes_per_token_mb']:8.1f} {x['tok_s']:6.2f}")
179
+
180
+ # ---- sensitivity: tok/s across the whole hit-rate range at 1.5 bit
181
+ sens = [project(1.5, float(h), io, batch=1, zipf_s=s_hat)
182
+ for h in np.arange(0.0, 0.99, 0.05)]
183
+ out["sensitivity_1p5bit"] = sens
184
+ json.dump(out, open(os.path.join(RES, "projection.json"), "w"), indent=2)
185
+ print("\nsaved results/projection.json")
186
+
187
+
188
+ if __name__ == "__main__":
189
+ main()
code/quant_model.py ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Sequential layer-wise quantisation of OLMoE-1B-7B with Hessian-aware
2
+ sub-2-bit residual VQ, plus frequency-conditioned bit allocation over experts.
3
+
4
+ Runs on a 4 GB GPU by moving one decoder layer at a time onto the device.
5
+ """
6
+ import argparse, gc, json, os, sys, time
7
+ import torch
8
+ import torch.nn as nn
9
+ from transformers import AutoModelForCausalLM, AutoTokenizer
10
+
11
+ sys.path.insert(0, os.path.dirname(__file__))
12
+ import codec, data
13
+
14
+ MODEL = "allenai/OLMoE-1B-7B-0924"
15
+ DEV = "cuda"
16
+
17
+
18
+ def hkey_of(name):
19
+ """Linears sharing an input share one Hessian."""
20
+ if name.endswith(("q_proj", "k_proj", "v_proj")):
21
+ return "attn.in"
22
+ if name.endswith("o_proj"):
23
+ return "attn.o"
24
+ if ".experts." in name:
25
+ e = name.split(".experts.")[1].split(".")[0]
26
+ if name.endswith("down_proj"):
27
+ return f"e{e}.mid"
28
+ return f"e{e}.in"
29
+ return None
30
+
31
+
32
+ def find_linears(layer):
33
+ out = {}
34
+ for n, m in layer.named_modules():
35
+ if isinstance(m, nn.Linear) and hkey_of(n) is not None:
36
+ out[n] = m
37
+ return out
38
+
39
+
40
+ class Catcher(nn.Module):
41
+ def __init__(self, mod, store):
42
+ super().__init__()
43
+ self.mod, self.store = mod, store
44
+
45
+ def forward(self, hs, **kw):
46
+ self.store["inps"].append(hs.detach().to("cpu"))
47
+ if "kw" not in self.store:
48
+ self.store["kw"] = {k: v for k, v in kw.items()
49
+ if k not in ("past_key_value", "past_key_values")}
50
+ raise RuntimeError("caught")
51
+
52
+
53
+ @torch.no_grad()
54
+ def capture_inputs(model, batches):
55
+ store = {"inps": []}
56
+ model.model.embed_tokens.to(DEV)
57
+ model.model.rotary_emb.to(DEV)
58
+ layers = model.model.layers
59
+ layers[0] = Catcher(layers[0], store)
60
+ for b in batches:
61
+ try:
62
+ model(b.to(DEV))
63
+ except RuntimeError as e:
64
+ if "caught" not in str(e):
65
+ raise
66
+ layers[0] = layers[0].mod
67
+ model.model.embed_tokens.to("cpu")
68
+ torch.cuda.empty_cache()
69
+ return store["inps"], store["kw"]
70
+
71
+
72
+ @torch.no_grad()
73
+ def run_layer(layer, inps, kw, out=None):
74
+ res = out if out is not None else [None] * len(inps)
75
+ for j, x in enumerate(inps):
76
+ y = layer(x.to(DEV), **kw)
77
+ y = y[0] if isinstance(y, tuple) else y
78
+ res[j] = y.detach().to("cpu")
79
+ return res
80
+
81
+
82
+ def alloc_stages(freq, base_stages, spread, n_experts):
83
+ """Frequency-conditioned bit allocation.
84
+
85
+ Experts are ranked by measured activation frequency; the top third get
86
+ +`spread` stages, the bottom third -`spread`, keeping the mean rate equal to
87
+ `base_stages` so the comparison against uniform allocation is rate-matched.
88
+ """
89
+ order = sorted(range(n_experts), key=lambda i: -freq[i])
90
+ st = [base_stages] * n_experts
91
+ k = n_experts // 3
92
+ for i in order[:k]:
93
+ st[i] = base_stages + spread
94
+ for i in order[-k:]:
95
+ st[i] = max(1, base_stages - spread)
96
+ return st
97
+
98
+
99
+ @torch.no_grad()
100
+ def quantize_model(stages, nsamples=32, seqlen=2048, rht_on=True, ldlq_on=True,
101
+ alloc="uniform", spread=1, refine=0, tag="", rtn_bits=None):
102
+ tok = AutoTokenizer.from_pretrained(MODEL)
103
+ model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16,
104
+ low_cpu_mem_usage=True)
105
+ model.eval()
106
+ model.config.use_cache = False
107
+ cbs = codec.build_codebooks(8, device=DEV)
108
+
109
+ batches = data.calib_batches(tok, nsamples, seqlen)
110
+ inps, kw = capture_inputs(model, batches)
111
+ outs = [None] * len(inps)
112
+ layers = model.model.layers
113
+ n_exp = model.config.num_experts
114
+
115
+ freq = load_freq(n_exp, len(layers))
116
+ log = {"layers": [], "bits": [], "params": []}
117
+ t_start = time.time()
118
+
119
+ for li, layer in enumerate(layers):
120
+ t0 = time.time()
121
+ layer.to(DEV)
122
+ lin = find_linears(layer)
123
+ H, cnt = {}, {}
124
+
125
+ reps = {}
126
+ for n, m in lin.items():
127
+ k = hkey_of(n)
128
+ reps.setdefault(k, (n, m))
129
+
130
+ hooks = []
131
+ need_hess = ldlq_on and rtn_bits is None
132
+
133
+ def mk(k, insize):
134
+ H[k] = torch.zeros(insize, insize, device=DEV, dtype=torch.float32)
135
+ cnt[k] = 0
136
+
137
+ def fn(mod, inp, out):
138
+ x = inp[0].detach().reshape(-1, insize).float()
139
+ if x.shape[0]:
140
+ H[k] += x.t() @ x
141
+ cnt[k] += x.shape[0]
142
+ return fn
143
+
144
+ if need_hess:
145
+ for k, (n, m) in reps.items():
146
+ hooks.append(m.register_forward_hook(mk(k, m.in_features)))
147
+ run_layer(layer, inps, kw)
148
+ for h in hooks:
149
+ h.remove()
150
+
151
+ if alloc == "freq":
152
+ st_e = alloc_stages(freq[li], stages, spread, n_exp)
153
+ else:
154
+ st_e = [stages] * n_exp
155
+
156
+ fact = {}
157
+ lbits, lparams = 0.0, 0
158
+ for n, m in lin.items():
159
+ k = hkey_of(n)
160
+ s = stages
161
+ if ".experts." in n:
162
+ s = st_e[int(n.split(".experts.")[1].split(".")[0])]
163
+ W = m.weight.data.to(DEV).float()
164
+ if rtn_bits is not None:
165
+ Wq, info = codec.rtn(W, rtn_bits)
166
+ elif ldlq_on:
167
+ if k not in fact:
168
+ fact[k] = codec.prepare_hessian(H[k], 1234, rht_on=rht_on)
169
+ L, dead = fact[k]
170
+ Wq, info = codec.ldlq_quantize(W, L, dead, cbs, s,
171
+ rht_on=rht_on, refine=refine)
172
+ else:
173
+ Wq, info = codec.quantize(W, cbs, s, rht_on=rht_on, refine=refine)
174
+ m.weight.data = Wq.to(torch.bfloat16)
175
+ lbits += info["bits"] * W.numel()
176
+ lparams += W.numel()
177
+ del W, Wq
178
+ H.clear(); fact.clear()
179
+ torch.cuda.empty_cache()
180
+
181
+ run_layer(layer, inps, kw, outs)
182
+ layer.to("cpu")
183
+ inps, outs = outs, inps
184
+ gc.collect(); torch.cuda.empty_cache()
185
+ log["layers"].append(li)
186
+ log["bits"].append(lbits / lparams)
187
+ log["params"].append(lparams)
188
+ print(f"[{tag}] layer {li:2d} {lbits/lparams:.3f} bits/w "
189
+ f"({time.time()-t0:.0f}s, total {time.time()-t_start:.0f}s)", flush=True)
190
+
191
+ avg_bits = sum(log["bits"][i] * log["params"][i] for i in range(len(log["bits"]))) \
192
+ / sum(log["params"])
193
+ log["avg_bits"] = avg_bits
194
+ log["quantized_params"] = sum(log["params"])
195
+ model.config.use_cache = False
196
+ return model, tok, log
197
+
198
+
199
+ def load_freq(n_exp, n_layers):
200
+ p = os.path.join(os.path.dirname(__file__), "..", "results", "routing_freq.json")
201
+ if os.path.exists(p):
202
+ f = json.load(open(p))
203
+ return [f[str(l)] for l in range(n_layers)]
204
+ return [[1.0] * n_exp for _ in range(n_layers)]
205
+
206
+
207
+ @torch.no_grad()
208
+ def perplexity(model, tok, seqlen=2048, limit=None):
209
+ """Layer-sequential evaluation: each layer is moved to the GPU once and all
210
+ sequences are streamed through it, rather than paging layers per sequence."""
211
+ tests = data.test_tokens(tok, seqlen)
212
+ if limit:
213
+ tests = tests[:limit]
214
+ pos = torch.arange(seqlen, device=DEV).unsqueeze(0)
215
+ model.model.embed_tokens.to(DEV); model.model.rotary_emb.to(DEV)
216
+ hs = [model.model.embed_tokens(b.to(DEV)).cpu() for b in tests]
217
+ pe = model.model.rotary_emb(hs[0].to(DEV), pos)
218
+ model.model.embed_tokens.to("cpu"); torch.cuda.empty_cache()
219
+
220
+ for layer in model.model.layers:
221
+ layer.to(DEV)
222
+ for j in range(len(hs)):
223
+ y = layer(hs[j].to(DEV), attention_mask=None, position_ids=pos,
224
+ position_embeddings=pe)
225
+ hs[j] = (y[0] if isinstance(y, tuple) else y).cpu()
226
+ layer.to("cpu"); torch.cuda.empty_cache()
227
+
228
+ model.model.norm.to(DEV); model.lm_head.to(DEV)
229
+ nll, ntok = 0.0, 0
230
+ for j, b in enumerate(tests):
231
+ logits = model.lm_head(model.model.norm(hs[j].to(DEV))).float()
232
+ loss = torch.nn.functional.cross_entropy(
233
+ logits[:, :-1].reshape(-1, logits.shape[-1]),
234
+ b.to(DEV)[:, 1:].reshape(-1))
235
+ nll += loss.item() * (seqlen - 1)
236
+ ntok += seqlen - 1
237
+ del logits
238
+ torch.cuda.empty_cache()
239
+ return float(torch.exp(torch.tensor(nll / ntok)))
240
+
241
+
242
+ if __name__ == "__main__":
243
+ ap = argparse.ArgumentParser()
244
+ ap.add_argument("--stages", type=int, default=3)
245
+ ap.add_argument("--nsamples", type=int, default=32)
246
+ ap.add_argument("--seqlen", type=int, default=2048)
247
+ ap.add_argument("--no-rht", action="store_true")
248
+ ap.add_argument("--no-ldlq", action="store_true")
249
+ ap.add_argument("--alloc", default="uniform")
250
+ ap.add_argument("--spread", type=int, default=1)
251
+ ap.add_argument("--ppl-limit", type=int, default=24)
252
+ ap.add_argument("--rtn", type=int, default=None)
253
+ ap.add_argument("--fp16", action="store_true")
254
+ ap.add_argument("--tag", default="run")
255
+ a = ap.parse_args()
256
+
257
+ if a.fp16:
258
+ tok = AutoTokenizer.from_pretrained(MODEL)
259
+ m = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16,
260
+ low_cpu_mem_usage=True)
261
+ m.eval(); m.config.use_cache = False
262
+ ppl = perplexity(m, tok, a.seqlen, a.ppl_limit)
263
+ print(f"[fp16] wikitext2 ppl={ppl:.4f}", flush=True)
264
+ json.dump({"ppl": ppl, "seqlen": a.seqlen, "limit": a.ppl_limit},
265
+ open(os.path.join(os.path.dirname(__file__), "..", "results",
266
+ "fp16_ppl.json"), "w"), indent=2)
267
+ sys.exit(0)
268
+
269
+ m, tok, log = quantize_model(a.stages, a.nsamples, a.seqlen,
270
+ rht_on=not a.no_rht, ldlq_on=not a.no_ldlq,
271
+ alloc=a.alloc, spread=a.spread, tag=a.tag,
272
+ rtn_bits=a.rtn)
273
+ t0 = time.time()
274
+ ppl = perplexity(m, tok, a.seqlen, a.ppl_limit)
275
+ log.update(ppl=ppl, config=vars(a), ppl_secs=time.time() - t0)
276
+ print(f"[{a.tag}] avg_bits={log['avg_bits']:.3f} wikitext2 ppl={ppl:.3f}", flush=True)
277
+ out = os.path.join(os.path.dirname(__file__), "..", "results", f"quant_{a.tag}.json")
278
+ json.dump(log, open(out, "w"), indent=2)
279
+ print("saved", out)
code/run_all.sh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Full experiment sweep. Each config reloads the model and quantises it
3
+ # layer-sequentially, then evaluates WikiText-2 perplexity.
4
+ set -u
5
+ cd "$(dirname "$0")/.."
6
+ N=32
7
+ S=2048
8
+ P=20
9
+
10
+ run () {
11
+ echo "=========== $* ==========="
12
+ python -u code/quant_model.py --nsamples $N --seqlen $S --ppl-limit $P "$@" 2>&1 \
13
+ | grep -Ev "^Loading checkpoint|it/s\]$"
14
+ }
15
+
16
+ python -u code/quant_model.py --fp16 --seqlen $S --ppl-limit $P 2>&1 | tail -2
17
+
18
+ run --stages 3 --tag main15
19
+ run --stages 4 --tag main20
20
+ run --stages 2 --tag main10
21
+ run --stages 3 --alloc freq --spread 1 --tag freq15
22
+ run --stages 3 --no-ldlq --tag noldlq15
23
+ run --stages 3 --no-rht --tag northt15
24
+ run --rtn 3 --tag rtn3
25
+ run --rtn 2 --tag rtn2
26
+ echo "ALL RUNS COMPLETE"
code/trace_routing.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Capture real per-token expert routing traces from OLMoE and derive the
2
+ statistics that drive the expert-cache model: activation-frequency skew,
3
+ temporal reuse, and cross-layer predictability.
4
+ """
5
+ import json, os, sys, time
6
+ import numpy as np
7
+ import torch
8
+ from transformers import AutoModelForCausalLM, AutoTokenizer
9
+
10
+ sys.path.insert(0, os.path.dirname(__file__))
11
+ import data
12
+
13
+ MODEL = "allenai/OLMoE-1B-7B-0924"
14
+ DEV = "cuda"
15
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
16
+
17
+
18
+ @torch.no_grad()
19
+ def trace(nseq=24, seqlen=2048):
20
+ tok = AutoTokenizer.from_pretrained(MODEL)
21
+ model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16,
22
+ low_cpu_mem_usage=True)
23
+ model.eval(); model.config.use_cache = False
24
+ L = model.config.num_hidden_layers
25
+ E = model.config.num_experts
26
+ K = model.config.num_experts_per_tok
27
+
28
+ picks = {l: [] for l in range(L)}
29
+ hooks = []
30
+
31
+ def mk(l):
32
+ def fn(mod, inp, out):
33
+ logits = out[0] if isinstance(out, tuple) else out
34
+ top = logits.float().reshape(-1, E).topk(K, dim=-1).indices
35
+ picks[l].append(top.to(torch.int16).cpu())
36
+ return fn
37
+
38
+ for l, layer in enumerate(model.model.layers):
39
+ hooks.append(layer.mlp.gate.register_forward_hook(mk(l)))
40
+
41
+ tests = data.test_tokens(tok, seqlen)[:nseq]
42
+ model.model.embed_tokens.to(DEV); model.model.rotary_emb.to(DEV)
43
+ model.model.norm.to(DEV)
44
+ for i, b in enumerate(tests):
45
+ b = b.to(DEV)
46
+ hs = model.model.embed_tokens(b)
47
+ pos = torch.arange(seqlen, device=DEV).unsqueeze(0)
48
+ pe = model.model.rotary_emb(hs, pos)
49
+ for layer in model.model.layers:
50
+ layer.to(DEV)
51
+ hs = layer(hs, attention_mask=None, position_ids=pos,
52
+ position_embeddings=pe)
53
+ hs = hs[0] if isinstance(hs, tuple) else hs
54
+ layer.to("cpu")
55
+ torch.cuda.empty_cache()
56
+ print(f" seq {i+1}/{len(tests)}", flush=True)
57
+ for h in hooks:
58
+ h.remove()
59
+
60
+ T = torch.stack([torch.cat(picks[l]) for l in range(L)]) # [L, tokens, K]
61
+ np.save(os.path.join(RES, "routing_trace.npy"), T.numpy().astype(np.int16))
62
+ print("trace shape", tuple(T.shape))
63
+ return T.numpy().astype(np.int64), L, E, K
64
+
65
+
66
+ def analyse(T, L, E, K):
67
+ ntok = T.shape[1]
68
+ freq = np.zeros((L, E))
69
+ for l in range(L):
70
+ c = np.bincount(T[l].reshape(-1), minlength=E)
71
+ freq[l] = c / c.sum()
72
+ json.dump({str(l): freq[l].tolist() for l in range(L)},
73
+ open(os.path.join(RES, "routing_freq.json"), "w"))
74
+
75
+ srt = np.sort(freq, axis=1)[:, ::-1]
76
+ cum = np.cumsum(srt, axis=1)
77
+ out = {
78
+ "tokens": int(ntok), "layers": L, "experts": E, "topk": K,
79
+ "gini": [float(gini(freq[l])) for l in range(L)],
80
+ "mass_top25pct": float(cum[:, E // 4 - 1].mean()),
81
+ "mass_top50pct": float(cum[:, E // 2 - 1].mean()),
82
+ "cum_mean": cum.mean(0).tolist(),
83
+ }
84
+
85
+ # temporal reuse: probability an expert used at token t was also used at t-1
86
+ reuse = []
87
+ for l in range(L):
88
+ a = T[l][:-1]; b = T[l][1:]
89
+ m = np.zeros((len(a), E), dtype=bool)
90
+ m[np.arange(len(a))[:, None], a] = True
91
+ hit = m[np.arange(len(b))[:, None], b].sum(1) / K
92
+ reuse.append(float(hit.mean()))
93
+ out["reuse_prev_token"] = reuse
94
+
95
+ # working set: distinct experts over a window of W tokens
96
+ ws = {}
97
+ for W in [1, 4, 16, 64, 256, 1024]:
98
+ vals = []
99
+ for l in range(L):
100
+ n = min(len(T[l]) // W, 64)
101
+ for i in range(n):
102
+ vals.append(len(np.unique(T[l][i * W:(i + 1) * W])))
103
+ ws[W] = float(np.mean(vals))
104
+ out["working_set"] = ws
105
+ json.dump(out, open(os.path.join(RES, "routing_stats.json"), "w"), indent=2)
106
+ return out
107
+
108
+
109
+ def gini(p):
110
+ x = np.sort(p)
111
+ n = len(x)
112
+ return float((2 * np.arange(1, n + 1) - n - 1).dot(x) / (n * x.sum()))
113
+
114
+
115
+ def simulate_cache(T, L, E, K, expert_bytes, cache_bytes, freq=None,
116
+ policy="lru", pin_frac=0.0):
117
+ """Byte-accurate expert cache simulation over the real trace.
118
+
119
+ Returns fraction of expert activations served from cache (hit rate) and
120
+ bytes fetched from storage per token.
121
+ """
122
+ cap = int(cache_bytes // expert_bytes)
123
+ if cap <= 0:
124
+ return 0.0, K * L * expert_bytes
125
+ npin = int(cap * pin_frac)
126
+ pinned = set()
127
+ if npin and freq is not None:
128
+ flat = [(freq[l][e], (l, e)) for l in range(L) for e in range(E)]
129
+ flat.sort(reverse=True)
130
+ pinned = {k for _, k in flat[:npin]}
131
+ from collections import OrderedDict
132
+ cache = OrderedDict((k, True) for k in pinned)
133
+ hits = tot = 0
134
+ ntok = T.shape[1]
135
+ for t in range(ntok):
136
+ for l in range(L):
137
+ for e in T[l, t]:
138
+ key = (l, int(e))
139
+ tot += 1
140
+ if key in cache:
141
+ hits += 1
142
+ if key not in pinned:
143
+ cache.move_to_end(key)
144
+ else:
145
+ cache[key] = True
146
+ while len(cache) > cap:
147
+ k0, _ = next(iter(cache.items()))
148
+ if k0 in pinned:
149
+ cache.move_to_end(k0)
150
+ continue
151
+ cache.popitem(last=False)
152
+ hr = hits / tot
153
+ return hr, (1 - hr) * K * L * expert_bytes
154
+
155
+
156
+ if __name__ == "__main__":
157
+ nseq = int(sys.argv[1]) if len(sys.argv) > 1 else 24
158
+ p = os.path.join(RES, "routing_trace.npy")
159
+ if os.path.exists(p):
160
+ T = np.load(p).astype(np.int64)
161
+ L, E, K = T.shape[0], 64, T.shape[2]
162
+ else:
163
+ T, L, E, K = trace(nseq)
164
+ st = analyse(T, L, E, K)
165
+ print(json.dumps({k: v for k, v in st.items() if k != "cum_mean"}, indent=2))
code/validate_cache.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Validate the analytic expert-cache model against the measured OLMoE trace.
2
+
3
+ Measures true LRU hit rates over the real routing sequence, compares them with
4
+ Che's approximation driven by the measured popularity vector, and fits the Zipf
5
+ exponent that is later used to extrapolate to a 1T-parameter expert count.
6
+ """
7
+ import json, os, sys
8
+ from collections import OrderedDict
9
+ import numpy as np
10
+
11
+ sys.path.insert(0, os.path.dirname(__file__))
12
+ from project_1t import che_hit_rate, zipf_fit, zipf_pmf, distinct_per_layer
13
+
14
+ RES = os.path.join(os.path.dirname(__file__), "..", "results")
15
+
16
+
17
+ def lru_hits(T, cap):
18
+ """True LRU hit rate over the real interleaved (layer, expert) access order."""
19
+ L, N, K = T.shape
20
+ cache = OrderedDict()
21
+ hits = tot = 0
22
+ for t in range(N):
23
+ for l in range(L):
24
+ base = l * 1000
25
+ for e in T[l, t]:
26
+ key = base + int(e)
27
+ tot += 1
28
+ if key in cache:
29
+ hits += 1
30
+ cache.move_to_end(key)
31
+ else:
32
+ if len(cache) >= cap:
33
+ cache.popitem(last=False)
34
+ cache[key] = True
35
+ return hits / tot
36
+
37
+
38
+ def static_freq_hits(T, cap, p_global):
39
+ """Static frequency-pinned cache: keep the globally hottest `cap` slots."""
40
+ L = T.shape[0]
41
+ E = p_global.shape[0] // L
42
+ keep = np.zeros(p_global.shape[0], dtype=bool)
43
+ keep[np.argsort(-p_global)[:cap]] = True
44
+ flat = np.arange(L)[:, None, None] * E + T
45
+ return float(keep[flat].mean())
46
+
47
+
48
+ def main():
49
+ T = np.load(os.path.join(RES, "routing_trace.npy")).astype(np.int64)
50
+ L, N, K = T.shape
51
+ E = int(T.max()) + 1
52
+ stats = json.load(open(os.path.join(RES, "routing_stats.json")))
53
+ freq = json.load(open(os.path.join(RES, "routing_freq.json")))
54
+ F = np.array([freq[str(l)] for l in range(L)]) # [L, E]
55
+
56
+ # global popularity over all (layer, expert) slots
57
+ p_global = (F / L).reshape(-1)
58
+ s_layer = [zipf_fit(F[l]) for l in range(L)]
59
+ s_hat = float(np.median(s_layer))
60
+
61
+ out = {"layers": L, "experts": E, "topk": K, "tokens": int(N),
62
+ "zipf_s": s_hat, "zipf_s_per_layer": s_layer}
63
+ print(f"trace: L={L} E={E} K={K} tokens={N}; Zipf s (median) = {s_hat:.3f}")
64
+
65
+ rows = []
66
+ n_slots = L * E
67
+ for frac in [0.02, 0.05, 0.10, 0.15, 0.25, 0.40, 0.60, 0.80]:
68
+ cap = max(1, int(frac * n_slots))
69
+ h_meas = lru_hits(T, cap)
70
+ h_che = che_hit_rate(p_global, cap)
71
+ h_zipf = che_hit_rate(np.tile(zipf_pmf(E, s_hat) / L, L), cap)
72
+ h_stat = static_freq_hits(T, cap, p_global)
73
+ rows.append(dict(frac=frac, cap=cap, measured=h_meas, static=h_stat,
74
+ che_measured_pop=h_che, che_zipf=h_zipf))
75
+ print(f" cap={frac*100:5.1f}% ({cap:5d} slots): measured LRU {h_meas:.4f} | "
76
+ f"static-freq {h_stat:.4f} | Che(measured pop) {h_che:.4f} | "
77
+ f"Che(Zipf s={s_hat:.2f}) {h_zipf:.4f}")
78
+ out["hit_rates"] = rows
79
+ err = np.array([abs(r["measured"] - r["che_measured_pop"]) for r in rows])
80
+ out["che_mae"] = float(err.mean())
81
+ out["che_zipf_mae"] = float(np.mean([abs(r["measured"] - r["che_zipf"])
82
+ for r in rows]))
83
+ print(f"Che approximation MAE vs measured LRU: {out['che_mae']:.4f} "
84
+ f"(Zipf-parameterised: {out['che_zipf_mae']:.4f})")
85
+
86
+ # distinct experts per batch: measured vs independent-reference prediction
87
+ dpb = []
88
+ rng = np.random.default_rng(0)
89
+ for B in [1, 2, 4, 8, 16, 32, 64]:
90
+ meas = []
91
+ for _ in range(200):
92
+ ts = rng.integers(0, N, size=B)
93
+ l = int(rng.integers(0, L))
94
+ meas.append(len(np.unique(T[l][ts])))
95
+ pred = distinct_per_layer(F.mean(0), K * B)
96
+ pred_z = distinct_per_layer(zipf_pmf(E, s_hat), K * B)
97
+ dpb.append(dict(batch=B, measured=float(np.mean(meas)),
98
+ irm_measured_pop=pred, irm_zipf=pred_z))
99
+ print(f" batch {B:3d}: distinct experts/layer measured {np.mean(meas):6.2f} | "
100
+ f"IRM {pred:6.2f} | IRM-Zipf {pred_z:6.2f}")
101
+ out["distinct_per_batch"] = dpb
102
+ out["reuse_prev_token"] = stats["reuse_prev_token"]
103
+ out["working_set"] = stats["working_set"]
104
+ out["mass_top25pct"] = stats["mass_top25pct"]
105
+ json.dump(out, open(os.path.join(RES, "cache_validation.json"), "w"), indent=2)
106
+ print("saved results/cache_validation.json")
107
+
108
+
109
+ if __name__ == "__main__":
110
+ main()
paper/figs/amplification.pdf ADDED
Binary file (20.3 kB). View file
 
paper/figs/cache.pdf ADDED
Binary file (28.8 kB). View file
 
paper/figs/io.pdf ADDED
Binary file (17.9 kB). View file
 
paper/figs/quality.pdf ADDED
Binary file (19.9 kB). View file
 
paper/figs/throughput.pdf ADDED
Binary file (19.1 kB). View file
 
paper/main.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e487d47e8bbd87e9bda9af16834f06d957059a43ec9b98181a3b99cc6c741853
3
+ size 462650
paper/main.tex ADDED
@@ -0,0 +1,727 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \documentclass[10pt]{article}
2
+ \usepackage[margin=1in]{geometry}
3
+ \usepackage{amsmath,amssymb}
4
+ \usepackage{graphicx}
5
+ \usepackage{booktabs}
6
+ \usepackage{xcolor}
7
+ \usepackage{caption}
8
+ \usepackage[hidelinks]{hyperref}
9
+ \usepackage{microtype}
10
+
11
+ \input{numbers}
12
+
13
+ \captionsetup{font=small,labelfont=bf}
14
+ \setlength{\parskip}{1pt}
15
+
16
+ \title{\bf Quantization as Cache Amplification:\\[2pt]
17
+ Trillion-Parameter Mixture-of-Experts Inference on a Commodity Laptop}
18
+
19
+ \author{Kavin Kumar\\ \small Neural Metrics\\ \small\texttt{kavin.kum016@neuralmetrics.ai}}
20
+ \date{\today}
21
+
22
+ \begin{document}
23
+ \maketitle
24
+
25
+ \begin{abstract}
26
+ Weight quantization is usually justified as footprint reduction. We argue that
27
+ for offloaded mixture-of-experts (MoE) inference this framing misses where the
28
+ leverage actually is. In an offloaded MoE engine the binding resource is not
29
+ storage capacity but the fraction of expert slots resident in DRAM, and storage
30
+ traffic depends on that fraction through a cache hit rate that is both concave
31
+ and, for recency-based policies, \emph{discontinuous}. We show on real routing
32
+ traces that a least-recently-used expert cache collapses to a hit rate of
33
+ \emph{exactly zero} whenever its capacity falls below the $kL$ expert slots a
34
+ single token touches --- a cyclic-reference pathology we measure at precisely
35
+ the predicted threshold. Quantization is what moves a system across that
36
+ threshold, so bits buy throughput super-proportionally to their compression
37
+ ratio.
38
+
39
+ We make this quantitative on one commodity laptop (\nGPUName, 4\,GB VRAM;
40
+ 32\,GB DRAM; consumer NVMe). We contribute (i) a sub-2-bit post-training codec
41
+ combining randomized Hadamard incoherence processing, multi-stage residual
42
+ vector quantization, and block-LDL error feedback; (ii) \emph{frequency-conditioned
43
+ bit allocation}, which spends bits on experts in proportion to measured
44
+ activation frequency and so improves distortion and cache residency together;
45
+ and (iii) an end-to-end roofline in which every hardware term is measured on the
46
+ host and the cache term is modelled analytically and validated against
47
+ \nTraceTokens{} tokens of real OLMoE-1B-7B routing traces.
48
+
49
+ Measured on the host: \nRandBest\,GB/s unbuffered random read at expert-block
50
+ granularity, \nPCIe\,GB/s over PCIe, $88.2$\,GB/s of GPU device bandwidth. On
51
+ OLMoE-1B-7B the codec reaches WikiText-2 perplexity \nPPLOursTwo{} at
52
+ \nBitsOursTwo{} bits and \nPPLFreq{} at \nBitsFreq{} bits against \nPPLfp{} in
53
+ bfloat16; frequency-conditioned allocation improves perplexity by $13.8\%$ over
54
+ uniform allocation at identical rate. We report the quality cost plainly: sub-2-bit
55
+ operation on a $1.3$\,B-active-parameter MoE is expensive, and the systems
56
+ analysis is presented as a function of rate rather than at one favoured point.
57
+ On the traces, expert popularity is Zipfian with exponent $\nZipfSmeas$, and a
58
+ popularity-pinned cache model reproduces measured hit rates to
59
+ \nStaticMAE{} percentage points. Composing these, a $\nTotalParams$\,B-parameter
60
+ MoE occupies \nFootprintOnePFive\,GB at $1.5$ bits --- resident on the laptop's
61
+ free NVMe --- and projects \nTokSecOne{} tokens/s at batch~1 and
62
+ \nTokSecBatch{} tokens/s at batch~32, versus \nTokSecFP{} tokens/s at bfloat16.
63
+ That is a $\nSpeedupOverFP\times$ throughput gain from a $10.7\times$
64
+ compression: $\nAmpFactor\times$ more than compression alone. We also report a
65
+ negative result that constrains any such system: sustaining the storage stream
66
+ while materializing fp16 weights would need ${\sim}\nFusedBw$\,GB/s of device
67
+ bandwidth against $88.2$\,GB/s measured, so dequantization must be fused into
68
+ the GEMM. \textbf{We did not execute a trillion-parameter model}; the 1T figures
69
+ are an analytical projection from measured host parameters and a cache model
70
+ validated at 7B scale, and we report sensitivity across the full hit-rate range.
71
+ \end{abstract}
72
+
73
+ \section{Introduction}
74
+
75
+ A trillion-parameter mixture-of-experts model stored at bfloat16 occupies
76
+ roughly \nFootprintFP\,GB. Models of this class are deployed on multi-GPU
77
+ servers whose aggregate high-bandwidth memory exceeds the entire storage budget
78
+ of a consumer machine, and the reasonable assumption is that such models are out
79
+ of reach for a single laptop.
80
+
81
+ Sparse MoE models complicate that assumption, because the parameters touched by
82
+ any one token are a small fraction of the total. In the reference configuration
83
+ we study (Section~\ref{sec:config}), $\nTotalParams$\,B total parameters yield
84
+ $\nActiveParams$\,B active parameters per token. The other ${\sim}96\%$ of the
85
+ model is idle at any instant; it does not need to be in memory, it needs to be
86
+ \emph{reachable} fast enough. That converts a capacity problem into a
87
+ bandwidth-and-locality problem, which is what caches address.
88
+
89
+ The usual account of quantization here is that it shrinks the model so more of
90
+ it fits. We think that understates it, for a reason specific to the access
91
+ pattern. Let $f$ be the fraction of expert slots that are DRAM-resident. Storage
92
+ traffic per token is governed by $1-h(f)$, and $h$ is not a gentle function. A
93
+ single token routes to $k$ experts in each of $L$ layers, touching $kL$ distinct
94
+ expert slots before any of them is reused. Under a recency-based policy this is
95
+ a cyclic reference pattern: if the cache holds fewer than $kL$ slots, every
96
+ entry is evicted before its next use and the hit rate is not merely low but
97
+ identically zero. We measure exactly this on real OLMoE traces
98
+ (Section~\ref{sec:policy}): LRU hit rate is $\nLruTen\%$ at $10\%$ capacity and
99
+ jumps to $\nLruTwelve\%$ the moment capacity reaches the $\nTokenWS$-slot
100
+ working set.
101
+
102
+ Quantization is the lever that moves a system across that threshold. On our
103
+ host, $24$\,GB of DRAM holds \nSlotsFP{} of \nExpertSlots{} expert slots at
104
+ bfloat16 --- below the $512$-slot per-token working set of our 1T reference
105
+ configuration, so recency-based caching is inoperative --- but
106
+ \nCacheExperts{} slots at $1.5$ bits, comfortably above it. The resulting
107
+ throughput gain, $\nSpeedupOverFP\times$, exceeds the $10.7\times$ compression
108
+ ratio by $\nAmpFactor\times$. We call this \emph{cache amplification}.
109
+
110
+ Our contributions:
111
+ \begin{itemize}\itemsep1pt
112
+ \item \textbf{The cache-amplification framing} (Section~\ref{sec:amp}), with a
113
+ closed form for when compressing weights buys more than its compression ratio,
114
+ and a measured phase transition that is its sharpest instance.
115
+ \item \textbf{A sub-2-bit post-training codec} (Section~\ref{sec:codec}):
116
+ randomized Hadamard incoherence processing, multi-stage residual vector
117
+ quantization on a shared Gaussian codebook, and block-LDL error feedback
118
+ minimizing activation-weighted rather than weight-space error.
119
+ \item \textbf{Frequency-conditioned bit allocation} (Section~\ref{sec:alloc}),
120
+ derived from reverse water-filling over measured expert popularities, which cuts
121
+ perplexity $13.8\%$ at exactly matched average rate.
122
+ \item \textbf{A measured roofline and validated cache model}
123
+ (Sections~\ref{sec:host}--\ref{sec:policy}), including the finding that
124
+ popularity-pinned caching strictly dominates LRU in the capacity regime these
125
+ systems operate in.
126
+ \item \textbf{A projection with explicit sensitivity}
127
+ (Section~\ref{sec:projection}) and a \textbf{negative result} on the
128
+ dequantization path (Section~\ref{sec:decode}).
129
+ \end{itemize}
130
+
131
+ We state the scope plainly. We did not run a trillion-parameter model. We
132
+ measured every component of the system on real hardware with real models,
133
+ validated the component that must be extrapolated, and composed them.
134
+ Section~\ref{sec:limits} is explicit about what this does and does not
135
+ establish.
136
+
137
+ \section{Background and Related Work}
138
+
139
+ \paragraph{Extreme post-training quantization.}
140
+ GPTQ established second-order rounding with error feedback as the standard for
141
+ post-training quantization; AWQ showed activation-scale-aware channel treatment
142
+ matters at low rates. Below $3$ bits scalar quantization becomes
143
+ rate-inefficient and the field moved to vector and lattice codes. QuIP
144
+ introduced incoherence processing --- rotating weights into a basis where
145
+ outliers are suppressed --- and QuIP\# paired randomized Hadamard transforms
146
+ with an $E_8$ lattice codebook. AQLM used additive multi-codebook quantization,
147
+ VPTQ pushed vector PTQ below $2$ bits at $70$--$405$\,B scale, and QTIP replaced
148
+ explicit codebooks with a bitshift trellis to reach high effective dimension.
149
+ BitNet~b1.58 showed ternary weights are viable when trained from scratch. Our
150
+ codec is deliberately conventional in its components: the contribution is the
151
+ allocation policy layered on top and the systems argument it serves, not a new
152
+ rate--distortion frontier.
153
+
154
+ \paragraph{Offloaded and streaming inference.}
155
+ FlexGen scheduled dense-model weights across GPU, CPU and disk; \emph{LLM in a
156
+ Flash} exploited FFN activation sparsity to stream from flash; PowerInfer
157
+ partitioned neurons by activation frequency between CPU and GPU. For MoE,
158
+ Mixtral-offload introduced LRU expert caching with speculative prefetch, and
159
+ MoE-Infinity, EdgeMoE, Pre-gated MoE, Fiddler, MoBiLE and FlashMoE refined
160
+ placement and replacement. Reported hit rates are modest --- existing policies
161
+ achieve $33$--$44\%$ caching $20$ of $60$ experts per layer, and FlashMoE
162
+ reports up to $51\%$ relative improvement over LRU/LFU via learned replacement.
163
+ This literature holds the weight rate fixed and optimizes the policy. We hold
164
+ the policy simple and observe that the rate is the more powerful lever, because
165
+ it changes $f$ rather than $h(\cdot)$ --- and because it can move the system
166
+ across the discontinuity in $h$ entirely.
167
+
168
+ \paragraph{Cache analysis.}
169
+ Che's approximation gives an accurate closed form for LRU hit rates under an
170
+ independent-reference model. We found it \emph{inapplicable} in our regime
171
+ precisely because the MoE access pattern is cyclic rather than independent
172
+ (Section~\ref{sec:policy}), which is itself informative: it is the structure
173
+ that IRM discards that produces the phase transition.
174
+
175
+ \section{Cache Amplification}\label{sec:amp}
176
+
177
+ Consider an MoE with $L$ layers, $E$ routed experts per layer, top-$k$ routing
178
+ and $P_e$ parameters per expert. At weight rate $r$ (bits/parameter) an expert
179
+ occupies $B(r)=P_e r/8$ bytes, so a DRAM budget $M$ holds $M/B(r)$ slots and the
180
+ resident fraction is
181
+ \begin{equation}
182
+ f(r)\;=\;\frac{M}{B(r)\,L\,E}\;=\;\frac{8M}{P_e\,L\,E\,r}\;\propto\;\frac{1}{r}.
183
+ \label{eq:frac}
184
+ \end{equation}
185
+ Storage traffic per generated token is
186
+ \begin{equation}
187
+ T(r)\;=\;L\,k\,\bigl(1-h(f(r))\bigr)\,B(r).
188
+ \label{eq:traffic}
189
+ \end{equation}
190
+ Writing $\rho=r/r_0$ for the compression ratio against a baseline rate $r_0$,
191
+ the naive expectation is $T\propto\rho$. The actual scaling is
192
+ \begin{equation}
193
+ \frac{T(r)}{T(r_0)}\;=\;\rho\cdot\underbrace{\frac{1-h(f_0/\rho)}{1-h(f_0)}}_{\text{amplification}},
194
+ \label{eq:amp}
195
+ \end{equation}
196
+ whose second factor is at most $1$ whenever $h$ is increasing, and strictly
197
+ below $1$ when $f_0$ lies below the knee of $h$. Equivalently, traffic scales as
198
+ $\rho^{\,1+|\eta|}$ with elasticity $\eta=\mathrm{d}\log(1-h)/\mathrm{d}\log f$.
199
+
200
+ \paragraph{The discontinuity.}
201
+ For recency-based replacement the amplification factor is not merely favourable
202
+ but discontinuous. A token touches $kL$ distinct expert slots, one per layer per
203
+ selected expert, and revisits none of them until the next token. This is a
204
+ cyclic reference string of period $kL$, the classical worst case for LRU: with
205
+ capacity $C<kL$, every entry is evicted before reuse and
206
+ \begin{equation}
207
+ h_{\mathrm{LRU}}(C)\;=\;0 \qquad\text{for } C<kL,
208
+ \label{eq:threshold}
209
+ \end{equation}
210
+ independently of how skewed expert popularity is. Since $C\propto 1/r$ by
211
+ Eq.~\ref{eq:frac}, there is a critical rate $r^\star = 8M/(P_e k L)$ below which
212
+ recency-based caching begins to function at all. Section~\ref{sec:policy}
213
+ confirms Eq.~\ref{eq:threshold} on real traces, and Section~\ref{sec:projection}
214
+ shows the 1T reference configuration sits on the inoperative side of $r^\star$
215
+ at bfloat16 and the operative side at $1.5$ bits.
216
+
217
+ Two consequences follow. First, the value of a saved bit is largest exactly
218
+ where systems are most constrained, so the case for extreme rates is stronger in
219
+ offloaded settings than the perplexity--rate curve alone suggests. Second,
220
+ because $h$ depends on \emph{which} experts are resident and not only how many,
221
+ the bit budget should not be spread uniformly.
222
+
223
+ \section{Method}
224
+
225
+ \subsection{Codec}\label{sec:codec}
226
+
227
+ Each linear weight matrix $W\in\mathbb{R}^{o\times i}$ is quantized in three
228
+ stages.
229
+
230
+ \paragraph{Incoherence processing.}
231
+ We apply a two-sided randomized Hadamard transform
232
+ $W'=(D_\ell H_o)\,W\,(D_r H_i)$ with $D_\ell,D_r$ random sign diagonals and
233
+ $H_n$ the normalized Walsh--Hadamard matrix. This suppresses outliers and drives
234
+ subvector statistics toward i.i.d.\ Gaussian, so a single global codebook serves
235
+ every layer of every model and its storage cost amortizes to zero. As $H$ is
236
+ orthogonal and symmetric the rotation is undone at inference time on
237
+ \emph{activations}, not weights:
238
+ $y=Wx=D_\ell H_o\bigl(W'(H_i D_r x)\bigr)$, costing two vector transforms per
239
+ matmul. We implement the transform as two dense GEMMs via the Kronecker
240
+ factorization $H_{ab}=H_a\otimes H_b$, replacing $O(\log n)$ kernel launches
241
+ with two cuBLAS calls; measured $86.7\,\mu$s versus $1930\,\mu$s for a butterfly
242
+ implementation at $n=8192$, a $22\times$ speedup at $10^{-6}$ agreement.
243
+
244
+ \paragraph{Residual vector quantization.}
245
+ Rows of $W'$ are normalized by an fp16 per-row RMS scale and partitioned into
246
+ subvectors of dimension $d=16$. Each subvector is coded by $S$ residual stages,
247
+ each an $8$-bit index into a $256$-entry codebook, giving $0.5$ bits/weight per
248
+ stage and a rate ladder in $0.5$-bit steps. Stage $s$'s codebook is trained by
249
+ $k$-means on the residual distribution left by stages $<s$, so later stages
250
+ adapt to the shrinking residual scale.
251
+
252
+ \paragraph{Block-LDL error feedback.}
253
+ Weight-space error is the wrong objective; what matters is
254
+ $\|(W-\widehat{W})X\|_F$ for calibration activations $X$. With $H=XX^\top$ and
255
+ the block-LDL factorization $H=LDL^\top$ ($L$ block-unit-lower-triangular with
256
+ $d\times d$ blocks), the objective decomposes over column blocks and processing
257
+ them in reverse order with
258
+ \begin{equation}
259
+ \widehat{W}_k \;=\; Q\Bigl(W_k + \textstyle\sum_{j>k} (W_j-\widehat{W}_j)\,L_{jk}\Bigr)
260
+ \label{eq:ldlq}
261
+ \end{equation}
262
+ greedily minimizes it. On synthetic data with a non-trivial Hessian this trades
263
+ higher weight-space error ($0.537$ vs $0.441$ relative Frobenius at $1.5$ bits)
264
+ for a $17$--$18\%$ lower activation-weighted error --- the quantity that governs
265
+ perplexity. Linears sharing an input share one factorization. We quantize layer
266
+ by layer, propagating each layer's \emph{quantized} output forward so later
267
+ layers calibrate against accumulated error.
268
+
269
+ \subsection{Frequency-Conditioned Bit Allocation}\label{sec:alloc}
270
+
271
+ Experts are not equally important: their activation frequencies are heavy-tailed
272
+ (Section~\ref{sec:routing}), and an expert's contribution to expected output
273
+ error is weighted by how often it is selected. With $\pi_e$ the activation
274
+ probability and $D(r)$ the distortion at rate $r$, the rate-constrained problem
275
+ \begin{equation}
276
+ \min_{\{r_e\}}\ \sum_e \pi_e D(r_e)
277
+ \quad\text{s.t.}\quad \tfrac{1}{E}\textstyle\sum_e r_e = \bar r
278
+ \label{eq:alloc}
279
+ \end{equation}
280
+ has the reverse-water-filling solution $r_e = \bar r + \tfrac12\log_2(\pi_e/\tilde\pi)$
281
+ for a Gaussian source with $D(r)\propto 2^{-2r}$, $\tilde\pi$ the geometric mean
282
+ of the $\pi_e$: bits should grow logarithmically in popularity.
283
+
284
+ The systems benefit is separate from and additive to the distortion benefit.
285
+ Cold experts coded at lower rate occupy fewer bytes, so at fixed $M$ more
286
+ \emph{hot} experts become resident: the allocation improves $h$ as well as $D$.
287
+ We implement a rank-based approximation: at average rate $\bar S$ stages, the
288
+ most-activated third of experts in each layer receive $\bar S+1$ stages and the
289
+ least-activated third $\bar S-1$, leaving the mean rate --- and hence the
290
+ comparison against uniform allocation --- exactly rate-matched.
291
+
292
+ \subsection{Execution Model}\label{sec:exec}
293
+
294
+ The engine we analyze keeps rate-invariant always-active parameters resident in
295
+ VRAM --- attention projections and the shared expert, \nResidentGB\,GB at
296
+ $1.5$ bits, within the \nGPUName's $4$\,GB --- and treats routed experts as a
297
+ demand-paged working set backed by NVMe with DRAM as a second-level cache.
298
+ Expert blocks at $1.5$ bits are \nExpertMB\,MB, a granularity at which random
299
+ reads are as fast as sequential (Section~\ref{sec:host}), which is why demand
300
+ paging is viable at all.
301
+
302
+ \section{Experimental Setup}\label{sec:config}
303
+
304
+ \paragraph{Host.}
305
+ All measurements are from one laptop: Intel 12-core CPU, $32$\,GB DDR5
306
+ (\nRamCopy\,GB/s measured copy bandwidth), \nGPUName{} with $4.29$\,GB VRAM
307
+ ($16$ SMs, $88.2$\,GB/s measured device bandwidth, \nPeakTflops\,TFLOP/s peak
308
+ fp16 GEMM), consumer NVMe with $294$\,GB free. Storage is measured through the
309
+ Win32 API with \texttt{FILE\_FLAG\_NO\_BUFFERING}, so results reflect device
310
+ behaviour rather than page-cache hits.
311
+
312
+ \paragraph{Model.}
313
+ Compression and routing experiments use OLMoE-1B-7B-0924 ($6.9$\,B total,
314
+ $1.3$\,B active, $16$ layers, $64$ experts/layer, top-$8$,
315
+ $d_{\text{model}}{=}2048$) --- the largest fully open MoE whose bfloat16 weights
316
+ fit this machine's DRAM, with power-of-two dimensions suited to the Hadamard
317
+ transform. Calibration uses $32$ sequences of $2048$ tokens from WikiText-2
318
+ train; perplexity is on WikiText-2 test at sequence length $2048$. Routing
319
+ traces cover \nTraceTokens{} tokens of held-out text.
320
+
321
+ \paragraph{Reference 1T configuration.}
322
+ \textbf{T1} is a DeepSeek-V3-style configuration scaled to
323
+ $\nTotalParams$\,B parameters: $64$ layers, $d_{\text{model}}{=}8192$, $320$
324
+ routed experts plus $1$ shared expert per layer, top-$8$ routing, expert
325
+ intermediate width $2048$, grouped-query attention with $1024$ KV width, vocab
326
+ $129280$. This gives $\nActiveParams$\,B active parameters per token,
327
+ \nExpertSlots{} routed expert slots and a per-token working set of $512$ slots.
328
+ T1 is a paper configuration, not a released checkpoint; it exists to make the
329
+ accounting concrete.
330
+
331
+ \section{Results}
332
+
333
+ \subsection{Host Roofline}\label{sec:host}
334
+
335
+ Table~\ref{tab:host} and Figure~\ref{fig:io} give measured host limits. The
336
+ important feature is the shape of the random-read curve: at $64$\,KiB blocks a
337
+ single thread sustains \nRandSmall\,GB/s, but by $1$\,MiB the same thread
338
+ reaches \nRandOneThread\,GB/s and with modest concurrency the device saturates
339
+ at \nRandBest\,GB/s --- above its \nSeqRead\,GB/s sequential rate. Expert blocks
340
+ at $1.5$ bits are \nExpertMB\,MB, well inside the flat region.
341
+ \emph{Demand-paging experts costs no measurable random-access penalty}, which is
342
+ the enabling hardware fact for this class of system. PCIe transfer measures
343
+ \nPCIe\,GB/s, closely matching storage, so the two stages pipeline without
344
+ either dominating.
345
+
346
+ \begin{table}[t]
347
+ \centering\small
348
+ \caption{Measured host limits. Storage uses unbuffered, page-cache-bypassing I/O.}
349
+ \label{tab:host}
350
+ \begin{tabular}{lr}
351
+ \toprule
352
+ Quantity & Measured \\
353
+ \midrule
354
+ NVMe sequential read & \nSeqRead\,GB/s \\
355
+ NVMe random read, $64$\,KiB blocks, 1 thread & \nRandSmall\,GB/s \\
356
+ NVMe random read, $1$\,MiB blocks, 1 thread & \nRandOneThread\,GB/s \\
357
+ NVMe random read, peak (\nRandBestBlock\,MiB, \nRandBestThreads\ threads) & \nRandBest\,GB/s \\
358
+ PCIe host$\rightarrow$device ($16$\,MB) & \nPCIe\,GB/s \\
359
+ DRAM copy & \nRamCopy\,GB/s \\
360
+ GPU device copy & $88.2$\,GB/s \\
361
+ GPU peak fp16 GEMM & \nPeakTflops\,TFLOP/s \\
362
+ \bottomrule
363
+ \end{tabular}
364
+ \end{table}
365
+
366
+ \begin{figure}[t]
367
+ \centering
368
+ \includegraphics[width=0.49\textwidth]{figs/io.pdf}
369
+ \caption{Unbuffered random-read bandwidth versus block size. Bandwidth saturates
370
+ by ${\sim}1$\,MiB; the $1.5$-bit expert block (\nExpertMB\,MB) sits in the flat
371
+ region, so demand-paged experts pay no random-access penalty.}
372
+ \label{fig:io}
373
+ \end{figure}
374
+
375
+ \subsection{Compression Quality}\label{sec:quality}
376
+
377
+ Table~\ref{tab:quality} and Figure~\ref{fig:quality} report WikiText-2
378
+ perplexity for OLMoE-1B-7B against a bfloat16 reference of \nPPLfp.
379
+
380
+ \paragraph{Both codec components are load-bearing.}
381
+ At a fixed \nBitsOurs{} bits, removing block-LDL error feedback --- quantizing
382
+ data-free against weight-space error --- moves perplexity from \nPPLOurs{} to
383
+ \nPPLNoLdlq, a factor of ${\sim}300$. Removing incoherence processing while
384
+ keeping error feedback gives \nPPLNoRht, a factor of ${\sim}14$. Neither
385
+ component is optional at this rate, and error feedback matters more than
386
+ rotation. This is consistent with the synthetic result of
387
+ Section~\ref{sec:codec}: weight-space error is a poor proxy, and the methods
388
+ that optimize the activation-weighted objective dominate.
389
+
390
+ \paragraph{Frequency-conditioned allocation.}
391
+ At an identical average rate of \nBitsFreq{} bits, allocating stages by measured
392
+ expert popularity improves perplexity from \nPPLOurs{} to \nPPLFreq{} --- a
393
+ $13.8\%$ reduction for no additional storage. Because the allocation is exactly
394
+ rate-matched by construction, this is attributable to the distribution of bits
395
+ across experts rather than to any change in budget. The systems benefit of
396
+ Section~\ref{sec:alloc} --- smaller cold experts admitting more hot experts into
397
+ cache --- is additional to this and not counted here.
398
+
399
+ \paragraph{Vector quantization dominates scalar rounding.}
400
+ Round-to-nearest with group-128 scales collapses below $3$ bits: \nPPLRtnTwo{}
401
+ at \nBitsRtnTwo{} bits, versus \nPPLOursTwo{} for our codec at a \emph{lower}
402
+ \nBitsOursTwo{} bits. RTN needs \nBitsRtnThree{} bits to reach \nPPLRtnThree,
403
+ i.e.\ ${\sim}1.6\times$ the storage for comparable quality.
404
+
405
+ \paragraph{The cost of going below two bits.}
406
+ We state this plainly rather than burying it. At \nBitsOursTwo{} bits perplexity
407
+ is \nPPLOursTwo{} ($1.5\times$ the bfloat16 reference), which we regard as a
408
+ usable operating point. At \nBitsFreq{} bits it is \nPPLFreq{} ($2.7\times$),
409
+ which is a substantial degradation, and at \nBitsOursOne{} bit the model
410
+ effectively breaks down (\nPPLOursOne). OLMoE-1B-7B has only $1.3$\,B active
411
+ parameters and is a hard case --- published sub-2-bit results are obtained on
412
+ $70$\,B+ dense models with more elaborate codebooks, and quantization tolerance
413
+ generally improves with scale --- but we have not verified that at 1T, and we
414
+ therefore parameterize every systems result in Section~\ref{sec:projection} by
415
+ rate rather than asserting a single operating point.
416
+
417
+ \begin{table}[t]
418
+ \centering\small
419
+ \caption{WikiText-2 perplexity for OLMoE-1B-7B at matched average rates.}
420
+ \label{tab:quality}
421
+ \input{tab_quality}
422
+ \end{table}
423
+
424
+ \begin{figure}[t]
425
+ \centering
426
+ \includegraphics[width=0.55\textwidth]{figs/quality.pdf}
427
+ \caption{Rate--perplexity for OLMoE-1B-7B. Each ablation removes one codec
428
+ component at matched average rate.}
429
+ \label{fig:quality}
430
+ \end{figure}
431
+
432
+ \subsection{Routing Statistics}\label{sec:routing}
433
+
434
+ Figure~\ref{fig:cache}(a) shows measured expert popularity over
435
+ \nTraceTokens{} tokens. The distribution is heavy-tailed and well described by a
436
+ Zipf law with exponent $\nZipfSmeas$; the most-activated quartile of experts
437
+ absorbs \nMassTopQ\% of activations. Consecutive tokens reuse \nReuseMean\% of
438
+ their experts, so there is short-range temporal locality on top of the
439
+ popularity skew. Distinct experts touched per layer grows sublinearly in batch
440
+ size --- \nWorkSetOne{} at one token, \nWorkSetSixteen{} at $16$,
441
+ \nWorkSetSixtyFour{} at $64$ of $64$ --- so batching amortizes fetches
442
+ (Figure~\ref{fig:cache}c).
443
+
444
+ \subsection{Cache Policy and the LRU Threshold}\label{sec:policy}
445
+
446
+ Table~\ref{tab:policy} and Figure~\ref{fig:cache}(b) compare replacement
447
+ policies over the true interleaved access order. The result is stark. Below the
448
+ $\nTokenWS$-slot per-token working set ($\nTokenWSFrac\%$ of slots for this
449
+ model), LRU achieves a hit rate of \emph{exactly zero} at every capacity tested
450
+ --- $\nLruTwo\%$, $\nLruFive\%$, $\nLruTen\%$ at $2$, $5$ and $10\%$ capacity ---
451
+ and jumps to $\nLruTwelve\%$ the moment capacity reaches $\nTokenWS$ slots. This
452
+ is Eq.~\ref{eq:threshold} observed at precisely the predicted threshold, and it
453
+ is a property of the access pattern, not of our implementation.
454
+
455
+ Popularity-pinned caching has no such failure mode: it delivers
456
+ $\nStaticTwo\%$, $\nStaticFive\%$ and $\nStaticTen\%$ at the same capacities
457
+ where LRU delivers nothing, and its hit rate is by construction the popularity
458
+ mass of the pinned set --- an analytic quantity we confirm against the trace to
459
+ \nStaticMAE{} percentage points. Above the working set the ordering reverses and
460
+ recency helps: LRU reaches $\nLruTwentyFive\%$ at $25\%$ capacity against
461
+ $\nStaticTwentyFive\%$ static, and a hybrid that pins the hottest $75\%$ of
462
+ capacity and runs LRU over the remainder is best of all at large capacity
463
+ ($\nHybridForty\%$ at $40\%$).
464
+
465
+ Two conclusions follow. Operationally, popularity-pinned or hybrid placement
466
+ should be preferred to pure LRU in offloaded MoE engines, which supports the
467
+ allocation policy of Section~\ref{sec:alloc}: what matters is \emph{which}
468
+ experts are resident, and popularity predicts that well. Methodologically, we
469
+ project with the popularity-pinned model because it is exact given the
470
+ popularity vector and therefore extrapolates without relying on recency
471
+ structure we cannot verify at $E{=}320$. When the popularity vector is replaced
472
+ by its Zipf fit the model becomes optimistic by \nZipfMAE{} points; we subtract
473
+ that bias in all projections.
474
+
475
+ \begin{table}[t]
476
+ \centering\small
477
+ \caption{Measured expert-cache hit rates on the OLMoE trace ($\nSlots$ slots,
478
+ per-token working set $\nTokenWS$ slots). $^\dagger$ marks capacities below the
479
+ working set, where recency-based replacement cannot hit at all. ``Analytic'' is
480
+ the popularity-mass model used for extrapolation.}
481
+ \label{tab:policy}
482
+ \input{tab_policy}
483
+ \end{table}
484
+
485
+ \begin{figure}[t]
486
+ \centering
487
+ \includegraphics[width=\textwidth]{figs/cache.pdf}
488
+ \caption{(a) Measured expert popularity per layer with Zipf fit. (b) Hit rate
489
+ versus cache capacity for LRU, popularity pinning and the analytic model; the
490
+ vertical line marks the per-token working set. (c) Distinct experts per layer
491
+ versus batch size.}
492
+ \label{fig:cache}
493
+ \end{figure}
494
+
495
+ \subsection{Projection to T1}\label{sec:projection}
496
+
497
+ Table~\ref{tab:amp} instantiates Eq.~\ref{eq:frac} on the host. At bfloat16, T1
498
+ occupies \nFootprintFP\,GB --- it does not fit the machine's storage at all ---
499
+ and $24$\,GB of DRAM would hold \nSlotsFP{} expert slots, \emph{below} the
500
+ $512$-slot per-token working set, so recency-based caching would be inoperative.
501
+ At $1.5$ bits the model occupies \nFootprintOnePFive\,GB, fitting the $294$\,GB
502
+ of free NVMe, and DRAM holds \nCacheExperts{} slots ($\nCacheFrac\%$),
503
+ comfortably above the working set.
504
+
505
+ \begin{table}[t]
506
+ \centering\small
507
+ \caption{Footprint and DRAM residency for T1 ($\nTotalParams$\,B) with a
508
+ $24$\,GB expert cache on the measured host.}
509
+ \label{tab:amp}
510
+ \input{tab_amp}
511
+ \end{table}
512
+
513
+ Composing measured bandwidths with the calibrated cache model gives
514
+ Table~\ref{tab:proj}. At $1.5$ bits and batch~1 the projection is
515
+ \nTokSecOne{} tokens/s, fetching \nMBperTok\,MB per token at
516
+ \nIOatExpert\,GB/s; batch~32 reaches \nTokSecBatch{} tokens/s. At $1.0$ bit the
517
+ figures are \nTokSecOneBit{} and \nTokSecOneBitBatch{} tokens/s. The bfloat16
518
+ row projects \nTokSecFP{} tokens/s, so the $10.7\times$ compression to $1.5$
519
+ bits yields a $\nSpeedupOverFP\times$ throughput gain --- $\nAmpFactor\times$
520
+ more than compression alone, which is the amplification of
521
+ Eq.~\ref{eq:amp} made concrete.
522
+
523
+ Because the hit rate is the least certain input, Figure~\ref{fig:throughput}(a)
524
+ reports throughput across its entire range rather than at a single assumed
525
+ value. The qualitative conclusion is robust: even at $h=0$ the projection stays
526
+ near one token per second, because $Lk B(r)$ at $1.5$ bits is $4.8$\,GB and the
527
+ device delivers ${\sim}\nIOatExpert$\,GB/s.
528
+
529
+ \begin{table}[t]
530
+ \centering\small
531
+ \caption{Projected T1 decode throughput. Hardware terms measured; hit rate from
532
+ the calibrated popularity-pinned model with the Zipf bias subtracted.}
533
+ \label{tab:proj}
534
+ \input{tab_proj}
535
+ \end{table}
536
+
537
+ \begin{figure}[t]
538
+ \centering
539
+ \includegraphics[width=\textwidth]{figs/throughput.pdf}
540
+ \caption{(a) Sensitivity of projected batch-1 throughput to expert-cache hit
541
+ rate at $1.5$ bits. (b) Projected throughput versus weight rate and batch size.}
542
+ \label{fig:throughput}
543
+ \end{figure}
544
+
545
+ \begin{figure}[t]
546
+ \centering
547
+ \includegraphics[width=\textwidth]{figs/amplification.pdf}
548
+ \caption{(a) T1 footprint versus weight rate against the host's storage and DRAM
549
+ limits. (b) Fraction of expert slots resident in $24$\,GB of DRAM.}
550
+ \label{fig:amp}
551
+ \end{figure}
552
+
553
+ \subsection{A Constraint on the Decode Path}\label{sec:decode}
554
+
555
+ The projections assume dequantization keeps up with storage. In a
556
+ straightforward implementation it does not, and the gap is instructive.
557
+
558
+ Our PyTorch-level decode path --- \texttt{index\_select} gathers per residual
559
+ stage into a preallocated accumulator, int32 indices to avoid int64 promotion
560
+ --- sustains \nDecodeGw{} Gweight/s at $1.5$ bits, or \nDecodePacked\,GB/s of
561
+ packed input, against a storage stream of \nIOatExpert\,GB/s: short by roughly
562
+ $\nDecodeGap\times$.
563
+
564
+ The reason is bandwidth, not arithmetic. Reconstructing $1.5$-bit weights into
565
+ fp16 expands them $10.7\times$, so sustaining \nIOatExpert\,GB/s of packed
566
+ weights means writing ${\sim}\nFusedBw$\,GB/s of fp16 into VRAM and reading it
567
+ back for the GEMM, against $88.2$\,GB/s measured. \emph{Materializing
568
+ dequantized weights is infeasible on this class of GPU by roughly
569
+ $\nFusedRatio\times$ in bandwidth alone}, however well the gather is written.
570
+ Dequantization must be fused into the GEMM prologue so codebook indices expand
571
+ in registers or shared memory and fp16 weights never reach VRAM --- the design
572
+ QuIP\# and QTIP adopt for their inference kernels. Our measurement quantifies
573
+ why it is not optional at this scale. We did not implement a fused kernel; the
574
+ projections in Section~\ref{sec:projection} are I/O rooflines and should be read
575
+ as upper bounds contingent on such a kernel existing.
576
+
577
+ \section{Discussion and Limitations}\label{sec:limits}
578
+
579
+ \paragraph{What we did not do.}
580
+ We did not execute a trillion-parameter model. No $1$\,T checkpoint was
581
+ downloaded, quantized or run. T1 is a specified configuration and the throughput
582
+ figures are analytical compositions of measured host parameters with a modelled
583
+ cache term. They are not benchmark results and should not be cited as such.
584
+
585
+ \paragraph{Extrapolation risk.}
586
+ The cache model is validated at $E{=}64$, $L{=}16$ and applied at $E{=}320$,
587
+ $L{=}64$, assuming the Zipf exponent of expert popularity is scale-invariant.
588
+ This is the weakest link. It is plausible --- load-balancing auxiliary losses
589
+ push MoE routers toward similar popularity profiles --- but we have not tested
590
+ it on a model with $E>64$. If the distribution flattens with $E$, hit rates fall
591
+ and throughput moves down Figure~\ref{fig:throughput}(a). We report the full
592
+ sensitivity curve precisely because we cannot foreclose this. We also assume the
593
+ per-token working set scales as $kL$, which follows from the architecture rather
594
+ than from measurement.
595
+
596
+ \paragraph{Quality at 1T scale.}
597
+ Our perplexity results are for a $6.9$\,B model with $1.3$\,B active parameters,
598
+ and the degradation at \nBitsFreq{} bits ($\nPPLfp\rightarrow\nPPLFreq$) is
599
+ real. Larger models are generally more quantization-tolerant at fixed rate, so
600
+ sub-2-bit operation should be more forgiving at $1$\,T, but we have not verified
601
+ this and it should not be assumed. A reader who regards \nBitsFreq{} bits as too
602
+ lossy should read the \nBitsOursTwo-bit row of Table~\ref{tab:proj}
603
+ (\nTokSecTwoBit{} tokens/s at batch~1), which still fits the machine's storage
604
+ and still crosses the working-set threshold; the qualitative argument does not
605
+ depend on the most aggressive rate.
606
+
607
+ \paragraph{Unmodelled costs.}
608
+ The roofline omits KV-cache growth with context length, router computation,
609
+ prefill, filesystem and allocator overhead, and thermal throttling under
610
+ sustained load. Each pushes achieved throughput below the projection. Sustained
611
+ SSD streaming also carries a substantial per-token energy cost --- reported at
612
+ up to ${\sim}12\times$ an HBM baseline --- which matters for a battery-powered
613
+ device and which we did not measure.
614
+
615
+ \section{Conclusion}
616
+
617
+ Quantization's role in offloaded mixture-of-experts inference is better
618
+ understood as cache amplification than as footprint reduction. Because a token
619
+ touches $kL$ distinct expert slots before reusing any, recency-based expert
620
+ caches have a hard threshold below which they cannot hit at all --- which we
621
+ measure exactly --- and because resident capacity is inversely proportional to
622
+ the weight rate, quantization is what carries a system across it. On our host
623
+ the $10.7\times$ compression from bfloat16 to $1.5$ bits yields a
624
+ $\nSpeedupOverFP\times$ projected throughput gain, $\nAmpFactor\times$ more than
625
+ compression alone. The reframing has a design consequence: bits should be
626
+ allocated across experts by activation frequency, improving distortion and cache
627
+ residency together, and placement should be popularity-pinned rather than purely
628
+ recency-based.
629
+
630
+ Instantiated on one commodity laptop with measured storage, PCIe and GPU limits
631
+ and a cache model calibrated against real routing traces, a
632
+ $\nTotalParams$\,B-parameter MoE fits in \nFootprintOnePFive\,GB at $1.5$ bits
633
+ and projects \nTokSecOne--\nTokSecBatch{} tokens/s depending on batch size. The
634
+ binding engineering constraint is not storage but the dequantization path: fp16
635
+ materialization exceeds the device's memory bandwidth, so fusion into the GEMM
636
+ is mandatory. Whether a trillion-parameter model actually runs on a laptop is
637
+ not settled here --- but the storage and bandwidth budgets close, and the kernel
638
+ that has to be written to find out is named.
639
+
640
+ \paragraph{Reproducibility.}
641
+ All measurement and quantization code, the raw routing traces, and the JSON
642
+ artefacts from which every number in this paper is generated are released with
643
+ the paper. Numbers in the text are injected programmatically from those
644
+ artefacts.
645
+
646
+ \begin{thebibliography}{99}\small
647
+
648
+ \bibitem{gptq} E.~Frantar, S.~Ashkboos, T.~Hoefler, D.~Alistarh.
649
+ GPTQ: Accurate Post-Training Quantization for Generative Pre-trained
650
+ Transformers. \emph{ICLR}, 2023.
651
+
652
+ \bibitem{awq} J.~Lin, J.~Tang, H.~Tang, S.~Yang, X.~Dang, S.~Han.
653
+ AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration.
654
+ \emph{MLSys}, 2024.
655
+
656
+ \bibitem{quip} J.~Chee, Y.~Cai, V.~Kuleshov, C.~De~Sa.
657
+ QuIP: 2-Bit Quantization of Large Language Models With Guarantees.
658
+ \emph{NeurIPS}, 2023.
659
+
660
+ \bibitem{quipsharp} A.~Tseng, J.~Chee, Q.~Sun, V.~Kuleshov, C.~De~Sa.
661
+ QuIP\#: Even Better LLM Quantization with Hadamard Incoherence and Lattice
662
+ Codebooks. \emph{ICML}, 2024.
663
+
664
+ \bibitem{aqlm} V.~Egiazarian, A.~Panferov, D.~Kuznedelev, E.~Frantar,
665
+ A.~Babenko, D.~Alistarh. Extreme Compression of Large Language Models via
666
+ Additive Quantization. \emph{ICML}, 2024.
667
+
668
+ \bibitem{qtip} A.~Tseng, Q.~Sun, D.~Hou, C.~De~Sa.
669
+ QTIP: Quantization with Trellises and Incoherence Processing.
670
+ \emph{NeurIPS}, 2024.
671
+
672
+ \bibitem{vptq} Y.~Liu et al. VPTQ: Extreme Low-bit Vector Post-Training
673
+ Quantization for Large Language Models. \emph{EMNLP}, 2024.
674
+
675
+ \bibitem{bitnet} S.~Ma, H.~Wang, L.~Ma, L.~Wang, W.~Wang, S.~Huang, L.~Dong,
676
+ R.~Wang, J.~Xue, F.~Wei. The Era of 1-bit LLMs: All Large Language Models are in
677
+ 1.58 Bits. \emph{arXiv:2402.17764}, 2024.
678
+
679
+ \bibitem{flexgen} Y.~Sheng, L.~Zheng, B.~Yuan, Z.~Li, M.~Ryabinin, D.~Fu,
680
+ Z.~Xie, B.~Chen, C.~Barrett, J.~Gonzalez, P.~Liang, C.~R\'e, I.~Stoica, C.~Zhang.
681
+ FlexGen: High-Throughput Generative Inference of Large Language Models with a
682
+ Single GPU. \emph{ICML}, 2023.
683
+
684
+ \bibitem{flash} K.~Alizadeh, I.~Mirzadeh, D.~Belenko, K.~Khatamifard, M.~Cho,
685
+ C.~C.~Del~Mundo, M.~Rastegari, M.~Farajtabar. LLM in a Flash: Efficient Large
686
+ Language Model Inference with Limited Memory. \emph{ACL}, 2024.
687
+
688
+ \bibitem{powerinfer} Y.~Song, Z.~Mi, H.~Xie, H.~Chen.
689
+ PowerInfer: Fast Large Language Model Serving with a Consumer-grade GPU.
690
+ \emph{SOSP}, 2024.
691
+
692
+ \bibitem{mixtraloffload} A.~Eliseev, D.~Mazur.
693
+ Fast Inference of Mixture-of-Experts Language Models with Offloading.
694
+ \emph{arXiv:2312.17238}, 2023.
695
+
696
+ \bibitem{moeinfinity} L.~Xue, Y.~Fu, Z.~Lu, L.~Mai, M.~Marina.
697
+ MoE-Infinity: Offloading-Efficient MoE Model Serving.
698
+ \emph{arXiv:2401.14361}, 2024.
699
+
700
+ \bibitem{flashmoe} FlashMoE: Reducing SSD I/O Bottlenecks via ML-Based Cache
701
+ Replacement for Mixture-of-Experts Inference on Edge Devices.
702
+ \emph{arXiv:2601.17063}, 2026.
703
+
704
+ \bibitem{mobile} MoBiLE: Efficient Mixture-of-Experts Inference on Consumer GPU
705
+ with Mixture of Big Little Experts. \emph{arXiv:2510.12357}, 2025.
706
+
707
+ \bibitem{olmoe} N.~Muennighoff, L.~Soldaini, D.~Groeneveld, K.~Lo, J.~Morrison,
708
+ S.~Min, W.~Shi, P.~Walsh, O.~Tafjord, N.~Lambert, Y.~Gu, S.~Arora, A.~Bhagia,
709
+ D.~Schwenk, D.~Wadden, A.~Wettig, B.~Hui, T.~Dettmers, D.~Kiela, A.~Farhadi,
710
+ N.~A.~Smith, P.~W.~Koh, A.~Singh, H.~Hajishirzi.
711
+ OLMoE: Open Mixture-of-Experts Language Models. \emph{ICLR}, 2025.
712
+
713
+ \bibitem{deepseek} DeepSeek-AI. DeepSeek-V3 Technical Report.
714
+ \emph{arXiv:2412.19437}, 2024.
715
+
716
+ \bibitem{switch} W.~Fedus, B.~Zoph, N.~Shazeer. Switch Transformers: Scaling to
717
+ Trillion Parameter Models with Simple and Efficient Sparsity. \emph{JMLR}, 2022.
718
+
719
+ \bibitem{che} H.~Che, Y.~Tung, Z.~Wang. Hierarchical Web Caching Systems:
720
+ Modeling, Design and Experimental Results. \emph{IEEE JSAC}, 20(7), 2002.
721
+
722
+ \bibitem{wikitext} S.~Merity, C.~Xiong, J.~Bradbury, R.~Socher.
723
+ Pointer Sentinel Mixture Models. \emph{ICLR}, 2017.
724
+
725
+ \end{thebibliography}
726
+
727
+ \end{document}
paper/numbers.tex ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % auto-generated by code/gen_numbers.py -- do not edit
2
+ \newcommand{\nActiveParams}{39.7}
3
+ \newcommand{\nAmpFactor}{1.54}
4
+ \newcommand{\nAmplification}{10.7}
5
+ \newcommand{\nBitsFreq}{1.51}
6
+ \newcommand{\nBitsNoLdlq}{1.51}
7
+ \newcommand{\nBitsNoRht}{1.51}
8
+ \newcommand{\nBitsOurs}{1.51}
9
+ \newcommand{\nBitsOursOne}{1.01}
10
+ \newcommand{\nBitsOursTwo}{2.01}
11
+ \newcommand{\nBitsRtnThree}{3.25}
12
+ \newcommand{\nBitsRtnTwo}{2.25}
13
+ \newcommand{\nCacheExperts}{2,543}
14
+ \newcommand{\nCacheExpertsFP}{238}
15
+ \newcommand{\nCacheFrac}{12.42}
16
+ \newcommand{\nCacheFracFP}{1.16}
17
+ \newcommand{\nDecodeFpEquiv}{2.4}
18
+ \newcommand{\nDecodeGap}{25}
19
+ \newcommand{\nDecodeGw}{1.20}
20
+ \newcommand{\nDecodePacked}{0.22}
21
+ \newcommand{\nDistinctEight}{38.2}
22
+ \newcommand{\nDistinctOne}{8.0}
23
+ \newcommand{\nDistinctThirtyTwo}{58.3}
24
+ \newcommand{\nExpertMB}{9.44}
25
+ \newcommand{\nExpertMBfp}{100.7}
26
+ \newcommand{\nExpertSlots}{20,480}
27
+ \newcommand{\nFootprintFP}{2,092}
28
+ \newcommand{\nFootprintOne}{131}
29
+ \newcommand{\nFootprintOnePFive}{196}
30
+ \newcommand{\nFootprintTwo}{261}
31
+ \newcommand{\nFusedBw}{116}
32
+ \newcommand{\nFusedRatio}{1.32}
33
+ \newcommand{\nGPUName}{NVIDIA RTX A500 Laptop GPU}
34
+ \newcommand{\nHitRate}{35.5}
35
+ \newcommand{\nHitRateFP}{5.8}
36
+ \newcommand{\nHybridFifteen}{24.9}
37
+ \newcommand{\nHybridFive}{10.6}
38
+ \newcommand{\nHybridForty}{67.3}
39
+ \newcommand{\nHybridTen}{18.4}
40
+ \newcommand{\nHybridTwelve}{21.9}
41
+ \newcommand{\nHybridTwentyFive}{38.2}
42
+ \newcommand{\nHybridTwo}{4.9}
43
+ \newcommand{\nIOatExpert}{5.46}
44
+ \newcommand{\nLruFifteen}{37.0}
45
+ \newcommand{\nLruFive}{0.0}
46
+ \newcommand{\nLruForty}{66.0}
47
+ \newcommand{\nLruTen}{0.0}
48
+ \newcommand{\nLruTwelve}{25.3}
49
+ \newcommand{\nLruTwentyFive}{48.4}
50
+ \newcommand{\nLruTwo}{0.0}
51
+ \newcommand{\nMBperTok}{3,021}
52
+ \newcommand{\nMassTopQ}{44.9}
53
+ \newcommand{\nNumRuns}{8}
54
+ \newcommand{\nPCIe}{6.11}
55
+ \newcommand{\nPPLFreq}{22.02}
56
+ \newcommand{\nPPLNoLdlq}{7,701.98}
57
+ \newcommand{\nPPLNoRht}{352.10}
58
+ \newcommand{\nPPLOurs}{25.54}
59
+ \newcommand{\nPPLOursOne}{156.07}
60
+ \newcommand{\nPPLOursTwo}{12.17}
61
+ \newcommand{\nPPLRtnThree}{10.49}
62
+ \newcommand{\nPPLRtnTwo}{22,793.90}
63
+ \newcommand{\nPPLfp}{8.11}
64
+ \newcommand{\nPeakTflops}{6.94}
65
+ \newcommand{\nRamCopy}{12.9}
66
+ \newcommand{\nRandBest}{6.01}
67
+ \newcommand{\nRandBestBlock}{1}
68
+ \newcommand{\nRandBestThreads}{4}
69
+ \newcommand{\nRandOneThread}{2.81}
70
+ \newcommand{\nRandSmall}{0.49}
71
+ \newcommand{\nReqDecode}{5.46}
72
+ \newcommand{\nResidentGB}{2.42}
73
+ \newcommand{\nReuseMean}{37.0}
74
+ \newcommand{\nSeqRead}{4.79}
75
+ \newcommand{\nSlots}{1,024}
76
+ \newcommand{\nSlotsFP}{238}
77
+ \newcommand{\nSpeedupOverFP}{16.4}
78
+ \newcommand{\nStaticFifteen}{31.0}
79
+ \newcommand{\nStaticFive}{13.5}
80
+ \newcommand{\nStaticForty}{62.4}
81
+ \newcommand{\nStaticMAE}{0.00}
82
+ \newcommand{\nStaticTen}{22.9}
83
+ \newcommand{\nStaticTwelve}{27.1}
84
+ \newcommand{\nStaticTwentyFive}{45.1}
85
+ \newcommand{\nStaticTwo}{6.2}
86
+ \newcommand{\nTokSecBatch}{3.08}
87
+ \newcommand{\nTokSecEight}{2.17}
88
+ \newcommand{\nTokSecFP}{0.11}
89
+ \newcommand{\nTokSecOne}{1.81}
90
+ \newcommand{\nTokSecOneBit}{3.21}
91
+ \newcommand{\nTokSecOneBitBatch}{5.48}
92
+ \newcommand{\nTokSecTwoBit}{1.22}
93
+ \newcommand{\nTokenWS}{128}
94
+ \newcommand{\nTokenWSFrac}{12.5}
95
+ \newcommand{\nTotalParams}{1,045.8}
96
+ \newcommand{\nTraceTokens}{49,152}
97
+ \newcommand{\nWorkSetKilo}{63.2}
98
+ \newcommand{\nWorkSetOne}{8.0}
99
+ \newcommand{\nWorkSetSixteen}{42.1}
100
+ \newcommand{\nWorkSetSixtyFour}{56.6}
101
+ \newcommand{\nZipfBias}{6.84}
102
+ \newcommand{\nZipfMAE}{6.84}
103
+ \newcommand{\nZipfS}{0.65}
104
+ \newcommand{\nZipfSmeas}{0.65}
paper/tab_amp.tex ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \begin{tabular}{rrrrrl}
2
+ \toprule
3
+ Rate & Footprint & Expert & Resident & Cache & Fits \\
4
+ (bits) & (GB) & (MB) & slots & fraction & 294\,GB? \\
5
+ \midrule
6
+ 16.0 & 2,092 & 100.66 & 238 & 1.16\% & \textbf{no} \\
7
+ 4.0 & 523 & 25.17 & 953 & 4.65\% & \textbf{no} \\
8
+ 3.0 & 392 & 18.87 & 1,271 & 6.21\% & \textbf{no} \\
9
+ 2.0 & 261 & 12.58 & 1,907 & 9.31\% & yes \\
10
+ 1.5 & 196 & 9.44 & 2,543 & 12.42\% & yes \\
11
+ 1.0 & 131 & 6.29 & 3,814 & 18.62\% & yes \\
12
+ \bottomrule
13
+ \end{tabular}
paper/tab_policy.tex ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \begin{tabular}{rrrrrr}
2
+ \toprule
3
+ Capacity & Slots & LRU & Static-freq. & Hybrid & Analytic \\
4
+ \midrule
5
+ 2.0\%$^\dagger$ & 20 & 0.0\% & 6.2\% & 4.9\% & 6.2\% \\
6
+ 5.0\%$^\dagger$ & 51 & 0.0\% & 13.5\% & 10.6\% & 13.5\% \\
7
+ 10.0\%$^\dagger$ & 102 & 0.0\% & 22.9\% & 18.4\% & 22.9\% \\
8
+ 12.5\% & 128 & 25.3\% & 27.1\% & 21.9\% & 27.1\% \\
9
+ 15.0\% & 153 & 37.0\% & 31.0\% & 24.9\% & 31.0\% \\
10
+ 25.0\% & 256 & 48.4\% & 45.1\% & 38.2\% & 45.1\% \\
11
+ 40.0\% & 409 & 66.0\% & 62.4\% & 67.3\% & 62.4\% \\
12
+ 60.0\% & 614 & 83.6\% & 80.6\% & 84.7\% & 80.6\% \\
13
+ 80.0\% & 819 & 96.0\% & 93.9\% & 95.9\% & 93.9\% \\
14
+ \bottomrule
15
+ \end{tabular}
paper/tab_proj.tex ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \begin{tabular}{rrrrrrr}
2
+ \toprule
3
+ Rate & Cache & Recency & Hit & Fetch & \multicolumn{2}{c}{Tokens/s} \\
4
+ \cmidrule(lr){6-7}
5
+ (bits) & slots & viable? & rate & MB/token & batch 1 & batch 32 \\
6
+ \midrule
7
+ 16.0 & 238 & \textbf{no} & 5.8\% & 47,050 & 0.11 & 0.19 \\
8
+ 4.0 & 953 & yes & 20.0\% & 9,991 & 0.52 & 0.89 \\
9
+ 3.0 & 1,271 & yes & 24.0\% & 7,120 & 0.73 & 1.24 \\
10
+ 2.0 & 1,907 & yes & 30.4\% & 4,348 & 1.22 & 2.09 \\
11
+ 1.5 & 2,543 & yes & 35.5\% & 3,021 & 1.81 & 3.08 \\
12
+ 1.0 & 3,814 & yes & 43.7\% & 1,759 & 3.21 & 5.48 \\
13
+ \bottomrule
14
+ \end{tabular}
paper/tab_quality.tex ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ \begin{tabular}{llrr}
2
+ \toprule
3
+ Method & Note & Bits/weight & PPL $\downarrow$ \\
4
+ \midrule
5
+ bf16 (reference) & --- & 16.00 & 8.11 \\
6
+ \midrule
7
+ RTN uniform, group 128 & scalar baseline & 3.25 & 10.49 \\
8
+ RTN uniform, group 128 & scalar baseline & 2.25 & 22793.90 \\
9
+ RVQ, data-free & no LDLQ & 1.51 & 7701.98 \\
10
+ RVQ + LDLQ, no rotation & no incoherence proc. & 1.51 & 352.10 \\
11
+ RVQ + RHT + LDLQ (ours) & & 1.01 & 156.07 \\
12
+ RVQ + RHT + LDLQ (ours) & & 1.51 & 25.54 \\
13
+ RVQ + RHT + LDLQ (ours) & & 2.01 & 12.17 \\
14
+ \quad + frequency-cond. alloc. & rate-matched & 1.51 & 22.02 \\
15
+ \bottomrule
16
+ \end{tabular}
results/cache_policy.json ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": 16,
3
+ "experts": 64,
4
+ "topk": 8,
5
+ "tokens": 49152,
6
+ "n_slots": 1024,
7
+ "token_working_set": 128,
8
+ "zipf_s": 0.6527289058070496,
9
+ "ws_frac": 0.125,
10
+ "policies": [
11
+ {
12
+ "frac": 0.02,
13
+ "cap": 20,
14
+ "lru": 0.0,
15
+ "static": 0.06245549519856771,
16
+ "hybrid": 0.0494688351949056,
17
+ "analytic_static": 0.062455495198567704,
18
+ "analytic_zipf": 0.11694738567082635
19
+ },
20
+ {
21
+ "frac": 0.05,
22
+ "cap": 51,
23
+ "lru": 0.0,
24
+ "static": 0.13478676478068033,
25
+ "hybrid": 0.10638793309529622,
26
+ "analytic_static": 0.13478676478068036,
27
+ "analytic_zipf": 0.2219950885845816
28
+ },
29
+ {
30
+ "frac": 0.1,
31
+ "cap": 102,
32
+ "lru": 0.0,
33
+ "static": 0.228851318359375,
34
+ "hybrid": 0.183563232421875,
35
+ "analytic_static": 0.228851318359375,
36
+ "analytic_zipf": 0.3324114679054415
37
+ },
38
+ {
39
+ "frac": 0.125,
40
+ "cap": 128,
41
+ "lru": 0.25345611572265625,
42
+ "static": 0.2711273829142253,
43
+ "hybrid": 0.2186457316080729,
44
+ "analytic_static": 0.2711273829142252,
45
+ "analytic_zipf": 0.3760863959531343
46
+ },
47
+ {
48
+ "frac": 0.15,
49
+ "cap": 153,
50
+ "lru": 0.3698643048604329,
51
+ "static": 0.3095962206522624,
52
+ "hybrid": 0.24870061874389648,
53
+ "analytic_static": 0.30959622065226233,
54
+ "analytic_zipf": 0.4127589521127012
55
+ },
56
+ {
57
+ "frac": 0.25,
58
+ "cap": 256,
59
+ "lru": 0.4839518864949544,
60
+ "static": 0.45073652267456055,
61
+ "hybrid": 0.3817426363627116,
62
+ "analytic_static": 0.45073652267456055,
63
+ "analytic_zipf": 0.5342836357250341
64
+ },
65
+ {
66
+ "frac": 0.4,
67
+ "cap": 409,
68
+ "lru": 0.6604461669921875,
69
+ "static": 0.6235604286193848,
70
+ "hybrid": 0.6733926137288412,
71
+ "analytic_static": 0.6235604286193848,
72
+ "analytic_zipf": 0.6665664373136196
73
+ },
74
+ {
75
+ "frac": 0.6,
76
+ "cap": 614,
77
+ "lru": 0.8356102307637533,
78
+ "static": 0.806199868520101,
79
+ "hybrid": 0.8468090693155924,
80
+ "analytic_static": 0.8061998685201008,
81
+ "analytic_zipf": 0.8008694898685313
82
+ },
83
+ {
84
+ "frac": 0.8,
85
+ "cap": 819,
86
+ "lru": 0.9596964518229166,
87
+ "static": 0.9390878677368164,
88
+ "hybrid": 0.9588371912638346,
89
+ "analytic_static": 0.9390878677368164,
90
+ "analytic_zipf": 0.9085847385781042
91
+ }
92
+ ],
93
+ "mae_analytic_static": 2.852656382717416e-17,
94
+ "mae_analytic_zipf": 0.06841874865295161,
95
+ "best_gain_hybrid": 0.183563232421875
96
+ }
results/cache_validation.json ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": 16,
3
+ "experts": 64,
4
+ "topk": 8,
5
+ "tokens": 49152,
6
+ "zipf_s": 0.6527289058070496,
7
+ "zipf_s_per_layer": [
8
+ 0.5168399731353996,
9
+ 0.45216287722374227,
10
+ 0.611280793656683,
11
+ 0.5906835171510877,
12
+ 0.7793981775030502,
13
+ 0.6480099103325739,
14
+ 0.8399621101649059,
15
+ 0.7226159598776765,
16
+ 0.6574479012815251,
17
+ 0.6178199900164697,
18
+ 0.5407503482861278,
19
+ 0.7115751165458343,
20
+ 0.6219601450559994,
21
+ 0.7641232197074124,
22
+ 0.7869316757535504,
23
+ 0.8445318723149822
24
+ ],
25
+ "hit_rates": [
26
+ {
27
+ "frac": 0.02,
28
+ "cap": 20,
29
+ "measured": 0.0,
30
+ "static": 0.06245549519856771,
31
+ "che_measured_pop": 0.026580850797751226,
32
+ "che_zipf": 0.03699199460718677
33
+ },
34
+ {
35
+ "frac": 0.05,
36
+ "cap": 51,
37
+ "measured": 0.0,
38
+ "static": 0.13478676478068033,
39
+ "che_measured_pop": 0.0673864982202855,
40
+ "che_zipf": 0.09189351727660205
41
+ },
42
+ {
43
+ "frac": 0.1,
44
+ "cap": 102,
45
+ "measured": 0.0,
46
+ "static": 0.228851318359375,
47
+ "che_measured_pop": 0.13345774419413597,
48
+ "che_zipf": 0.1760246570537025
49
+ },
50
+ {
51
+ "frac": 0.15,
52
+ "cap": 153,
53
+ "measured": 0.3698643048604329,
54
+ "static": 0.3095962206522624,
55
+ "che_measured_pop": 0.1981815435699793,
56
+ "che_zipf": 0.25295360799759015
57
+ },
58
+ {
59
+ "frac": 0.25,
60
+ "cap": 256,
61
+ "measured": 0.4839518864949544,
62
+ "static": 0.45073652267456055,
63
+ "che_measured_pop": 0.3246471540752854,
64
+ "che_zipf": 0.38915048181000694
65
+ },
66
+ {
67
+ "frac": 0.4,
68
+ "cap": 409,
69
+ "measured": 0.6604461669921875,
70
+ "static": 0.6235604286193848,
71
+ "che_measured_pop": 0.5013942145993738,
72
+ "che_zipf": 0.5550206500765682
73
+ },
74
+ {
75
+ "frac": 0.6,
76
+ "cap": 614,
77
+ "measured": 0.8356102307637533,
78
+ "static": 0.806199868520101,
79
+ "che_measured_pop": 0.7149889036966475,
80
+ "che_zipf": 0.7333943331893689
81
+ },
82
+ {
83
+ "frac": 0.8,
84
+ "cap": 819,
85
+ "measured": 0.9596964518229166,
86
+ "static": 0.9390878677368164,
87
+ "che_measured_pop": 0.8950458315684564,
88
+ "che_zipf": 0.8798901406977873
89
+ }
90
+ ],
91
+ "che_mae": 0.11284206082958438,
92
+ "che_zipf_mae": 0.10050874951255183,
93
+ "distinct_per_batch": [
94
+ {
95
+ "batch": 1,
96
+ "measured": 8.0,
97
+ "irm_measured_pop": 7.565598081578889,
98
+ "irm_zipf": 7.244434802265509
99
+ },
100
+ {
101
+ "batch": 2,
102
+ "measured": 14.635,
103
+ "irm_measured_pop": 14.21605904627252,
104
+ "irm_zipf": 13.146814196509677
105
+ },
106
+ {
107
+ "batch": 4,
108
+ "measured": 24.785,
109
+ "irm_measured_pop": 25.20959290631525,
110
+ "irm_zipf": 22.39747563960906
111
+ },
112
+ {
113
+ "batch": 8,
114
+ "measured": 38.245,
115
+ "irm_measured_pop": 40.331336428136424,
116
+ "irm_zipf": 35.00525487643894
117
+ },
118
+ {
119
+ "batch": 16,
120
+ "measured": 50.145,
121
+ "irm_measured_pop": 55.00905829801991,
122
+ "irm_zipf": 48.80265749792019
123
+ },
124
+ {
125
+ "batch": 32,
126
+ "measured": 58.33,
127
+ "irm_measured_pop": 62.59406412137466,
128
+ "irm_zipf": 59.23503640459326
129
+ },
130
+ {
131
+ "batch": 64,
132
+ "measured": 61.625,
133
+ "irm_measured_pop": 63.953407955543796,
134
+ "irm_zipf": 63.42120139668306
135
+ }
136
+ ],
137
+ "reuse_prev_token": [
138
+ 0.2499567658847226,
139
+ 0.2796840349128197,
140
+ 0.3672738092816016,
141
+ 0.3708393522003621,
142
+ 0.44042084596447684,
143
+ 0.4547211653882932,
144
+ 0.46631045146589084,
145
+ 0.4375648511729161,
146
+ 0.3781764358812639,
147
+ 0.3395353095562654,
148
+ 0.31294632866065797,
149
+ 0.36515025126650524,
150
+ 0.3588685886350227,
151
+ 0.38883491688877136,
152
+ 0.34283127505035504,
153
+ 0.36325557974405404
154
+ ],
155
+ "working_set": {
156
+ "1": 8.0,
157
+ "4": 21.099609375,
158
+ "16": 42.0537109375,
159
+ "64": 56.6220703125,
160
+ "256": 61.19140625,
161
+ "1024": 63.161458333333336
162
+ },
163
+ "mass_top25pct": 0.4494392077128093
164
+ }
results/decode_bench.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "decode": [
3
+ {
4
+ "stages": 2,
5
+ "bits": 1.0,
6
+ "weights_per_s": 1817943193.799809,
7
+ "fp16_equiv_GBs": 3.635886387599618,
8
+ "packed_GBs": 0.22724289922497612
9
+ },
10
+ {
11
+ "stages": 3,
12
+ "bits": 1.5,
13
+ "weights_per_s": 1198775873.844113,
14
+ "fp16_equiv_GBs": 2.3975517476882264,
15
+ "packed_GBs": 0.22477047634577121
16
+ },
17
+ {
18
+ "stages": 4,
19
+ "bits": 2.0,
20
+ "weights_per_s": 863031951.5133244,
21
+ "fp16_equiv_GBs": 1.7260639030266487,
22
+ "packed_GBs": 0.2157579878783311
23
+ }
24
+ ],
25
+ "hadamard_us": {
26
+ "2048": 1603.822000324726,
27
+ "4096": 1567.6909999456257,
28
+ "8192": 1929.9134996253997
29
+ },
30
+ "matmul": {
31
+ "1x8192x2048": {
32
+ "tflops": 0.08747153860226937,
33
+ "ms": 0.38360399892553687
34
+ },
35
+ "32x8192x2048": {
36
+ "tflops": 2.891719779463005,
37
+ "ms": 0.37131600081920624
38
+ },
39
+ "2048x8192x2048": {
40
+ "tflops": 6.941912431603671,
41
+ "ms": 9.899214000906795
42
+ }
43
+ },
44
+ "gpu": "NVIDIA RTX A500 Laptop GPU"
45
+ }
results/fp16_ppl.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "ppl": 8.107172012329102,
3
+ "seqlen": 2048,
4
+ "limit": 20
5
+ }
results/io_bench.json ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "file_gb": 8,
3
+ "random": [
4
+ {
5
+ "block_kb": 64,
6
+ "threads": 1,
7
+ "mb_s": 494.9510341759896,
8
+ "iops": 7552.353426757654,
9
+ "lat_ms": 0.13240905761335853
10
+ },
11
+ {
12
+ "block_kb": 64,
13
+ "threads": 2,
14
+ "mb_s": 980.044654849359,
15
+ "iops": 14954.294660176985,
16
+ "lat_ms": 0.13374084471706738
17
+ },
18
+ {
19
+ "block_kb": 64,
20
+ "threads": 4,
21
+ "mb_s": 1748.0921417310979,
22
+ "iops": 26673.769252488677,
23
+ "lat_ms": 0.14996005859302386
24
+ },
25
+ {
26
+ "block_kb": 64,
27
+ "threads": 8,
28
+ "mb_s": 2852.569135318681,
29
+ "iops": 43526.750722025776,
30
+ "lat_ms": 0.18379501955223532
31
+ },
32
+ {
33
+ "block_kb": 256,
34
+ "threads": 1,
35
+ "mb_s": 1547.8506430620785,
36
+ "iops": 5904.581615684809,
37
+ "lat_ms": 0.16936000974965282
38
+ },
39
+ {
40
+ "block_kb": 256,
41
+ "threads": 2,
42
+ "mb_s": 2876.0505176667384,
43
+ "iops": 10971.262045542673,
44
+ "lat_ms": 0.18229443355721742
45
+ },
46
+ {
47
+ "block_kb": 256,
48
+ "threads": 4,
49
+ "mb_s": 4576.405233664012,
50
+ "iops": 17457.600531250046,
51
+ "lat_ms": 0.22912656254447938
52
+ },
53
+ {
54
+ "block_kb": 256,
55
+ "threads": 8,
56
+ "mb_s": 5370.6425547877725,
57
+ "iops": 20487.37546839818,
58
+ "lat_ms": 0.3904843747477571
59
+ },
60
+ {
61
+ "block_kb": 1024,
62
+ "threads": 1,
63
+ "mb_s": 2805.1044913303567,
64
+ "iops": 2675.1561082175795,
65
+ "lat_ms": 0.37380996081992635
66
+ },
67
+ {
68
+ "block_kb": 1024,
69
+ "threads": 2,
70
+ "mb_s": 5384.820501499133,
71
+ "iops": 5135.365010737546,
72
+ "lat_ms": 0.3894562501045584
73
+ },
74
+ {
75
+ "block_kb": 1024,
76
+ "threads": 4,
77
+ "mb_s": 6007.7807939759905,
78
+ "iops": 5729.46624181365,
79
+ "lat_ms": 0.6981453125263215
80
+ },
81
+ {
82
+ "block_kb": 1024,
83
+ "threads": 8,
84
+ "mb_s": 5833.036315730558,
85
+ "iops": 5562.816920977171,
86
+ "lat_ms": 1.4381203109223861
87
+ },
88
+ {
89
+ "block_kb": 4096,
90
+ "threads": 1,
91
+ "mb_s": 4233.817423838591,
92
+ "iops": 1009.4207343670346,
93
+ "lat_ms": 0.9906671875796746
94
+ },
95
+ {
96
+ "block_kb": 4096,
97
+ "threads": 2,
98
+ "mb_s": 5842.093998027338,
99
+ "iops": 1392.8637499874444,
100
+ "lat_ms": 1.4358906246343395
101
+ },
102
+ {
103
+ "block_kb": 4096,
104
+ "threads": 4,
105
+ "mb_s": 5842.545391522159,
106
+ "iops": 1392.9713705830952,
107
+ "lat_ms": 2.871559376217192
108
+ },
109
+ {
110
+ "block_kb": 4096,
111
+ "threads": 8,
112
+ "mb_s": 5580.8599282872,
113
+ "iops": 1330.5806942670822,
114
+ "lat_ms": 6.012412501149811
115
+ },
116
+ {
117
+ "block_kb": 16384,
118
+ "threads": 1,
119
+ "mb_s": 4158.337625827989,
120
+ "iops": 247.85623704361848,
121
+ "lat_ms": 4.0345968773181085
122
+ },
123
+ {
124
+ "block_kb": 16384,
125
+ "threads": 2,
126
+ "mb_s": 5578.186766517397,
127
+ "iops": 332.4858407090543,
128
+ "lat_ms": 6.015293751261197
129
+ },
130
+ {
131
+ "block_kb": 16384,
132
+ "threads": 4,
133
+ "mb_s": 5183.172285271779,
134
+ "iops": 308.94114287327403,
135
+ "lat_ms": 12.947449999046512
136
+ },
137
+ {
138
+ "block_kb": 16384,
139
+ "threads": 8,
140
+ "mb_s": 4622.515008682658,
141
+ "iops": 275.52336506144155,
142
+ "lat_ms": 29.03565001906827
143
+ }
144
+ ],
145
+ "host": {
146
+ "seq_read_mb_s": 4790.751643316461,
147
+ "ram_copy_GBs": 12.893710872298776,
148
+ "h2d_1MB_GBs": 6.036089340643436,
149
+ "h2d_4MB_GBs": 6.090728427703106,
150
+ "h2d_16MB_GBs": 6.111264413438207,
151
+ "h2d_64MB_GBs": 6.112899630205483
152
+ }
153
+ }
results/projection.json ADDED
@@ -0,0 +1,641 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "config": {
3
+ "name": "T1-1046B",
4
+ "layers": 64,
5
+ "d_model": 8192,
6
+ "n_experts": 320,
7
+ "topk": 8,
8
+ "d_ff_expert": 2048,
9
+ "n_shared": 1,
10
+ "kv_dim": 1024,
11
+ "vocab": 129280
12
+ },
13
+ "params": {
14
+ "total": 1045795176448.0,
15
+ "active": 39713767424.0,
16
+ "expert": 50331648.0,
17
+ "attn_total": 9663676416.0,
18
+ "shared_total": 3221225472.0,
19
+ "routed_total": 1030792151040.0,
20
+ "n_slots": 20480.0
21
+ },
22
+ "amplification": [
23
+ {
24
+ "bits": 16,
25
+ "model_gb": 2091.590352896,
26
+ "expert_mb": 100.663296,
27
+ "dram_experts": 238,
28
+ "frac": 0.01162109375
29
+ },
30
+ {
31
+ "bits": 4,
32
+ "model_gb": 522.897588224,
33
+ "expert_mb": 25.165824,
34
+ "dram_experts": 953,
35
+ "frac": 0.046533203125
36
+ },
37
+ {
38
+ "bits": 3,
39
+ "model_gb": 392.173191168,
40
+ "expert_mb": 18.874368,
41
+ "dram_experts": 1271,
42
+ "frac": 0.062060546875
43
+ },
44
+ {
45
+ "bits": 2,
46
+ "model_gb": 261.448794112,
47
+ "expert_mb": 12.582912,
48
+ "dram_experts": 1907,
49
+ "frac": 0.093115234375
50
+ },
51
+ {
52
+ "bits": 1.5,
53
+ "model_gb": 196.086595584,
54
+ "expert_mb": 9.437184,
55
+ "dram_experts": 2543,
56
+ "frac": 0.124169921875
57
+ },
58
+ {
59
+ "bits": 1.0,
60
+ "model_gb": 130.724397056,
61
+ "expert_mb": 6.291456,
62
+ "dram_experts": 3814,
63
+ "frac": 0.18623046875
64
+ }
65
+ ],
66
+ "zipf_s": 0.6527289058070496,
67
+ "zipf_bias_pp": 6.841874865295161,
68
+ "token_working_set": 512,
69
+ "projection": [
70
+ {
71
+ "rate_bits": 1.0,
72
+ "hit_rate": 0.4367962797108301,
73
+ "batch": 1,
74
+ "total_gb": 130.724397056,
75
+ "expert_mb": 6.291456,
76
+ "dram_slots": 3814,
77
+ "vram_slots": 284,
78
+ "cache_frac": 0.18623046875,
79
+ "resident_gb": 1.610612736,
80
+ "io_bw_gbs": 5.649691120951909,
81
+ "bytes_per_token_mb": 1759.091443393542,
82
+ "tok_s": 3.2117097392349523,
83
+ "cap_slots": 3814,
84
+ "lru_viable": true
85
+ },
86
+ {
87
+ "rate_bits": 1.0,
88
+ "hit_rate": 0.4367962797108301,
89
+ "batch": 8,
90
+ "total_gb": 130.724397056,
91
+ "expert_mb": 6.291456,
92
+ "dram_slots": 3814,
93
+ "vram_slots": 284,
94
+ "cache_frac": 0.18623046875,
95
+ "resident_gb": 1.610612736,
96
+ "io_bw_gbs": 5.649691120951909,
97
+ "bytes_per_token_mb": 1467.4761276341483,
98
+ "tok_s": 3.8499373274714115,
99
+ "cap_slots": 3814,
100
+ "lru_viable": true
101
+ },
102
+ {
103
+ "rate_bits": 1.0,
104
+ "hit_rate": 0.4367962797108301,
105
+ "batch": 32,
106
+ "total_gb": 130.724397056,
107
+ "expert_mb": 6.291456,
108
+ "dram_slots": 3814,
109
+ "vram_slots": 284,
110
+ "cache_frac": 0.18623046875,
111
+ "resident_gb": 1.610612736,
112
+ "io_bw_gbs": 5.649691120951909,
113
+ "bytes_per_token_mb": 1030.5399589031413,
114
+ "tok_s": 5.482263033221125,
115
+ "cap_slots": 3814,
116
+ "lru_viable": true
117
+ },
118
+ {
119
+ "rate_bits": 1.5,
120
+ "hit_rate": 0.35517904351866053,
121
+ "batch": 1,
122
+ "total_gb": 196.086595584,
123
+ "expert_mb": 9.437184,
124
+ "dram_slots": 2543,
125
+ "vram_slots": 104,
126
+ "cache_frac": 0.124169921875,
127
+ "resident_gb": 2.415919104,
128
+ "io_bw_gbs": 5.45683685038166,
129
+ "bytes_per_token_mb": 3021.0179359737863,
130
+ "tok_s": 1.8062907821243104,
131
+ "cap_slots": 2543,
132
+ "lru_viable": true
133
+ },
134
+ {
135
+ "rate_bits": 1.5,
136
+ "hit_rate": 0.35517904351866053,
137
+ "batch": 8,
138
+ "total_gb": 196.086595584,
139
+ "expert_mb": 9.437184,
140
+ "dram_slots": 2543,
141
+ "vram_slots": 104,
142
+ "cache_frac": 0.124169921875,
143
+ "resident_gb": 2.415919104,
144
+ "io_bw_gbs": 5.45683685038166,
145
+ "bytes_per_token_mb": 2520.2053701334007,
146
+ "tok_s": 2.1652349903900157,
147
+ "cap_slots": 2543,
148
+ "lru_viable": true
149
+ },
150
+ {
151
+ "rate_bits": 1.5,
152
+ "hit_rate": 0.35517904351866053,
153
+ "batch": 32,
154
+ "total_gb": 196.086595584,
155
+ "expert_mb": 9.437184,
156
+ "dram_slots": 2543,
157
+ "vram_slots": 104,
158
+ "cache_frac": 0.124169921875,
159
+ "resident_gb": 2.415919104,
160
+ "io_bw_gbs": 5.45683685038166,
161
+ "bytes_per_token_mb": 1769.8225474726378,
162
+ "tok_s": 3.0832677875949734,
163
+ "cap_slots": 2543,
164
+ "lru_viable": true
165
+ },
166
+ {
167
+ "rate_bits": 2.0,
168
+ "hit_rate": 0.30395889352693944,
169
+ "batch": 1,
170
+ "total_gb": 261.448794112,
171
+ "expert_mb": 12.582912,
172
+ "dram_slots": 1907,
173
+ "vram_slots": 14,
174
+ "cache_frac": 0.093115234375,
175
+ "resident_gb": 3.221225472,
176
+ "io_bw_gbs": 5.320004567826719,
177
+ "bytes_per_token_mb": 4347.982481430631,
178
+ "tok_s": 1.2235570383614471,
179
+ "cap_slots": 1907,
180
+ "lru_viable": true
181
+ },
182
+ {
183
+ "rate_bits": 2.0,
184
+ "hit_rate": 0.30395889352693944,
185
+ "batch": 8,
186
+ "total_gb": 261.448794112,
187
+ "expert_mb": 12.582912,
188
+ "dram_slots": 1907,
189
+ "vram_slots": 14,
190
+ "cache_frac": 0.093115234375,
191
+ "resident_gb": 3.221225472,
192
+ "io_bw_gbs": 5.320004567826719,
193
+ "bytes_per_token_mb": 3627.1909108726686,
194
+ "tok_s": 1.4667010087282046,
195
+ "cap_slots": 1907,
196
+ "lru_viable": true
197
+ },
198
+ {
199
+ "rate_bits": 2.0,
200
+ "hit_rate": 0.30395889352693944,
201
+ "batch": 32,
202
+ "total_gb": 261.448794112,
203
+ "expert_mb": 12.582912,
204
+ "dram_slots": 1907,
205
+ "vram_slots": 14,
206
+ "cache_frac": 0.093115234375,
207
+ "resident_gb": 3.221225472,
208
+ "io_bw_gbs": 5.320004567826719,
209
+ "bytes_per_token_mb": 2547.2068007340467,
210
+ "tok_s": 2.088564056241376,
211
+ "cap_slots": 1907,
212
+ "lru_viable": true
213
+ },
214
+ {
215
+ "rate_bits": 3.0,
216
+ "hit_rate": 0.2401688791612775,
217
+ "batch": 1,
218
+ "total_gb": 392.173191168,
219
+ "expert_mb": 18.874368,
220
+ "dram_slots": 1271,
221
+ "vram_slots": 0,
222
+ "cache_frac": 0.062060546875,
223
+ "resident_gb": 4.831838208,
224
+ "io_bw_gbs": 5.183172285271779,
225
+ "bytes_per_token_mb": 7119.69243955946,
226
+ "tok_s": 0.7280050829825586,
227
+ "cap_slots": 1271,
228
+ "lru_viable": true
229
+ },
230
+ {
231
+ "rate_bits": 3.0,
232
+ "hit_rate": 0.2401688791612775,
233
+ "batch": 8,
234
+ "total_gb": 392.173191168,
235
+ "expert_mb": 18.874368,
236
+ "dram_slots": 1271,
237
+ "vram_slots": 0,
238
+ "cache_frac": 0.062060546875,
239
+ "resident_gb": 4.831838208,
240
+ "io_bw_gbs": 5.183172285271779,
241
+ "bytes_per_token_mb": 5939.417606963728,
242
+ "tok_s": 0.8726734889283956,
243
+ "cap_slots": 1271,
244
+ "lru_viable": true
245
+ },
246
+ {
247
+ "rate_bits": 3.0,
248
+ "hit_rate": 0.2401688791612775,
249
+ "batch": 32,
250
+ "total_gb": 392.173191168,
251
+ "expert_mb": 18.874368,
252
+ "dram_slots": 1271,
253
+ "vram_slots": 0,
254
+ "cache_frac": 0.062060546875,
255
+ "resident_gb": 4.831838208,
256
+ "io_bw_gbs": 5.183172285271779,
257
+ "bytes_per_token_mb": 4170.975637237044,
258
+ "tok_s": 1.2426762311911366,
259
+ "cap_slots": 1271,
260
+ "lru_viable": true
261
+ },
262
+ {
263
+ "rate_bits": 4.0,
264
+ "hit_rate": 0.20026908899632856,
265
+ "batch": 1,
266
+ "total_gb": 522.897588224,
267
+ "expert_mb": 25.165824,
268
+ "dram_slots": 953,
269
+ "vram_slots": 0,
270
+ "cache_frac": 0.046533203125,
271
+ "resident_gb": 6.442450944,
272
+ "io_bw_gbs": 5.183172285271779,
273
+ "bytes_per_token_mb": 9991.409870954525,
274
+ "tok_s": 0.5187628525118855,
275
+ "cap_slots": 953,
276
+ "lru_viable": true
277
+ },
278
+ {
279
+ "rate_bits": 4.0,
280
+ "hit_rate": 0.20026908899632856,
281
+ "batch": 8,
282
+ "total_gb": 522.897588224,
283
+ "expert_mb": 25.165824,
284
+ "dram_slots": 953,
285
+ "vram_slots": 0,
286
+ "cache_frac": 0.046533203125,
287
+ "resident_gb": 6.442450944,
288
+ "io_bw_gbs": 5.183172285271779,
289
+ "bytes_per_token_mb": 8335.072927617983,
290
+ "tok_s": 0.6218508620479507,
291
+ "cap_slots": 953,
292
+ "lru_viable": true
293
+ },
294
+ {
295
+ "rate_bits": 4.0,
296
+ "hit_rate": 0.20026908899632856,
297
+ "batch": 32,
298
+ "total_gb": 522.897588224,
299
+ "expert_mb": 25.165824,
300
+ "dram_slots": 953,
301
+ "vram_slots": 0,
302
+ "cache_frac": 0.046533203125,
303
+ "resident_gb": 6.442450944,
304
+ "io_bw_gbs": 5.183172285271779,
305
+ "bytes_per_token_mb": 5853.332500972426,
306
+ "tok_s": 0.8855079195331359,
307
+ "cap_slots": 953,
308
+ "lru_viable": true
309
+ },
310
+ {
311
+ "rate_bits": 16.0,
312
+ "hit_rate": 0.05849908967870593,
313
+ "batch": 1,
314
+ "total_gb": 2091.590352896,
315
+ "expert_mb": 100.663296,
316
+ "dram_slots": 238,
317
+ "vram_slots": 0,
318
+ "cache_frac": 0.01162109375,
319
+ "resident_gb": 25.769803776,
320
+ "io_bw_gbs": 5.183172285271779,
321
+ "bytes_per_token_mb": 47050.43338685536,
322
+ "tok_s": 0.11016205191257217,
323
+ "cap_slots": 238,
324
+ "lru_viable": false
325
+ },
326
+ {
327
+ "rate_bits": 16.0,
328
+ "hit_rate": 0.05849908967870593,
329
+ "batch": 8,
330
+ "total_gb": 2091.590352896,
331
+ "expert_mb": 100.663296,
332
+ "dram_slots": 238,
333
+ "vram_slots": 0,
334
+ "cache_frac": 0.01162109375,
335
+ "resident_gb": 25.769803776,
336
+ "io_bw_gbs": 5.183172285271779,
337
+ "bytes_per_token_mb": 39250.596124128955,
338
+ "tok_s": 0.13205333923796053,
339
+ "cap_slots": 238,
340
+ "lru_viable": false
341
+ },
342
+ {
343
+ "rate_bits": 16.0,
344
+ "hit_rate": 0.05849908967870593,
345
+ "batch": 32,
346
+ "total_gb": 2091.590352896,
347
+ "expert_mb": 100.663296,
348
+ "dram_slots": 238,
349
+ "vram_slots": 0,
350
+ "cache_frac": 0.01162109375,
351
+ "resident_gb": 25.769803776,
352
+ "io_bw_gbs": 5.183172285271779,
353
+ "bytes_per_token_mb": 27563.86080494246,
354
+ "tok_s": 0.18804231823512865,
355
+ "cap_slots": 238,
356
+ "lru_viable": false
357
+ }
358
+ ],
359
+ "sensitivity_1p5bit": [
360
+ {
361
+ "rate_bits": 1.5,
362
+ "hit_rate": 0.0,
363
+ "batch": 1,
364
+ "total_gb": 196.086595584,
365
+ "expert_mb": 9.437184,
366
+ "dram_slots": 2543,
367
+ "vram_slots": 104,
368
+ "cache_frac": 0.124169921875,
369
+ "resident_gb": 2.415919104,
370
+ "io_bw_gbs": 5.45683685038166,
371
+ "bytes_per_token_mb": 4685.049246009132,
372
+ "tok_s": 1.1647341498128245
373
+ },
374
+ {
375
+ "rate_bits": 1.5,
376
+ "hit_rate": 0.05,
377
+ "batch": 1,
378
+ "total_gb": 196.086595584,
379
+ "expert_mb": 9.437184,
380
+ "dram_slots": 2543,
381
+ "vram_slots": 104,
382
+ "cache_frac": 0.124169921875,
383
+ "resident_gb": 2.415919104,
384
+ "io_bw_gbs": 5.45683685038166,
385
+ "bytes_per_token_mb": 4450.796783708675,
386
+ "tok_s": 1.2260359471713942
387
+ },
388
+ {
389
+ "rate_bits": 1.5,
390
+ "hit_rate": 0.1,
391
+ "batch": 1,
392
+ "total_gb": 196.086595584,
393
+ "expert_mb": 9.437184,
394
+ "dram_slots": 2543,
395
+ "vram_slots": 104,
396
+ "cache_frac": 0.124169921875,
397
+ "resident_gb": 2.415919104,
398
+ "io_bw_gbs": 5.45683685038166,
399
+ "bytes_per_token_mb": 4216.544321408219,
400
+ "tok_s": 1.2941490553475827
401
+ },
402
+ {
403
+ "rate_bits": 1.5,
404
+ "hit_rate": 0.15000000000000002,
405
+ "batch": 1,
406
+ "total_gb": 196.086595584,
407
+ "expert_mb": 9.437184,
408
+ "dram_slots": 2543,
409
+ "vram_slots": 104,
410
+ "cache_frac": 0.124169921875,
411
+ "resident_gb": 2.415919104,
412
+ "io_bw_gbs": 5.45683685038166,
413
+ "bytes_per_token_mb": 3982.291859107762,
414
+ "tok_s": 1.3702754703680289
415
+ },
416
+ {
417
+ "rate_bits": 1.5,
418
+ "hit_rate": 0.2,
419
+ "batch": 1,
420
+ "total_gb": 196.086595584,
421
+ "expert_mb": 9.437184,
422
+ "dram_slots": 2543,
423
+ "vram_slots": 104,
424
+ "cache_frac": 0.124169921875,
425
+ "resident_gb": 2.415919104,
426
+ "io_bw_gbs": 5.45683685038166,
427
+ "bytes_per_token_mb": 3748.0393968073054,
428
+ "tok_s": 1.4559176872660304
429
+ },
430
+ {
431
+ "rate_bits": 1.5,
432
+ "hit_rate": 0.25,
433
+ "batch": 1,
434
+ "total_gb": 196.086595584,
435
+ "expert_mb": 9.437184,
436
+ "dram_slots": 2543,
437
+ "vram_slots": 104,
438
+ "cache_frac": 0.124169921875,
439
+ "resident_gb": 2.415919104,
440
+ "io_bw_gbs": 5.45683685038166,
441
+ "bytes_per_token_mb": 3513.786934506849,
442
+ "tok_s": 1.5529788664170994
443
+ },
444
+ {
445
+ "rate_bits": 1.5,
446
+ "hit_rate": 0.30000000000000004,
447
+ "batch": 1,
448
+ "total_gb": 196.086595584,
449
+ "expert_mb": 9.437184,
450
+ "dram_slots": 2543,
451
+ "vram_slots": 104,
452
+ "cache_frac": 0.124169921875,
453
+ "resident_gb": 2.415919104,
454
+ "io_bw_gbs": 5.45683685038166,
455
+ "bytes_per_token_mb": 3279.5344722063924,
456
+ "tok_s": 1.663905928304035
457
+ },
458
+ {
459
+ "rate_bits": 1.5,
460
+ "hit_rate": 0.35000000000000003,
461
+ "batch": 1,
462
+ "total_gb": 196.086595584,
463
+ "expert_mb": 9.437184,
464
+ "dram_slots": 2543,
465
+ "vram_slots": 104,
466
+ "cache_frac": 0.124169921875,
467
+ "resident_gb": 2.415919104,
468
+ "io_bw_gbs": 5.45683685038166,
469
+ "bytes_per_token_mb": 3045.2820099059354,
470
+ "tok_s": 1.7918986920197302
471
+ },
472
+ {
473
+ "rate_bits": 1.5,
474
+ "hit_rate": 0.4,
475
+ "batch": 1,
476
+ "total_gb": 196.086595584,
477
+ "expert_mb": 9.437184,
478
+ "dram_slots": 2543,
479
+ "vram_slots": 104,
480
+ "cache_frac": 0.124169921875,
481
+ "resident_gb": 2.415919104,
482
+ "io_bw_gbs": 5.45683685038166,
483
+ "bytes_per_token_mb": 2811.0295476054794,
484
+ "tok_s": 1.941223583021374
485
+ },
486
+ {
487
+ "rate_bits": 1.5,
488
+ "hit_rate": 0.45,
489
+ "batch": 1,
490
+ "total_gb": 196.086595584,
491
+ "expert_mb": 9.437184,
492
+ "dram_slots": 2543,
493
+ "vram_slots": 104,
494
+ "cache_frac": 0.124169921875,
495
+ "resident_gb": 2.415919104,
496
+ "io_bw_gbs": 5.45683685038166,
497
+ "bytes_per_token_mb": 2576.7770853050224,
498
+ "tok_s": 2.1176984542051356
499
+ },
500
+ {
501
+ "rate_bits": 1.5,
502
+ "hit_rate": 0.5,
503
+ "batch": 1,
504
+ "total_gb": 196.086595584,
505
+ "expert_mb": 9.437184,
506
+ "dram_slots": 2543,
507
+ "vram_slots": 104,
508
+ "cache_frac": 0.124169921875,
509
+ "resident_gb": 2.415919104,
510
+ "io_bw_gbs": 5.45683685038166,
511
+ "bytes_per_token_mb": 2342.524623004566,
512
+ "tok_s": 2.329468299625649
513
+ },
514
+ {
515
+ "rate_bits": 1.5,
516
+ "hit_rate": 0.55,
517
+ "batch": 1,
518
+ "total_gb": 196.086595584,
519
+ "expert_mb": 9.437184,
520
+ "dram_slots": 2543,
521
+ "vram_slots": 104,
522
+ "cache_frac": 0.124169921875,
523
+ "resident_gb": 2.415919104,
524
+ "io_bw_gbs": 5.45683685038166,
525
+ "bytes_per_token_mb": 2108.272160704109,
526
+ "tok_s": 2.588298110695166
527
+ },
528
+ {
529
+ "rate_bits": 1.5,
530
+ "hit_rate": 0.6000000000000001,
531
+ "batch": 1,
532
+ "total_gb": 196.086595584,
533
+ "expert_mb": 9.437184,
534
+ "dram_slots": 2543,
535
+ "vram_slots": 104,
536
+ "cache_frac": 0.124169921875,
537
+ "resident_gb": 2.415919104,
538
+ "io_bw_gbs": 5.45683685038166,
539
+ "bytes_per_token_mb": 1874.0196984036522,
540
+ "tok_s": 2.911835374532062
541
+ },
542
+ {
543
+ "rate_bits": 1.5,
544
+ "hit_rate": 0.65,
545
+ "batch": 1,
546
+ "total_gb": 196.086595584,
547
+ "expert_mb": 9.437184,
548
+ "dram_slots": 2543,
549
+ "vram_slots": 104,
550
+ "cache_frac": 0.124169921875,
551
+ "resident_gb": 2.415919104,
552
+ "io_bw_gbs": 5.45683685038166,
553
+ "bytes_per_token_mb": 1639.7672361031962,
554
+ "tok_s": 3.32781185660807
555
+ },
556
+ {
557
+ "rate_bits": 1.5,
558
+ "hit_rate": 0.7000000000000001,
559
+ "batch": 1,
560
+ "total_gb": 196.086595584,
561
+ "expert_mb": 9.437184,
562
+ "dram_slots": 2543,
563
+ "vram_slots": 104,
564
+ "cache_frac": 0.124169921875,
565
+ "resident_gb": 2.415919104,
566
+ "io_bw_gbs": 5.45683685038166,
567
+ "bytes_per_token_mb": 1405.5147738027392,
568
+ "tok_s": 3.8824471660427498
569
+ },
570
+ {
571
+ "rate_bits": 1.5,
572
+ "hit_rate": 0.75,
573
+ "batch": 1,
574
+ "total_gb": 196.086595584,
575
+ "expert_mb": 9.437184,
576
+ "dram_slots": 2543,
577
+ "vram_slots": 104,
578
+ "cache_frac": 0.124169921875,
579
+ "resident_gb": 2.415919104,
580
+ "io_bw_gbs": 5.45683685038166,
581
+ "bytes_per_token_mb": 1171.262311502283,
582
+ "tok_s": 4.658936599251298
583
+ },
584
+ {
585
+ "rate_bits": 1.5,
586
+ "hit_rate": 0.8,
587
+ "batch": 1,
588
+ "total_gb": 196.086595584,
589
+ "expert_mb": 9.437184,
590
+ "dram_slots": 2543,
591
+ "vram_slots": 104,
592
+ "cache_frac": 0.124169921875,
593
+ "resident_gb": 2.415919104,
594
+ "io_bw_gbs": 5.45683685038166,
595
+ "bytes_per_token_mb": 937.0098492018261,
596
+ "tok_s": 5.823670749064124
597
+ },
598
+ {
599
+ "rate_bits": 1.5,
600
+ "hit_rate": 0.8500000000000001,
601
+ "batch": 1,
602
+ "total_gb": 196.086595584,
603
+ "expert_mb": 9.437184,
604
+ "dram_slots": 2543,
605
+ "vram_slots": 104,
606
+ "cache_frac": 0.124169921875,
607
+ "resident_gb": 2.415919104,
608
+ "io_bw_gbs": 5.45683685038166,
609
+ "bytes_per_token_mb": 702.7573869013694,
610
+ "tok_s": 7.7648943320855
611
+ },
612
+ {
613
+ "rate_bits": 1.5,
614
+ "hit_rate": 0.9,
615
+ "batch": 1,
616
+ "total_gb": 196.086595584,
617
+ "expert_mb": 9.437184,
618
+ "dram_slots": 2543,
619
+ "vram_slots": 104,
620
+ "cache_frac": 0.124169921875,
621
+ "resident_gb": 2.415919104,
622
+ "io_bw_gbs": 5.45683685038166,
623
+ "bytes_per_token_mb": 468.50492460091306,
624
+ "tok_s": 11.647341498128249
625
+ },
626
+ {
627
+ "rate_bits": 1.5,
628
+ "hit_rate": 0.9500000000000001,
629
+ "batch": 1,
630
+ "total_gb": 196.086595584,
631
+ "expert_mb": 9.437184,
632
+ "dram_slots": 2543,
633
+ "vram_slots": 104,
634
+ "cache_frac": 0.124169921875,
635
+ "resident_gb": 2.415919104,
636
+ "io_bw_gbs": 5.45683685038166,
637
+ "bytes_per_token_mb": 234.25246230045627,
638
+ "tok_s": 23.29468299625652
639
+ }
640
+ ]
641
+ }
results/quant_freq15.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 1.5103125,
22
+ 1.5103125,
23
+ 1.5103125,
24
+ 1.5103125,
25
+ 1.5103125,
26
+ 1.5103125,
27
+ 1.5103125,
28
+ 1.5103125,
29
+ 1.5103125,
30
+ 1.5103125,
31
+ 1.5103125,
32
+ 1.5103125,
33
+ 1.5103125,
34
+ 1.5103125,
35
+ 1.5103125,
36
+ 1.5103125
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 1.5103125,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 22.018173217773438,
59
+ "config": {
60
+ "stages": 3,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": false,
65
+ "alloc": "freq",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": null,
69
+ "fp16": false,
70
+ "tag": "freq15"
71
+ },
72
+ "ppl_secs": 36.206817388534546
73
+ }
results/quant_main10.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 1.0103125,
22
+ 1.0103125,
23
+ 1.0103125,
24
+ 1.0103125,
25
+ 1.0103125,
26
+ 1.0103125,
27
+ 1.0103125,
28
+ 1.0103125,
29
+ 1.0103125,
30
+ 1.0103125,
31
+ 1.0103125,
32
+ 1.0103125,
33
+ 1.0103125,
34
+ 1.0103125,
35
+ 1.0103125,
36
+ 1.0103125
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 1.0103125,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 156.0718231201172,
59
+ "config": {
60
+ "stages": 2,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": false,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": null,
69
+ "fp16": false,
70
+ "tag": "main10"
71
+ },
72
+ "ppl_secs": 36.35476326942444
73
+ }
results/quant_main15.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 1.5103125,
22
+ 1.5103125,
23
+ 1.5103125,
24
+ 1.5103125,
25
+ 1.5103125,
26
+ 1.5103125,
27
+ 1.5103125,
28
+ 1.5103125,
29
+ 1.5103125,
30
+ 1.5103125,
31
+ 1.5103125,
32
+ 1.5103125,
33
+ 1.5103125,
34
+ 1.5103125,
35
+ 1.5103125,
36
+ 1.5103125
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 1.5103125,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 25.54167938232422,
59
+ "config": {
60
+ "stages": 3,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": false,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": null,
69
+ "fp16": false,
70
+ "tag": "main15"
71
+ },
72
+ "ppl_secs": 37.337796211242676
73
+ }
results/quant_main20.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 2.0103125,
22
+ 2.0103125,
23
+ 2.0103125,
24
+ 2.0103125,
25
+ 2.0103125,
26
+ 2.0103125,
27
+ 2.0103125,
28
+ 2.0103125,
29
+ 2.0103125,
30
+ 2.0103125,
31
+ 2.0103125,
32
+ 2.0103125,
33
+ 2.0103125,
34
+ 2.0103125,
35
+ 2.0103125,
36
+ 2.0103125
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 2.0103125,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 12.165743827819824,
59
+ "config": {
60
+ "stages": 4,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": false,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": null,
69
+ "fp16": false,
70
+ "tag": "main20"
71
+ },
72
+ "ppl_secs": 36.14291453361511
73
+ }
results/quant_noldlq15.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 1.5103125,
22
+ 1.5103125,
23
+ 1.5103125,
24
+ 1.5103125,
25
+ 1.5103125,
26
+ 1.5103125,
27
+ 1.5103125,
28
+ 1.5103125,
29
+ 1.5103125,
30
+ 1.5103125,
31
+ 1.5103125,
32
+ 1.5103125,
33
+ 1.5103125,
34
+ 1.5103125,
35
+ 1.5103125,
36
+ 1.5103125
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 1.5103125,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 7701.97509765625,
59
+ "config": {
60
+ "stages": 3,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": true,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": null,
69
+ "fp16": false,
70
+ "tag": "noldlq15"
71
+ },
72
+ "ppl_secs": 36.23133039474487
73
+ }
results/quant_northt15.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 1.5103125,
22
+ 1.5103125,
23
+ 1.5103125,
24
+ 1.5103125,
25
+ 1.5103125,
26
+ 1.5103125,
27
+ 1.5103125,
28
+ 1.5103125,
29
+ 1.5103125,
30
+ 1.5103125,
31
+ 1.5103125,
32
+ 1.5103125,
33
+ 1.5103125,
34
+ 1.5103125,
35
+ 1.5103125,
36
+ 1.5103125
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 1.5103125,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 352.1000671386719,
59
+ "config": {
60
+ "stages": 3,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": true,
64
+ "no_ldlq": false,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": null,
69
+ "fp16": false,
70
+ "tag": "northt15"
71
+ },
72
+ "ppl_secs": 36.26489615440369
73
+ }
results/quant_rtn2.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 2.25,
22
+ 2.25,
23
+ 2.25,
24
+ 2.25,
25
+ 2.25,
26
+ 2.25,
27
+ 2.25,
28
+ 2.25,
29
+ 2.25,
30
+ 2.25,
31
+ 2.25,
32
+ 2.25,
33
+ 2.25,
34
+ 2.25,
35
+ 2.25,
36
+ 2.25
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 2.25,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 22793.90234375,
59
+ "config": {
60
+ "stages": 3,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": false,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": 2,
69
+ "fp16": false,
70
+ "tag": "rtn2"
71
+ },
72
+ "ppl_secs": 35.358806133270264
73
+ }
results/quant_rtn3.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layers": [
3
+ 0,
4
+ 1,
5
+ 2,
6
+ 3,
7
+ 4,
8
+ 5,
9
+ 6,
10
+ 7,
11
+ 8,
12
+ 9,
13
+ 10,
14
+ 11,
15
+ 12,
16
+ 13,
17
+ 14,
18
+ 15
19
+ ],
20
+ "bits": [
21
+ 3.25,
22
+ 3.25,
23
+ 3.25,
24
+ 3.25,
25
+ 3.25,
26
+ 3.25,
27
+ 3.25,
28
+ 3.25,
29
+ 3.25,
30
+ 3.25,
31
+ 3.25,
32
+ 3.25,
33
+ 3.25,
34
+ 3.25,
35
+ 3.25,
36
+ 3.25
37
+ ],
38
+ "params": [
39
+ 419430400,
40
+ 419430400,
41
+ 419430400,
42
+ 419430400,
43
+ 419430400,
44
+ 419430400,
45
+ 419430400,
46
+ 419430400,
47
+ 419430400,
48
+ 419430400,
49
+ 419430400,
50
+ 419430400,
51
+ 419430400,
52
+ 419430400,
53
+ 419430400,
54
+ 419430400
55
+ ],
56
+ "avg_bits": 3.25,
57
+ "quantized_params": 6710886400,
58
+ "ppl": 10.492335319519043,
59
+ "config": {
60
+ "stages": 3,
61
+ "nsamples": 32,
62
+ "seqlen": 2048,
63
+ "no_rht": false,
64
+ "no_ldlq": false,
65
+ "alloc": "uniform",
66
+ "spread": 1,
67
+ "ppl_limit": 20,
68
+ "rtn": 3,
69
+ "fp16": false,
70
+ "tag": "rtn3"
71
+ },
72
+ "ppl_secs": 35.27370619773865
73
+ }
results/routing_freq.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"0": [0.010378519694010416, 0.008371988932291666, 0.009244283040364584, 0.017913818359375, 0.0103302001953125, 0.017911275227864582, 0.02248382568359375, 0.016405741373697918, 0.011789957682291666, 0.025960286458333332, 0.012369791666666666, 0.0136566162109375, 0.0322113037109375, 0.019254048665364582, 0.013170878092447916, 0.010434468587239584, 0.016161600748697918, 0.023462931315104168, 0.020952860514322918, 0.024920145670572918, 0.01148223876953125, 0.0019709269205729165, 0.02022552490234375, 0.004486083984375, 0.012613932291666666, 0.015462239583333334, 0.02184295654296875, 0.008997599283854166, 0.037732442220052086, 0.019683837890625, 0.014806111653645834, 0.010945638020833334, 0.0104217529296875, 0.013275146484375, 0.0030949910481770835, 0.00989532470703125, 0.00820159912109375, 0.010938008626302084, 0.017865498860677082, 0.01351165771484375, 0.0152587890625, 0.044888814290364586, 0.0119781494140625, 0.013567606608072916, 0.01532745361328125, 0.014673868815104166, 0.027715047200520832, 0.011296590169270834, 0.0115966796875, 0.014523824055989584, 0.010645548502604166, 0.022791544596354168, 0.004193623860677083, 0.02054595947265625, 0.027041117350260418, 0.01636505126953125, 0.009226481119791666, 0.025571187337239582, 0.019287109375, 0.0133819580078125, 0.016466776529947918, 0.015920003255208332, 0.009534200032552084, 0.00336456298828125], "1": [0.01065826416015625, 0.011322021484375, 0.011751810709635416, 0.011037190755208334, 0.01058197021484375, 0.05185699462890625, 0.0096282958984375, 0.012906392415364584, 0.01880645751953125, 0.018964131673177082, 0.007273356119791667, 0.0311126708984375, 0.016156514485677082, 0.0187530517578125, 0.015825907389322918, 0.01287078857421875, 0.0189666748046875, 0.013702392578125, 0.03275299072265625, 0.01349639892578125, 0.013516743977864584, 0.018946329752604168, 0.011202494303385416, 0.017613728841145832, 0.009351094563802084, 0.0015385945638020833, 0.011014302571614584, 0.019343058268229168, 0.0081634521484375, 0.018308003743489582, 0.011263529459635416, 0.01441192626953125, 0.020495096842447918, 0.009577433268229166, 0.009760538736979166, 0.020205179850260418, 0.009607950846354166, 0.02588653564453125, 0.010556538899739584, 0.0151214599609375, 0.019711812337239582, 0.01568603515625, 0.026606241861979168, 0.00888824462890625, 0.01317596435546875, 0.01776123046875, 0.0090789794921875, 0.028948465983072918, 0.0184478759765625, 0.01132965087890625, 0.01511383056640625, 0.015652974446614582, 0.013913472493489584, 0.021191914876302082, 0.01445770263671875, 0.01197052001953125, 0.00891876220703125, 0.011260986328125, 0.01146697998046875, 0.026392618815104168, 0.00675201416015625, 0.018475850423177082, 0.017779032389322918, 0.0127105712890625], "2": [0.009691874186197916, 0.0171661376953125, 0.008822123209635416, 0.0106353759765625, 0.0065460205078125, 0.0003153483072916667, 0.009450276692708334, 0.013033548990885416, 0.0020879109700520835, 0.03218841552734375, 0.049143473307291664, 0.010302225748697916, 0.011263529459635416, 0.010775248209635416, 0.021535237630208332, 0.01019287109375, 0.019915262858072918, 0.010617574055989584, 0.012163798014322916, 0.01507568359375, 0.015764872233072918, 0.015848795572916668, 0.01787567138671875, 0.015703837076822918, 0.010358174641927084, 0.018435160319010418, 0.017346700032552082, 0.01615142822265625, 0.021779378255208332, 0.022572835286458332, 0.008982340494791666, 0.009432474772135416, 0.016604105631510418, 0.013799031575520834, 0.020334879557291668, 0.01567840576171875, 0.05517578125, 0.012054443359375, 0.022806803385416668, 0.015118916829427084, 0.0031000773111979165, 0.00724029541015625, 0.00995635986328125, 0.011601765950520834, 0.021616617838541668, 0.0248260498046875, 0.01331329345703125, 0.010851542154947916, 0.01918792724609375, 0.011233011881510416, 0.011899312337239584, 0.0033416748046875, 0.007870992024739584, 0.0055084228515625, 0.013041178385416666, 0.009808858235677084, 0.01415252685546875, 0.02729034423828125, 0.027631123860677082, 0.027394612630208332, 0.02297210693359375, 0.02170562744140625, 0.009221394856770834, 0.022488911946614582], "3": [0.037816365559895836, 0.006235758463541667, 0.007548014322916667, 0.016721089680989582, 0.0201873779296875, 0.00853729248046875, 0.016682942708333332, 0.008623758951822916, 0.012524922688802084, 0.03018951416015625, 0.018826802571614582, 0.009625752766927084, 0.023648579915364582, 0.008595784505208334, 0.005279541015625, 0.00450897216796875, 0.0114593505859375, 0.01067352294921875, 0.016710917154947918, 0.015958150227864582, 0.02729034423828125, 0.004582722981770833, 0.02420806884765625, 0.032964070638020836, 0.02553558349609375, 0.032292683919270836, 0.00800323486328125, 0.010279337565104166, 0.017534891764322918, 0.01596832275390625, 0.025438944498697918, 0.028826395670572918, 0.011426289876302084, 0.0216217041015625, 0.009043375651041666, 0.0022023518880208335, 0.02126312255859375, 0.017827351888020832, 0.016482035319010418, 0.0037511189778645835, 0.023030598958333332, 0.01773834228515625, 0.014516194661458334, 0.00209808349609375, 0.011906941731770834, 0.007410685221354167, 0.010533650716145834, 0.018076578776041668, 0.027745564778645832, 0.022705078125, 0.01335906982421875, 0.014658610026041666, 0.031140645345052082, 0.008252461751302084, 0.014462788899739584, 0.008466084798177084, 0.015218098958333334, 0.015904744466145832, 0.013829549153645834, 0.021525065104166668, 0.012601216634114584, 0.016370137532552082, 0.0025889078776041665, 0.00896453857421875], "4": [0.005480448404947917, 0.012296040852864584, 0.008183797200520834, 0.008883158365885416, 0.018046061197916668, 0.01018524169921875, 0.014879862467447916, 0.01988983154296875, 0.021052042643229168, 0.004750569661458333, 0.02515411376953125, 0.008603413899739584, 0.0267181396484375, 0.0149078369140625, 0.01622772216796875, 0.0104217529296875, 0.0190277099609375, 0.00090789794921875, 0.0009511311848958334, 0.0009943644205729167, 0.008832295735677084, 0.02024078369140625, 0.01314544677734375, 0.023890177408854168, 0.01515960693359375, 0.01001739501953125, 0.057523091634114586, 0.007937113444010416, 0.019175211588541668, 0.03563690185546875, 0.008173624674479166, 0.00052642822265625, 0.0182647705078125, 0.010607401529947916, 0.0355682373046875, 0.02922821044921875, 0.013338724772135416, 0.026425679524739582, 0.012646993001302084, 0.012204488118489584, 0.011057535807291666, 0.01334381103515625, 0.01471710205078125, 0.022641499837239582, 0.008059183756510416, 0.015157063802083334, 0.011739095052083334, 0.03094482421875, 0.0014750162760416667, 0.0358123779296875, 0.022176106770833332, 0.019439697265625, 0.015841166178385418, 0.014851888020833334, 0.007410685221354167, 0.0008392333984375, 0.013364156087239584, 0.01073455810546875, 0.023348490397135418, 0.0169219970703125, 0.014882405598958334, 0.012644449869791666, 0.032124837239583336, 0.004369099934895833], "5": [0.007481892903645833, 0.01291656494140625, 0.00662994384765625, 0.006444295247395833, 0.0086822509765625, 0.0120849609375, 0.025822957356770832, 0.0091094970703125, 0.020413716634114582, 0.014737447102864584, 0.029558817545572918, 0.013468424479166666, 0.006014506022135417, 0.0111236572265625, 0.015317281087239584, 0.01094818115234375, 0.013455708821614584, 0.019152323404947918, 0.021677652994791668, 0.020701090494791668, 0.02884674072265625, 0.011500040690104166, 0.014645894368489584, 0.025731404622395832, 0.005839029947916667, 0.010899861653645834, 0.00954437255859375, 0.01323699951171875, 0.027394612630208332, 0.0005340576171875, 0.016878763834635418, 0.006991068522135417, 0.014650980631510416, 0.004834493001302083, 0.014750162760416666, 0.021212259928385418, 0.005706787109375, 0.03816986083984375, 0.020182291666666668, 0.006510416666666667, 0.038103739420572914, 0.00379180908203125, 0.00176239013671875, 0.0255279541015625, 0.039418538411458336, 0.015126546223958334, 0.0065155029296875, 0.00841522216796875, 0.005658467610677083, 0.017069498697916668, 0.027966817220052082, 0.0124053955078125, 0.0199737548828125, 0.014790852864583334, 0.021547953287760418, 0.01613616943359375, 0.013590494791666666, 0.024050394694010418, 0.015034993489583334, 0.008084615071614584, 0.008799235026041666, 0.013308207194010416, 0.018725077311197918, 0.040395100911458336], "6": [0.027567545572916668, 0.018796284993489582, 0.025723775227864582, 0.016092936197916668, 0.014836629231770834, 0.0075836181640625, 0.01705169677734375, 0.0098724365234375, 0.012377421061197916, 0.020749409993489582, 0.0029347737630208335, 0.0013707478841145833, 0.022343953450520832, 0.014353434244791666, 0.005160013834635417, 0.022710164388020832, 0.018346150716145832, 0.009775797526041666, 0.05783843994140625, 0.022036234537760418, 0.024495442708333332, 0.040283203125, 0.01683807373046875, 0.008244832356770834, 0.01772308349609375, 0.01432037353515625, 0.020388285319010418, 0.0206451416015625, 0.033437093098958336, 0.015291849772135416, 0.016843159993489582, 0.0037358601888020835, 0.01534271240234375, 0.0021489461263020835, 0.0004984537760416666, 0.025563557942708332, 0.010454813639322916, 0.021489461263020832, 0.0006815592447916666, 0.026397705078125, 0.015085856119791666, 0.00439453125, 0.00020853678385416666, 0.0010935465494791667, 0.01992034912109375, 0.02376556396484375, 0.008257548014322916, 0.021616617838541668, 0.021527608235677082, 0.00885009765625, 0.013773600260416666, 0.00815582275390625, 0.0006281534830729166, 0.0150909423828125, 0.01971435546875, 0.0203399658203125, 0.008534749348958334, 0.015167236328125, 0.010213216145833334, 0.013409932454427084, 0.004778544108072917, 0.027804056803385418, 0.019666035970052082, 0.015658060709635418], "7": [0.006917317708333333, 0.017664591471354168, 0.0019022623697916667, 0.010373433430989584, 0.019251505533854168, 0.027295430501302082, 0.00640869140625, 0.0038121541341145835, 0.0035400390625, 0.00553131103515625, 0.012669881184895834, 0.01195526123046875, 0.011884053548177084, 0.006398518880208333, 0.011998494466145834, 0.009831746419270834, 0.01629638671875, 0.0003763834635416667, 0.013219197591145834, 0.018908182779947918, 0.014628092447916666, 0.027737935384114582, 0.013399759928385416, 0.016955057779947918, 0.017621358235677082, 0.008420308430989584, 0.02088165283203125, 0.01508331298828125, 0.0006688435872395834, 0.020477294921875, 0.022806803385416668, 0.024388631184895832, 0.018419901529947918, 0.0131072998046875, 0.011136372884114584, 0.016398111979166668, 0.013135274251302084, 0.019620259602864582, 0.034032185872395836, 0.010467529296875, 0.02271270751953125, 0.016222635904947918, 0.012941996256510416, 0.043212890625, 0.038653055826822914, 0.007151285807291667, 0.02984619140625, 0.01611328125, 0.018269856770833332, 0.01503753662109375, 0.009976704915364584, 0.0046539306640625, 0.019070943196614582, 0.004290262858072917, 0.001556396484375, 0.0392303466796875, 0.01624298095703125, 0.013852437337239584, 0.017590840657552082, 0.017201741536458332, 0.0035730997721354165, 0.021502176920572918, 0.018096923828125, 0.037378946940104164], "8": [0.017262776692708332, 0.01354217529296875, 0.015050252278645834, 0.00020599365234375, 0.008519490559895834, 0.028912862141927082, 0.016535441080729168, 0.00202178955078125, 0.005366007486979167, 0.013928731282552084, 0.017687479654947918, 0.02367401123046875, 0.030232747395833332, 0.009124755859375, 0.006795247395833333, 0.034434000651041664, 0.013181050618489584, 0.022705078125, 0.039957682291666664, 0.007120768229166667, 0.025316874186197918, 0.014338175455729166, 0.009493509928385416, 0.016558329264322918, 0.0214691162109375, 0.016393025716145832, 0.023106892903645832, 0.017926534016927082, 0.017995198567708332, 0.009076436360677084, 0.014399210611979166, 0.00962066650390625, 0.008900960286458334, 0.019381205240885418, 0.024579366048177082, 0.0159149169921875, 0.012456258138020834, 0.0278472900390625, 0.0037943522135416665, 0.00284576416015625, 0.0133209228515625, 0.00882720947265625, 0.011792500813802084, 0.0035909016927083335, 0.01883697509765625, 0.02906036376953125, 0.005032857259114583, 0.009282430013020834, 0.012288411458333334, 0.008860270182291666, 0.015276590983072916, 0.014279683430989584, 0.020718892415364582, 0.01679229736328125, 0.00800323486328125, 0.026769002278645832, 0.035687764485677086, 0.02027130126953125, 0.016072591145833332, 0.004720052083333333, 0.0036493937174479165, 0.019465128580729168, 0.015050252278645834, 0.024678548177083332], "9": [0.020617167154947918, 0.01406097412109375, 0.014790852864583334, 0.006815592447916667, 0.0008443196614583334, 0.0070953369140625, 0.025011698404947918, 0.025052388509114582, 0.009958902994791666, 0.0179290771484375, 0.0225372314453125, 0.012440999348958334, 0.0069122314453125, 0.017590840657552082, 0.01589202880859375, 0.011751810709635416, 0.0149688720703125, 0.03600311279296875, 0.041910807291666664, 0.0025812784830729165, 0.015607198079427084, 0.015902201334635418, 0.009923299153645834, 0.014712015787760416, 0.010304768880208334, 0.006482442220052083, 0.0215301513671875, 0.01235198974609375, 0.015752156575520832, 0.015472412109375, 0.017384847005208332, 0.015218098958333334, 0.0216064453125, 0.01092529296875, 0.00739288330078125, 0.021687825520833332, 0.023813883463541668, 0.024762471516927082, 0.018468221028645832, 0.0019963582356770835, 0.018633524576822918, 0.021097819010416668, 0.013295491536458334, 0.0201568603515625, 0.013966878255208334, 0.00867462158203125, 0.00021107991536458334, 0.01056671142578125, 0.026685078938802082, 0.009244283040364584, 0.037442525227864586, 0.014312744140625, 0.01464080810546875, 0.016718546549479168, 0.019922892252604168, 0.020192464192708332, 0.0092620849609375, 0.00527191162109375, 0.020810445149739582, 0.015314737955729166, 0.0154571533203125, 0.006121317545572917, 0.011126200358072916, 0.024813334147135418], "10": [0.022707621256510418, 0.022394816080729168, 0.01651763916015625, 0.01314544677734375, 0.00560760498046875, 0.023289998372395832, 0.006228129069010417, 0.016489664713541668, 0.020617167154947918, 0.02289581298828125, 0.01531982421875, 0.014775594075520834, 0.0114288330078125, 0.023646036783854168, 0.016703287760416668, 0.011372884114583334, 0.012486775716145834, 0.027463277180989582, 0.011433919270833334, 0.0038731892903645835, 0.0038655598958333335, 0.008534749348958334, 0.005549112955729167, 0.021601359049479168, 0.0233306884765625, 0.00357818603515625, 0.009539286295572916, 0.012430826822916666, 0.012502034505208334, 0.012364705403645834, 0.012433369954427084, 0.031366984049479164, 0.019994099934895832, 0.011049906412760416, 0.016092936197916668, 0.0037206013997395835, 0.0212860107421875, 0.026204427083333332, 0.012326558430989584, 0.017636617024739582, 0.05213165283203125, 0.02103424072265625, 0.01181793212890625, 0.013234456380208334, 0.0164794921875, 0.012448628743489584, 0.009267171223958334, 0.024564107259114582, 0.01018524169921875, 0.017000834147135418, 0.011243184407552084, 0.012873331705729166, 0.016176859537760418, 0.021161397298177082, 0.032010396321614586, 0.01239013671875, 0.0037790934244791665, 0.0119781494140625, 0.010403951009114584, 0.010759989420572916, 0.013226826985677084, 0.007354736328125, 0.033045450846354164, 0.011627197265625], "11": [0.022371927897135418, 0.033167521158854164, 0.010874430338541666, 0.0142059326171875, 0.008160909016927084, 0.013844807942708334, 0.055498758951822914, 0.018582661946614582, 0.0189971923828125, 0.011388142903645834, 0.007288614908854167, 0.021375020345052082, 0.015635172526041668, 0.00019073486328125, 0.005421956380208333, 0.024378458658854168, 0.007685343424479167, 0.027987162272135418, 0.017038981119791668, 0.012847900390625, 0.015576680501302084, 0.015268961588541666, 0.014251708984375, 0.009862263997395834, 0.015820821126302082, 0.010101318359375, 0.013308207194010416, 0.0026372273763020835, 0.009808858235677084, 0.0115509033203125, 0.018658955891927082, 0.018895467122395832, 0.018229166666666668, 0.009114583333333334, 0.0223541259765625, 0.0075836181640625, 0.01425933837890625, 0.0095367431640625, 0.0045318603515625, 0.009829203287760416, 0.011355082194010416, 0.013621012369791666, 0.015352884928385416, 0.03899383544921875, 0.022051493326822918, 0.02303314208984375, 0.017819722493489582, 0.018717447916666668, 0.0018030802408854167, 0.02024078369140625, 0.0037943522135416665, 0.006159464518229167, 0.009173075358072916, 0.00601959228515625, 0.019343058268229168, 0.03795623779296875, 0.011995951334635416, 0.04059600830078125, 0.0269775390625, 0.01615142822265625, 0.0076904296875, 0.022715250651041668, 0.009124755859375, 0.0011927286783854167], "12": [0.016576131184895832, 0.014246622721354166, 0.040445963541666664, 0.0184783935546875, 0.014233907063802084, 0.01721954345703125, 0.01079559326171875, 0.01963043212890625, 0.0009511311848958334, 0.014284769694010416, 0.011217753092447916, 0.022852579752604168, 0.010653177897135416, 0.007738749186197917, 0.021044413248697918, 0.015271504720052084, 0.013735453287760416, 0.011189778645833334, 0.00328826904296875, 0.055226643880208336, 0.010907491048177084, 0.023165384928385418, 0.018857320149739582, 0.005060831705729167, 0.011411031087239584, 0.02371978759765625, 0.013910929361979166, 0.014134724934895834, 0.010492960611979166, 0.009180704752604166, 0.026092529296875, 0.0021692911783854165, 0.021753946940104168, 0.0076446533203125, 0.016756693522135418, 0.01206207275390625, 0.0103607177734375, 0.0121917724609375, 0.004178365071614583, 0.0068359375, 0.057360331217447914, 0.016909281412760418, 0.01495361328125, 0.00336456298828125, 0.011576334635416666, 0.02325439453125, 0.020861307779947918, 0.0184783935546875, 0.020281473795572918, 0.012664794921875, 0.025553385416666668, 0.016306559244791668, 0.024564107259114582, 0.020444234212239582, 0.008417765299479166, 0.022282918294270832, 0.01444244384765625, 0.013562520345052084, 0.006779988606770833, 0.0100555419921875, 0.007642110188802083, 0.0104522705078125, 0.01406097412109375, 0.005762736002604167], "13": [0.012830098470052084, 0.02161407470703125, 0.008272806803385416, 0.018984476725260418, 0.00554656982421875, 0.009310404459635416, 0.00119781494140625, 0.0269012451171875, 0.024462381998697918, 0.00726318359375, 0.013102213541666666, 0.0003458658854166667, 0.00891876220703125, 0.008148193359375, 0.009600321451822916, 0.008107503255208334, 0.011426289876302084, 0.006573994954427083, 0.01398468017578125, 0.032892862955729164, 0.006853739420572917, 0.009343465169270834, 0.023981730143229168, 0.013323465983072916, 0.01065826416015625, 0.004862467447916667, 0.011782328287760416, 0.025881449381510418, 0.013427734375, 0.02643585205078125, 0.015271504720052084, 0.013158162434895834, 0.027478535970052082, 0.017072041829427082, 0.016863505045572918, 0.02207183837890625, 0.029858907063802082, 0.015645345052083332, 0.009923299153645834, 0.014040629069010416, 0.01019287109375, 0.0256805419921875, 0.008463541666666666, 0.047915140787760414, 0.00957489013671875, 0.004000345865885417, 0.028065999348958332, 0.006947835286458333, 0.02144622802734375, 0.008603413899739584, 0.009440104166666666, 0.00490570068359375, 0.06434885660807292, 0.0027109781901041665, 0.020093282063802082, 0.0252838134765625, 0.02887725830078125, 0.013427734375, 0.014844258626302084, 0.00821685791015625, 0.0020777384440104165, 0.007563273111979167, 0.007649739583333333, 0.0422515869140625], "14": [0.014251708984375, 0.025594075520833332, 0.033894856770833336, 0.039087931315104164, 0.00449371337890625, 0.02930450439453125, 0.0002950032552083333, 0.030248006184895832, 0.0035044352213541665, 0.012982686360677084, 0.013641357421875, 0.012265523274739584, 0.01155853271484375, 0.016789754231770832, 0.02744293212890625, 0.0234832763671875, 0.01568603515625, 0.005587259928385417, 0.016665140787760418, 0.010854085286458334, 0.018646240234375, 0.023618062337239582, 0.004262288411458333, 0.012652079264322916, 0.00606536865234375, 0.008165995279947916, 0.0117645263671875, 0.0135955810546875, 0.00061798095703125, 0.00308990478515625, 0.00136566162109375, 0.01592254638671875, 0.009213765462239584, 0.0025787353515625, 0.00394439697265625, 0.0076446533203125, 0.004038492838541667, 0.041811625162760414, 0.024988810221354168, 0.020624796549479168, 0.01856231689453125, 0.012486775716145834, 0.01020050048828125, 0.030774434407552082, 0.022333780924479168, 0.014600118001302084, 0.02091217041015625, 0.014096577962239584, 0.02204132080078125, 0.033457438151041664, 0.015207926432291666, 0.00351715087890625, 0.023050944010416668, 0.018488566080729168, 0.005877176920572917, 0.008694966634114584, 0.0080413818359375, 0.021227518717447918, 0.011355082194010416, 0.030077616373697918, 0.010080973307291666, 0.009366353352864584, 0.0334014892578125, 0.01990509033203125], "15": [0.015446980794270834, 0.00719451904296875, 0.024706522623697918, 0.040669759114583336, 0.004015604654947917, 0.012148539225260416, 0.008074442545572916, 0.03563690185546875, 0.0033925374348958335, 0.0040740966796875, 0.018300374348958332, 0.004351298014322917, 0.0020853678385416665, 0.01900482177734375, 0.00920867919921875, 0.0181732177734375, 0.012194315592447916, 0.038210550944010414, 0.0007654825846354166, 0.006123860677083333, 0.0131988525390625, 0.030888875325520832, 0.008646647135416666, 0.019663492838541668, 0.010370890299479166, 0.005589803059895833, 0.051531473795572914, 0.0156707763671875, 0.015726725260416668, 0.006121317545572917, 0.0008443196614583334, 0.01576995849609375, 0.00279998779296875, 0.005803426106770833, 0.003631591796875, 0.0121917724609375, 0.023267110188802082, 0.011377970377604166, 0.00786590576171875, 0.0026652018229166665, 0.02513885498046875, 0.01985931396484375, 0.009033203125, 0.0116119384765625, 0.007181803385416667, 0.041142781575520836, 0.016469319661458332, 0.019223531087239582, 0.040425618489583336, 0.047849019368489586, 0.00325775146484375, 0.0021870930989583335, 0.010958353678385416, 0.016754150390625, 0.01837921142578125, 0.02478790283203125, 0.02323150634765625, 0.01389312744140625, 0.0152587890625, 0.023585001627604168, 0.01822662353515625, 0.019014994303385418, 0.014841715494791666, 0.010284423828125]}
results/routing_stats.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokens": 49152,
3
+ "layers": 16,
4
+ "experts": 64,
5
+ "topk": 8,
6
+ "gini": [
7
+ 0.2641251881917318,
8
+ 0.23673518498738605,
9
+ 0.29776819547017414,
10
+ 0.29947829246520996,
11
+ 0.3454646269480387,
12
+ 0.3215921719868978,
13
+ 0.34398754437764484,
14
+ 0.3286585807800293,
15
+ 0.309318463007609,
16
+ 0.2810204029083252,
17
+ 0.280742883682251,
18
+ 0.3329012393951416,
19
+ 0.3131023248036703,
20
+ 0.3724563121795655,
21
+ 0.3590616385142008,
22
+ 0.4008479118347168
23
+ ],
24
+ "mass_top25pct": 0.4494392077128093,
25
+ "mass_top50pct": 0.7201894124348959,
26
+ "cum_mean": [
27
+ 0.04957866668701171,
28
+ 0.08984041213989256,
29
+ 0.12564531962076825,
30
+ 0.15774806340535483,
31
+ 0.18765417734781906,
32
+ 0.2160946528116862,
33
+ 0.24337959289550778,
34
+ 0.2692921956380208,
35
+ 0.2938820521036784,
36
+ 0.3178324699401856,
37
+ 0.3411908149719239,
38
+ 0.36395390828450525,
39
+ 0.3860907554626466,
40
+ 0.40786997477213544,
41
+ 0.4289251963297527,
42
+ 0.4494392077128092,
43
+ 0.4695858955383301,
44
+ 0.48933347066243493,
45
+ 0.5085887908935547,
46
+ 0.5272884368896485,
47
+ 0.5454365412394205,
48
+ 0.5631278355916342,
49
+ 0.5805028279622395,
50
+ 0.5973410606384277,
51
+ 0.6137038866678873,
52
+ 0.6296553611755371,
53
+ 0.6453857421875,
54
+ 0.6608610153198242,
55
+ 0.6761328379313151,
56
+ 0.6911047299702963,
57
+ 0.7057998975118002,
58
+ 0.7201894124348959,
59
+ 0.7341702779134114,
60
+ 0.7478232383728028,
61
+ 0.7613116900126139,
62
+ 0.7745154698689779,
63
+ 0.7874118487040203,
64
+ 0.8000138600667318,
65
+ 0.8123443921407064,
66
+ 0.8243754704793295,
67
+ 0.8361045519510906,
68
+ 0.8473731676737467,
69
+ 0.8582647641499838,
70
+ 0.8688268661499025,
71
+ 0.8790240287780763,
72
+ 0.8889846801757814,
73
+ 0.8986585934956869,
74
+ 0.9080793062845866,
75
+ 0.9172714551289876,
76
+ 0.9262355168660482,
77
+ 0.9347052574157716,
78
+ 0.9429275194803874,
79
+ 0.95058012008667,
80
+ 0.957863966623942,
81
+ 0.9648462931315105,
82
+ 0.9712352752685547,
83
+ 0.9771231015523276,
84
+ 0.982486565907796,
85
+ 0.9872740109761556,
86
+ 0.9913490613301595,
87
+ 0.9945575396219889,
88
+ 0.9972108205159506,
89
+ 0.9991180102030437,
90
+ 1.0
91
+ ],
92
+ "reuse_prev_token": [
93
+ 0.2499567658847226,
94
+ 0.2796840349128197,
95
+ 0.3672738092816016,
96
+ 0.3708393522003621,
97
+ 0.44042084596447684,
98
+ 0.4547211653882932,
99
+ 0.46631045146589084,
100
+ 0.4375648511729161,
101
+ 0.3781764358812639,
102
+ 0.3395353095562654,
103
+ 0.31294632866065797,
104
+ 0.36515025126650524,
105
+ 0.3588685886350227,
106
+ 0.38883491688877136,
107
+ 0.34283127505035504,
108
+ 0.36325557974405404
109
+ ],
110
+ "working_set": {
111
+ "1": 8.0,
112
+ "4": 21.099609375,
113
+ "16": 42.0537109375,
114
+ "64": 56.6220703125,
115
+ "256": 61.19140625,
116
+ "1024": 63.161458333333336
117
+ }
118
+ }
results/routing_trace.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74d821864ef73b28a53a377f602accf9dd1a4b8d4a7ae1b16bac08e60d40d9d1
3
+ size 12583040