
Avifenesh 发布 layby-dwell 模型,预测闲置会话的 KV cache 驻留位置
来源标题:Layby: Where should an idle session's KV cache wait?
开发者 Avifenesh 在 Hugging Face 发布 layby-dwell 文本分类模型,用于判断闲置会话的 KV cache 应该驻留在哪里。该模型以 apache-2.0 许可开源,基于 WildChat-4.8M 和 SWE-chat 数据训练,使用 Transformers 可直接加载,涉及 vLLM、SGLang 等推理框架场景。
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Like 2
Text Classification
Transformers
Safetensors
allenai/WildChat-4.8M
SALT-NLP/SWE-chat
doi:10.57967/hf/10852
kv-cache
llm-serving
inference
survival-analysis
vllm
sglang
agents
License: apache-2.0
Model card Files Files and versions xet
Community
More actions
Deploy
Copy to bucket
Use this model Instructions to use Avifenesh/layby-dwell with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
Libraries
Transformers How to use Avifenesh/layby-dwell with Transformers:
Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Avifenesh/layby-dwell")
pip install -U transformers accelerate
Load model directly
from transformers import AutoModel model = AutoModel.from_pretrained("Avifenesh/layby-dwell", device_map="auto")
Notebooks
Google Colab
Kaggle
v2_gated</code>)","children":[],"isValid":true,"title":"Architecture (<code>v2_gated</code>)"},{"id":"input","label":"Input","children":[],"isValid":true,"title":"Input"},{"id":"output","label":"Output","children":[],"isValid":true,"title":"Output"},{"id":"use","label":"Use","children":[{"id":"with-vllm-and-sglang","label":"With vLLM and SGLang","children":[],"isValid":true,"title":"With vLLM and SGLang"}],"isValid":true,"title":"Use"},{"id":"training","label":"Training","children":[{"id":"data","label":"Data","children":[],"isValid":true,"title":"Data"}],"isValid":true,"title":"Training"},{"id":"evaluation","label":"Evaluation","children":[{"id":"head-to-head-vs-archived-v1-421m-on-strictly-untouched-splits","label":"Head-to-head vs. archived <code>v1</code> (<code>421M</code>) on strictly untouched splits","children":[],"isValid":true,"title":"Head-to-head vs. archived <code>v1</code> (<code>421M</code>) on strictly untouched splits"},{"id":"architecture--objective-ablations-full-eval_uhold-n184148--33-returnbench-cells","label":"Architecture & objective ablations (full <code>eval_uhold</code>, <code>n=184,148</code> + 33 ReturnBench cells)","children":[],"isValid":true,"title":"Architecture & objective ablations (full <code>eval_uhold</code>, <code>n=184,148</code> + 33 ReturnBench cells)"},{"id":"real-engine-serving-cpu-sidecar-0-mib-gpu-vram","label":"Real-engine serving (CPU sidecar, 0 MiB GPU VRAM)","children":[],"isValid":true,"title":"Real-engine serving (CPU sidecar, 0 MiB GPU VRAM)"}],"isValid":true,"title":"Evaluation"},{"id":"speed","label":"Speed","children":[],"isValid":true,"title":"Speed"},{"id":"limits","label":"Limits","children":[],"isValid":true,"title":"Limits"},{"id":"license","label":"License","children":[],"isValid":true,"title":"License"},{"id":"citation","label":"Citation","children":[],"isValid":true,"title":"Citation"}],"isValid":true,"title":"Layby-Dwell v2"}]}"> Layby-Dwell v2 v2_gated</code>)">Architecture (v2_gated)
Input
Output
Use With vLLM and SGLang
Training Data
Evaluation v1</code> (<code>421M</code>) on strictly untouched splits">Head-to-head vs. archived v1 (421M) on strictly untouched splits
eval_uhold</code>, <code>n=184,148</code> + 33 ReturnBench cells)">Architecture & objective ablations (full eval_uhold, n=184,148 + 33 ReturnBench cells)
Real-engine serving (CPU sidecar, 0 MiB GPU VRAM)
Speed
Limits
License
Citation
Layby-Dwell v2
Layby-Dwell predicts how long an LLM session stays idle after a response ends. It reads what a serving engine can see at that moment and returns a calibrated survival curve: the probability that the session's next request has not arrived yet, at 15 horizons from 0.5 s to 30 min.
Code, engine adapters and the ReturnBench benchmark: github.com/avifenesh/layby (v2.1.1), archived on Zenodo as 10.5281/zenodo.23285213. Paper: layby.pdf (arXiv link to follow). Author: Avi Fenesh.
It exists for one decision: where to keep the session's KV cache while it waits. Keep it on the GPU, move it to CPU memory, write it to disk, or let it go. Layby, the placement rule it was built for, turns the curve and the engine's own measured hardware costs into that choice. There are no workload-fitted decision thresholds.
v2.0 release (main, tag v2.0): Layby-Dwell v2 replaces the 421M v1 model with a standalone 33.8M (135 MB) two-tower model built on jhu-clsp/ettin-encoder-32m (Apache-2.0). It removes the laya dependency, runs on host CPU with 0 MiB GPU VRAM (10.6-19.4 ms p50 live on a 64-vCPU server, 20.9-29.8 ms isolated 8-thread at L=128-512, 68.2 ms at L=1024, 117 ms on DGX Spark ARM64, 140-380 ms on a loaded laptop CPU; or 4.07-4.26 ms on GPU BF16 using 427 MiB), cuts human calibration error by 3.3x, and matches or beats v1 on ReturnBench and held-out splits. Legacy v1 (421M, convaiinnovations/laya) remains archived at branch v1 / tag v1.0 (Dwell("avifenesh/layby-dwell", revision="v1")).
Architecture (v2_gated)
Text tower: jhu-clsp/ettin-encoder-32m (10-layer, 384-dim ModernBERT, max_len = 1536) over compact delta text (kind, tool, program, model, TOOL_CALL, ASSISTANT, USER) + learnable top-4 LayerMix + [CLS] + AttentionPool.
Numeric tower (PeriodicNumericEncoder): 32 causal server-view numeric features with explicit missing masks, 8 learned Fourier frequencies per feature, and 2 residual SwiGLU blocks (256-dim).
Gated bilinear residual head: z = z_num + sigmoid(gate) * z_delta over concatenated [h_txt, h_num, h_num * txt_proj], producing 16 right-censored discrete survival bin logits with per-kind temperature calibration (_all: 1.0261, human: 1.0051, tool: 1.0309).
Size: 33,755,701 parameters (14.4M non-embedding), 135 MB fp32 safetensors, zero laya dependency. One forward pass per state; no text is generated.
Input
A server-view state: a JSON object (or Python dict) built at the moment a response ends. Any OpenAI-compatible server can fill every field. layby_dwell.Tracker builds it from the request and response stream.
Sessions are linked by a hash of the conversation prefix. A user is whatever key the server has (API key, tenant, header). History fields are optional: the model was trained with telemetry dropout (p_id = 0.30, p_history = 0.15) and degrades gracefully on cold-start traffic, though session history remains valuable for long human waits (see Limits).
Output
P(T > h) for h in [0.5, 1, 2, 3, 5, 8, 12, 20, 30, 45, 60, 120, 300, 600, 1800] seconds, where T is the time until the session's next request. Probabilities are strictly non-increasing and calibrated per kind with temperatures stored in config.json.
Use
from layby_dwell import Dwell, Tracker
v2 (33.8M, zero laya dependency; runs comfortably on CPU with 0 MiB GPU VRAM, or GPU bf16)
dwell = Dwell("avifenesh/layby-dwell", device="cpu") tracker = Tracker()
in the serving path, per request and response:
sess = tracker.on_request(body, user) state, kind = tracker.on_response(sess, body, resp_message, usage, user) surv = dwell.survival([state], [kind])[0] # 15 values of P(T > h)
To reproduce legacy v1 (421M, requires pip install -e ".[dwell,dwell-v1]"):
dwell_v1 = Dwell("avifenesh/layby-dwell", revision="v1")
Score at the end of each response, off the critical path. Batch the boundaries that end together: survival sorts states by length and pads each batch only to its longest state (rounded to 16).
With vLLM and SGLang
The Layby adapters run the placement rule inside the engine and take the curve as a hint keyed by request:
The Layby sidecar (python -m layby.sidecar.proxy --device cpu) is an OpenAI-compatible proxy that handles session tracking, CPU scoring (0 MiB GPU VRAM), optional online temperature recalibration (--online-calib), and hint delivery for either engine.
Training
Trained from jhu-clsp/ettin-encoder-32m (1b8ba06455dd44f80fc9c1ca9e22806157a57379) on 3,236,086 cleaned, secret-scrubbed server-view turns for 1 epoch with ScheduleFree AdamW, FP32 master weights under BF16 autocast, max_len = 1536, inverse-subsampling importance weighting normalized by kind, and server-telemetry dropout (p_id = 0.30, p_history = 0.15). Target: exact right-censored 16-bin discrete survival negative log-likelihood (a strictly proper scoring rule). The published weights are Seed 0 of the 3-seed champion run (rung4_32m_all_corpora).
Data
Only datasets whose licenses allow commercial use, with 0 secret regex hits across 100% of rows and strict zero-leakage splits (0 unseen-user overlap, 0 cross-split sessions, 0/9,987 ReturnBench replay_pop turns in training, and future weeks 12-15 of FreeInference held out):
Evaluation
Head-to-head vs. archived v1 (421M) on strictly untouched splits
All v2 offline metrics below are 3-seed medians on strictly untouched evaluation splits:
Architecture & objective ablations (full eval_uhold, n=184,148 + 33 ReturnBench cells)
One-epoch ablations on the 3.24M-row corpus (*Compact 18.5M aux=0 trained on 3.00M rows without swechat_v2_new), all evaluated apples-to-apples on full eval_uhold (n=184,148):
Real-engine serving (CPU sidecar, 0 MiB GPU VRAM)
Running this exact checkpoint (rung4_32m_all_corpora, seed 0) on host CPU across 4 hardware tiers and 5 model families (O_DIRECT / fadvise, 0 hint errors across >8,000 live turns, 0 MiB extra GPU VRAM; multi-repeat averages for layby):
Full real-hardware tables across all hardware tiers and model families are in the Layby repository README and layby.pdf.
Speed
device precision one state (bs=1) batch of 8 VRAM
CPU x86, 8 threads (L = 128 / 256 / 512 / 1024) fp32 20.9 / 24.3 / 29.8 / 68.2 ms
0 MiB
CPU x86, live sidecar (64-vCPU server, mixed lengths) fp32 10.6 to 19.4 ms p50
0 MiB
CPU x86, live sidecar (loaded laptop CPU) fp32 140 to 380 ms p50
0 MiB
CPU ARM64, live sidecar (DGX Spark GB10) fp32 117 ms p50
0 MiB
RTX 5090 (L = 256 / 1536, PyTorch sdpa) bf16 4.07 / 4.26 ms 1,960 / 488 st/s (L=256/1024) 427 MiB
Unlike v1 (1.7-2.9 s on CPU, GPU-required), v2 is fast enough to run directly on CPU inside the inference router or sidecar process with zero GPU contention. On GPU, serve in bf16 (the default). Weight-only 8-bit options (precision="int8w", "fp8w") remain available via torchao; see model/QUANT.md for the v1 quantization study.
Limits
Session history matters for long human waits. Without session linking (stateless scoring), long-horizon human recall degrades sharply. Run Tracker so prior session gaps are populated.
Temporal harness drift on tool latencies. On the single slice where archived v1 edged v2 (freeinference:tool future weeks 12-15: 1.6336 vs 1.6828, +0.0492 NLL driven by wait_poll latency shift), v2 still ranked tools better (rho = 0.790-0.798 vs 0.774) and beat v1 on freeinference:human (-0.0690 NLL). For deployments with shifting agent harnesses, layby/sidecar/proxy.py implements optional rolling per-kind temperature recalibration (--online-calib) for /v1/chat/completions proxy traffic (not yet evaluated under live proxy replay).
English-centric text fields: non-English corpora were not specifically benchmarked.
Forecast, not a guarantee: use the survival curve inside a cost-aware rule that prices wrong calls, as Layby does, rather than as a hard eviction timeout.
Data handling: scoring reads prompt and response text locally; it stores nothing, but treat it like any other component on the inference host.
License
Apache-2.0, matching the base jhu-clsp/ettin-encoder-32m weights.
Citation
@misc{fenesh2026layby, title = {Layby: Placing Idle KV Cache by Predicted Return Time and Measured Cost}, author = {Avi Fenesh}, year = {2026}, note = {arXiv id to follow} }
Downloads last month 81
Safetensors
Model size
33.8M params
Tensor type
F32 ·
Files info
Inference Providers NEW
Text Classification
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。
