Speed predictions now come from a model trained on 6.6k real measurements (17.5% median error on unseen hardware), physics formula beyond its measured range
Browse filesFiles changed (5)
- .gitattributes+1
- engine/speed.py+43-5
- model/README.mdAdded+53
- model/metrics.jsonAdded+11
- model/speed_model.skopsAdded+3
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textmodel/speed_model.skops filter=lfs diff=lfs merge=lfs -text
115 unmodified lines1161171181191201211226 unmodified lines12913013113213313426 unmodified lines16116216316416516616710 unmodified lines178179180181182183184185186187188189115 unmodified linesreturn Nonetry:from skops.io import load as skops_loadmodel = skops_load(_MODEL_PATH, trusted=None)print(f"[FitCheck] speed predictor loaded from {_MODEL_PATH.name}", flush=True)return modelexcept Exception as e: # noqa: BLE0016 unmodified linesreturn None# --------------------------------------------------------------------------# Prediction# --------------------------------------------------------------------------26 unmodified lineseff_bw = 1.0 / ((1.0 - f) / bandwidth_gbs + f / _RAM_BW_GBS)model = _trained_model()if model is not None:try:import numpy as npx = np.array([[eff_bw, bytes_gb, weights_gb, kv_gb,10 unmodified linespassbase = eff_bw / bytes_gbreturn {"tps": round(base * _EFF_MID, 1),"lo": round(base * _EFF_LO, 1), "hi": round(base * _EFF_HI, 1),"bytes_gb": round(bytes_gb, 2), "eff_bw": round(eff_bw, 1),"method": "roofline","note": ("analytical estimate: decode speed is memory-bandwidth-bound ""(bandwidth divided by bytes read per token)")}def feel_text(pred: dict) -> str:115 unmodified lines1161171181191201211221231241251266 unmodified lines13313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816926 unmodified lines19619719819920020120210 unmodified lines213214215216217218219220221222223224225226227115 unmodified linesreturn Nonetry:from skops.io import load as skops_load# skops only loads explicitly-trusted types — exactly these two, which# scripts/train_speed_model.py produces. Anything else is refused.model = skops_load(_MODEL_PATH, trusted=["xgboost.core.Booster", "xgboost.sklearn.XGBRegressor",])print(f"[FitCheck] speed predictor loaded from {_MODEL_PATH.name}", flush=True)return modelexcept Exception as e: # noqa: BLE0016 unmodified linesreturn None_METRICS_PATH = _ROOT / "model" / "metrics.json"@lru_cache(maxsize=1)def _envelope() -> dict:"""The region of feature space the training data actually covered.Decision trees cannot extrapolate: outside what they saw, they clamp tothe nearest seen value and quietly give wrong answers (e.g. a 32B modelgets a 14B's speed). The roofline DOES extrapolate — it's physics. So thetrained model only answers inside its measured envelope; outside it, thelabelled analytical estimate takes over. Bounds come from metrics.jsonwhen the training script recorded them, else conservative defaultsmatching the LocalScore grid (<=14B Q4 models, consumer hardware)."""env = {"bytes_gb": (0.8, 10.0), "eff_bw": (30.0, 1900.0)}try:rec = json.loads(_METRICS_PATH.read_text(encoding="utf-8")).get("envelope")if rec:env.update({k: tuple(v) for k, v in rec.items()})except OSError:passreturn envdef _in_envelope(eff_bw: float, bytes_gb: float) -> bool:env = _envelope()return (env["bytes_gb"][0] <= bytes_gb <= env["bytes_gb"][1]and env["eff_bw"][0] <= eff_bw <= env["eff_bw"][1])# --------------------------------------------------------------------------# Prediction# --------------------------------------------------------------------------26 unmodified lineseff_bw = 1.0 / ((1.0 - f) / bandwidth_gbs + f / _RAM_BW_GBS)model = _trained_model()if model is not None and _in_envelope(eff_bw, bytes_gb):try:import numpy as npx = np.array([[eff_bw, bytes_gb, weights_gb, kv_gb,10 unmodified linespassbase = eff_bw / bytes_gbnote = ("analytical estimate: decode speed is memory-bandwidth-bound ""(bandwidth divided by bytes read per token)")if model is not None:note += (" — this configuration is outside the measured data's range, ""so the physics formula answers instead of the trained model")return {"tps": round(base * _EFF_MID, 1),"lo": round(base * _EFF_LO, 1), "hi": round(base * _EFF_HI, 1),"bytes_gb": round(bytes_gb, 2), "eff_bw": round(eff_bw, 1),"method": "roofline", "note": note}def feel_text(pred: dict) -> str:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253---
license: mit
library_name: skops
tags: [tabular-regression, xgboost, llm-inference, performance-prediction]
---
# FitCheck speed predictor
Predicts local-LLM **decode tokens/sec** from hardware + model features.
Part of [FitCheck](https://huggingface.co/spaces/build-small-hackathon/FitCheck),
the honest "what AI can your computer run" advisor.
## Method
Gradient-boosted regression (XGBoost) following the methodology of
**LLM-Pilot** (IBM, SC'24): [arXiv:2410.02425](https://arxiv.org/abs/2410.02425) —
performance prediction for LLM inference on unseen hardware, validated
**leave-one-accelerator-out** so the error below is measured on hardware the
model never saw in training.
Features: effective memory bandwidth, bytes read per token (weights + KV),
weights size, KV size, MoE active fraction, offload fraction, and the
analytical roofline prior (bandwidth / bytes). Decode is memory-bandwidth-bound;
the model learns the residual between the roofline ideal and reality.
## Training data
6,633 real measurements across 595 distinct
accelerators (consumer CPUs, Apple Silicon, NVIDIA/AMD GPUs), from the
[LocalScore](https://www.localscore.ai) community benchmark (Mozilla Builders /
cjpais — thank you; data attributed, not owned, takedown requests honoured).
Trained 2026-06-10.
## Honest holdout results (leave-one-accelerator-out)
| metric | roofline baseline | this model |
|---|---|---|
| median APE (bandwidth-known hardware) | 28.1% | 17.5% |
| median abs error (tok/s) | 11.63 | 9.55 |
| all hardware incl. CPUs (no baseline possible) | — | 23.6% median APE |
**Shipping rule:** this model is only deployed because it beat the analytical
baseline on held-out hardware. If a retrain ever fails that gate, FitCheck
falls back to the labelled roofline estimate.
## Limits (read this)
- Trained on **dense LLMs running fully on-device** (LocalScore's fixed grid:
1B / 8B / 14B at Q4_K_M, varied context). The model axis generalises through
the bytes-per-token feature, not data diversity.
- MoE and GPU->RAM offload are corrected analytically upstream, then fed
through — those corrections are engineering estimates, labelled as such.
- Does NOT cover vision/diffusion models (compute-bound, different physics).1234567891011{
"rows": 6633,
"accelerators": 595,
"model_mape_pct": 23.6,
"model_mae_tps": 7.63,
"bw_known_rows": 3732,
"baseline_mape_pct": 28.1,
"baseline_mae_tps": 11.63,
"model_mape_on_bw_known_pct": 17.5,
"model_mae_on_bw_known_tps": 9.55
}123version https://git-lfs.github.com/spec/v1oid sha256:70249e8241e24de5202af7ba82e911b9dbfaed06c19be920d6b6fd2873bef58bsize 1658817.gitattributes+1
engine/speed.py+43-5
model/README.mdAdded+53
model/metrics.jsonAdded+11
model/speed_model.skopsAdded+3