SPB Git

spb/wp30_uqo

Public
4.8 KB · 62 lines python
1"""Tables that depend on manifests/evidence rather than trial outcomes: taxonomy, models, datasets, coverage."""2from __future__ import annotations3import json, pandas as pd4from pathlib import Path5from ..util import ROOT, read_json, write_json, utc_now67TAB = ROOT / "results/tables"89TAXONOMY = [10    # id, representation, access regime, training, compatibility, composable (fan-in), status11    ("A0", "none (task only)", "n/a", "none", "any", "n/a", "measured"),12    ("A1", "raw text", "blind", "none", "any receiver", "concatenation", "measured"),13    ("A2", "text head/tail", "blind", "none", "any", "concatenation", "measured"),14    ("A3", "extractive sentences (BM25/centrality)", "blind or aware", "none", "any", "concatenation", "measured"),15    ("A4", "abstractive summary", "blind or aware", "none (prompted sender)", "any", "concatenation", "measured"),16    ("A5", "typed facts + source spans + unknowns (JSON)", "blind or aware", "none (prompted sender)", "any", "record merge", "measured"),17    ("A6", "reference index + metered retrieval", "blind index, aware retrieval", "none", "any + source access", "shared memory", "measured"),18    ("A7", "raw text, zstd transport codec", "blind", "none", "any", "concatenation", "measured"),19    ("A8", "LLMLingua-2 token dropping", "blind", "pretrained compressor (official)", "any", "concatenation", "measured"),20    ("B0", "native bf16 KV cache", "blind", "none", "same checkpoint", "no", "measured"),21    ("B1", "serialized KV cache (manifest-checked)", "blind", "none", "same checkpoint + revision", "no", "measured (process + 2-node)"),22    ("B2", "packed quantized KV (8/4/2 bit)", "blind", "none", "same checkpoint", "no", "measured"),23    ("B3", "sink+recent retention (StreamingLLM-inspired)", "blind", "none", "same checkpoint", "no", "measured"),24    ("B4", "random retention (control)", "blind", "none", "same checkpoint", "no", "measured"),25    ("B5", "attention-informed retention (SnapKV rule)", "aware (blind variant tested)", "none", "same checkpoint", "no", "measured"),26    ("B6", "pyramid layer budgets (PyramidKV rule)", "aware", "none", "same checkpoint", "no", "measured"),27    ("B9", "selection then packed quantization", "aware", "none", "same checkpoint", "no", "measured"),28    ("C0", "sender cache fed as receiver cache", "blind", "none", "incompatible (negative control)", "no", "measured (control)"),29    ("C2", "linear KV mapper (ridge, un-rotated K/V)", "blind", "ridge on train caches", "trained pair (Qwen 1.5B→3B)", "no", "measured"),30    ("C3", "mapper + attention selection", "aware", "ridge on train caches", "trained pair", "no", "measured"),31    ("—", "SwaT cross-family mapper", "blind", "~300M mapper (not public)", "Granite→SmolLM", "no", "not run: no checkpoint/licence"),32    ("—", "Attention-Matching compaction", "blind", "none (optimization)", "same model", "no", "not run: CUDA/vLLM code; MLX port out of scope"),33    ("—", "C2C fuser", "blind", "released fusers (Qwen3)", "Qwen3 receivers", "no", "not run: CUDA; receiver still prefills source"),34    ("—", "H2O eviction", "cumulative", "none", "same checkpoint", "no", "not run: requires attention scores during whole prefill"),35    ("—", "KIVI per-channel key quantization", "blind", "none", "same checkpoint", "no", "not run: CUDA kernels; motivation confirmed by B2 Qwen result"),36]3738def taxonomy():39    t = pd.DataFrame(TAXONOMY, columns=["id", "representation", "question_access", "training", "compatibility", "composable", "status_in_wp30"])40    t.to_csv(TAB / "table1_taxonomy.csv", index=False); return t4142def models():43    ev = read_json(ROOT / "evidence/models.json")44    rows = []45    for alias, m in ev["models"].items():46        rows.append({"alias": alias, "repo": m["repo_id"], "revision": m["revision"][:12], "family": m["model_type"], "layers": m["num_layers"], "kv_heads": m["num_kv_heads"], "q_heads": m["num_attention_heads"],47                     "head_dim": m["head_dim"], "weights": m["weight_dtype"], "max_pos": m["max_position_embeddings"], "rope_theta": m["rope_theta"], "cache_bytes_per_token_bf16": 2 * m["num_layers"] * m["num_kv_heads"] * m["head_dim"] * 2,48                     "prefill_ms_8k": round(m["context_lengths"]["8192"]["prefill_ms"]), "prefill_ms_16k": round(m["context_lengths"]["16384"]["prefill_ms"]), "mlx": m["mlx_version"], "mlx_lm": m["mlx_lm_version"]})49    t = pd.DataFrame(rows); t.to_csv(TAB / "table2_models.csv", index=False); return t5051def datasets():52    man = read_json(ROOT / "data/manifests/splits.json"); df = pd.DataFrame(man["items"])53    g = df.groupby(["family", "split"]).agg(documents=("document_id", "count"), questions=("n_questions", "sum"), median_chars=("char_len", "median")).reset_index()54    g.to_csv(TAB / "table3_datasets.csv", index=False); return g5556def main():57    TAB.mkdir(parents=True, exist_ok=True)58    taxonomy(); models(); datasets(); print("static tables written")5960if __name__ == "__main__":61    main()62
Files · f4474e1b03aebffdfcd19ab989b35165571329e6
Menu

Theme