Skip to content

[Engine] /v1/stats reports frontend default instead of resolved backend KV page size #598

Closed

Description

@yunwei37

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 main when 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/checkpoint

Independent 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"] == 64

Full 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglinux

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions