Thaki-MemoryPolicy-vLLM-Ranker
🇰🇷 Korean card: MODEL_CARD.ko.md
Engineering blog: Can a 10K-Parameter Ranker Pick Better vLLM Settings Than the Defaults? (한국어: 블로그)
Research Preview · Offline Policy Ranker · not a production serving policy.
A 10K-parameter listwise ranker that picks one of 15 vLLM serving configurations (--max-num-seqs, --max-num-batched-tokens, --gpu-memory-utilization, prefix caching on/off) for a given model and workload, offline, before any server is started. It only reads facts that are known ahead of time: model architecture, prompt length, the max_new_tokens budget, the prefix-share ratio the workload is designed with, and concurrency.
Status: research preview. No significant improvement over vLLM's default configuration. The test covers 16 scenarios: Qwen3-1.7B and Qwen3-4B (both models also appear in training) on two workload families never used in training (agent, codeassist), concurrency 4–256, one B200 GPU. This measures generalisation to unseen workloads on known models, not to new models. On these scenarios SLO-violation rate is 0.25 for both the ranker and the default config (Δ 0.0, 95% CI [0, 0]). Goodput is +26.0 tok/s observed (bootstrap mean +26.6, 95% CI [−17.0, +77.7]), throughput is +19.0 tok/s (bootstrap mean +20.4, CI [−82.8, +119.9]). Neither CI excludes zero. All six pre-registered gates passed, but the gates require "not worse than default", so passing them here means parity, not improvement. The tail is worse: the 95th percentile of per-scenario p95 TTFT is 12.99 s vs 10.78 s for the default. Evaluation is offline only: every candidate was measured on its own fresh server, and switching configurations on a live server was never tested. Results from an earlier leaky version (v1) are invalid and are not used as evidence anywhere in this card.
0. How to use
from huggingface_hub import snapshot_download
import sys
path = snapshot_download("ThakiCloud/Thaki-MemoryPolicy-vLLM-Ranker")
sys.path.insert(0, path)
from memorypolicy import MemoryPolicy, arch_from_hf_config
mp = MemoryPolicy(path)
arch = arch_from_hf_config("/models/Qwen3-4B/config.json", weight_bytes=8.05e9) # total *.safetensors bytes
print(mp.recommend(arch, prompt_len=3000, output_budget=256, prefix_share_spec=0.9, concurrency=64))
# {'config_id': 's512_b8192_g85', 'vllm_args': {'--max-num-seqs': 512, '--max-num-batched-tokens': 8192,
# '--gpu-memory-utilization': 0.85, '--enable-prefix-caching': True}}
python memorypolicy.py prints recommendations for an illustrative 4B-class architecture. mp.scores(...) returns the ranker score for every candidate. Dependencies: torch, safetensors, numpy. Inference takes about 0.15 ms on CPU.
Input contract:
| Input | Meaning | Must be |
|---|---|---|
arch | weight size (GB), layers, hidden size, KV bytes per token | from the model's config and file sizes |
prompt_len | prompt tokens per request | the designed length |
output_budget | generated tokens per request | the pre-specified max_new_tokens |
prefix_share_spec | share of the prompt common across requests | the ratio your workload is built with, not a measured cache hit rate |
concurrency | concurrent requests | 4–256 was covered |
1. What it was trained on
We ran a private vLLM 0.28 server per job on one B200 and swept 15 configurations × 6 synthetic workload families × 4 concurrency levels × 4 models (Qwen3-0.6B, 1.7B, 4B, 8B). That gives 1,440 measured cells, with no missing cells and no duplicates. Prompts are random token-id sequences with a fixed shared prefix. Each request generates exactly its budget (min_tokens = max_tokens, EOS ignored). No production traffic, no user prompts and no operational logs were used, and no shared serving endpoint was loaded.
| Split | Workload families | Models | Scenarios |
|---|---|---|---|
| train | chat (512→256), rag (6000→128, prefix 0.7), longgen (256→1024) | all 4 | 48 |
| dev (model selection) | summarize (12000→256, prefix 0.1) | all 4 | 16 |
| test (evaluated once) | agent (3000→256, prefix 0.9), codeassist (1500→512, prefix 0.5) | 1.7B, 4B | 16 |
Splits are at the scenario level. Feature normalisation statistics come from train only. An earlier run (v1) on the 8B/0.6B test scenarios fed the model post-run metrics from the default config (KV usage, queue length, prefix hit rate, TTFT/TPOT, SLO pass flag). That leaked the answer, so we discarded v1 and its test was not reused. For this version the training code refuses to run unless no forbidden field is an input and the state vector is identical across all 15 candidates of a scenario. That check passed.
Training: utility = throughput / scenario best if the config met the SLO, else −1; ListNet loss (softmax temperature 0.1), MLP 12→128→64→1, AdamW, 400 epochs, seed 0. SLO: p95 TTFT ≤ 3 s, p95 TPOT ≤ 60 ms, error rate ≤ 1%, server started.
2. Results
Dev (summarize, used to choose between the LightGBM and MLP policies; carries selection optimism):
| Policy | SLO violation | Failure | Goodput tok/s | Regret vs oracle |
|---|---|---|---|---|
| vLLM default | 0.5625 | 0.375 | 593 | 0.194 |
| Heuristic | 0.500 | 0.125 | 682 | 0.024 |
| LightGBM (classifier + regressor) | 0.375 | 0.000 | 1049 | 0.0091 |
| This model (MLP ranker) | 0.375 | 0.000 | 1054 | 0.0063 |
The MLP was selected on dev by (violation rate, regret).
Test, evaluated once (16 scenarios; workload families not seen in training, on models 1.7B and 4B that were in training):
| Policy | SLO violation | Failure | Mean tok/s | Goodput tok/s | Throughput ratio (both SLO-ok) | p95 of per-scenario p95 TTFT |
|---|---|---|---|---|---|---|
| vLLM default | 0.250 | 0.000 | 9483 | 5343 | 1.000 | 10.78 s |
| Heuristic | 0.250 | 0.000 | 8172 | 4090 | 0.765 | 13.11 s |
| LightGBM (not selected) | 0.1875 | 0.000 | 8580 | 5811 | 0.977 | 10.43 s |
| This model | 0.250 | 0.000 | 9502 | 5369 | 1.005 | 12.99 s |
Paired comparison against the default, bootstrap over scenarios, B = 2000:
| Metric | Observed Δ | Bootstrap mean Δ | 95% CI |
|---|---|---|---|
| SLO violation rate | 0.0 | 0.0 | [0, 0] |
| Throughput tok/s | +19.0 | +20.4 | [−82.8, +119.9] |
| Goodput tok/s | +26.0 | +26.6 | [−17.0, +77.7] |
Pre-registered gates (all must hold): violation ≤ default ✅, violation CI upper ≤ 0 ✅, throughput ratio ≥ 1 ✅, goodput Δ ≥ 0 ✅, failure rate 0 ✅, reload parity 1.0 ✅.
3. What we measured but do not claim
The non-selected LightGBM policy had a lower test violation rate (0.1875) and higher goodput (5811) than this model. It was not chosen on dev, and swapping it in after seeing the test would be post-hoc selection, so this release ships the dev-selected MLP. The LightGBM boosters (lgbm_slo.txt, lgbm_tput.txt) are included only so the dev comparison can be reproduced. The test violation-rate CI of [0, 0] means the ranker and the default violated the SLO in exactly the same scenarios; it is not evidence of a reduction.
4. Limitations
- No demonstrated gain over the default on held-out data. Use it as a parity baseline or a starting point. Do not use it as a tuner that is known to improve serving.
- p95 TTFT tail is worse than the default on test (12.99 s vs 10.78 s).
- Coverage: one B200 GPU, vLLM 0.28, the Qwen3 dense family from 0.6B to 8B, BF16 weights, concurrency 4–256, and the 15 listed configurations. Other GPUs, engine versions, quantized weights, MoE models or tensor parallelism are out of distribution.
- Workloads are synthetic, with fixed-length outputs and a fixed prefix ratio. Real traffic has variable lengths and arrival bursts that were not modelled.
- Small test set (16 scenarios), so the CIs are wide.
- The test models (1.7B, 4B) were also in the training set. Behaviour on an unseen model is untested.
- Offline evaluation only. No live configuration switching, no online A/B test.
- Not adopted as a serving policy in any product; this release is for research.
- The "regret vs oracle" metric can be negative on test because the oracle only counts SLO-meeting configurations. It is reported for dev only.
5. Files
| File | Purpose |
|---|---|
mlp_ranker.safetensors | ranker weights (the released policy) |
config.json | candidate configurations, feature names and order, train-only normalisation, SLO, forbidden inputs |
memorypolicy.py | inference code |
lgbm_slo.txt, lgbm_tput.txt | LightGBM baseline boosters (dev comparison only) |
eval_summary.json | aggregate dev/test metrics, gates, weight SHA-256 |
No training rows, benchmark rows, prompts or serving logs are published.
6. License
Apache-2.0 covers the weights, config.json and memorypolicy.py, all written and trained by ThakiCloud. The measured Qwen3 models (Apache-2.0) are not redistributed; only their public architecture numbers enter as features. The workloads are synthetic token sequences, so no third-party dataset is involved. LightGBM (MIT) and PyTorch (BSD-3) are runtime dependencies, not bundled.