Repository navigation
[Engine] /v1/stats reports frontend default instead of resolved backend KV page size #598
Description
Before you start
- I have read the FAQ and my problem is not answered there.
- I have read the Roadmap and this is not already planned there.
- I have searched existing issues and found no duplicate.
- I am on the latest release, or on a freshly rebuilt
mainwhen building from source.
What happened
When qsa_sparse resolves 64-token KV pages, the frontend config can still hold the CLI default page_size=1. After real generation, /v1/stats reported total_pages=130 and page_size=1, while /v1/cache/status reported 64-token pages (8,320 tokens). Both endpoints should describe the actual backend pool.
The minimal build_stats reproducer below fails independently of model loading on main d3512b4. I searched existing reports; #552 concerns cumulative timing counters, not page-size correctness.
How did you install FreeToken
Built from source
FreeToken version
0.1.3, main d3512b4
OS
Ubuntu
OS details
Ubuntu 24.04.3 LTS; Linux 7.3.0-070300rc3-generic x86_64; Python 3.12.3; torch 2.11.0+cu130; dedicated Coder Kubernetes Workspace.
GPU and driver
One RTX 5090 32 GB; NVIDIA 610.57.04; CUDA toolkit 13.0.88.
CPU and system RAM
Intel Core Ultra 9 285K; 128 GB physical RAM (134,490,562,560 bytes reported).
Checkpoint
Qwen/Qwen3.8-Flash-Next-FP8, revision 236dfdf285828023ca3bcd3f37366c58a3469b13
Command
ft serve --model /tmp/freetoken-eval/checkpointIndependent minimal reproducer on main:
from types import SimpleNamespace
from freetoken.server.stats import StatsTracker, build_stats
tracker = StatsTracker()
tracker.kv_total_pages = 130
config = SimpleNamespace(served_model_name="unit-model", max_seq_len=262144, page_size=1, served_modalities=(), model_config=SimpleNamespace())
state = SimpleNamespace(stats=tracker, config=config, cache_pools={"page_size": 64})
assert build_stats(state, 0, 0)["kv"]["page_size"] == 64Full log
Focused regression failure and passing-test output
Focused regression excerpts (original main build_stats executed in memory):
.F [100%]
_______________ test_stats_reports_backend_page_size[pools1-64] ________________
pools = {'page_size': 64}, expected = 64
> assert doc["kv"] == {"used_pages": 0, "total_pages": 130, "page_size": expected}
E AssertionError: assert {'used_pages': 0, 'total_pages': 130, 'page_size': 1} == {'used_pages': 0, 'total_pages': 130, 'page_size': 64}
1 failed, 1 passed, 1 warning in 1.09s
Warning: PytestAssertRewriteWarning because anyio was already imported during the in-memory comparison.
Candidate: 2 passed, 1 warning in 0.01s (same warning).
Related accounting/rebuild tests: 33 passed, 1 Starlette dependency deprecation warning in 2.19s.
This is focused regression evidence, not the entire model-loading log. The stats reproduction does not load a model.
Anything else
Prepared with AI assistance; the reported tests were executed in the dedicated Workspace.
A minimal fix reads the existing backend metadata state.cache_pools["page_size"], falling back to config.page_size when metadata is absent. The candidate changes two files: two production lines added/one replaced and 13 regression-test lines. No CLI flag, serving default, API schema or KV allocation changes.
The full-model run required separate candidate loader repairs; those are not part of this stats fix. This stats regression reproduces against original main independently. Full repository tests and upstream CI have not run.
Activity
test(server): cover resolved kv page size and fallback
fix(server): report the backend kv page size in stats
fix(server): report the backend kv page size in stats (#599)
fix(server): report the backend kv page size in stats (FlashML-org#599)