Skip to content

kern-serve: --prices serves without a device, every call taking what a bench report measured - #146

Open
xiaguan wants to merge 1 commit into
masterfrom
kern-serve/priced
Open

xiaguan wants to merge 1 commit into
masterfrom
kern-serve/priced

Conversation

@xiaguan

@xiaguan xiaguan commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

What

kern server <target> --prices <report.json> --capacity <tokens> loads no GPU. The frontend, KernScheduler and the rank's pool are the server's own code; the rank behind Run is replaced by priced::Priced, which answers an order once the time a kern bench report measured for the call's shape has passed, and hands back one fixed token a row. It starts in about three seconds and several run beside each other on a machine with no device.

  • A step is priced at its own size (sequences, rows); a size the report lacks is an error that names it.
  • A chunk is read between the two measured chunks around its rows; a token of context adds what the measured chunk at or above it says.
  • Refused: a report of another manifest (sha256), a second rank, a speculative round, the pooled tier, --trace.
  • The real rank's rank item debug line now carries the call's shape (vars, tokens held), so a real server's orders can be priced off the same report.

The report is the one measured on the workload kern workload writes from a manifest's bounds (#143); the error messages and docs name that command's --groups / --chunk, so this reads best after #143.

Measured (docs/serve.md, 2026-11-18, one GB300, Qwen3.8-27B)

The same requests at the same times, open-loop Poisson load, real server with 32 cores:

load TTFT p50 TPOT p50 E2E p50 E2E p99
≤1500 in, 2.5 req/s +1.56% +0.13% −2.41% (the real server's own repeat: −2.06%) −3.10% (repeat: −3.02%)
≤1500 in, 5 req/s +2.09% +0.26% +1.35% +0.07%
≤12000 in, 1.2 req/s +1.44% +0.32% +0.78% +0.97%

Order by order, as shares of a load's summed prices: writing inputs +0.2% to +0.5%, launch to done less the price −0.3% to −0.6%, graph capture of a new shape ≤0.26%; the time between two orders is the same on both servers (45–80 µs against 44–91 µs). What remains is in the prices: whole chunks of 2048–4096 rows are priced 2.3% high, short last chunks over a context 6–8% low.

Gate

crates/kern-serve/tests/priced.rs: six tests over the plain.json fixture (measured calls, the per-token slope, chunk interpolation, the unmeasured-call error, linearity as a property, a priced rank driven through Ranks orders). fmt and clippy -D warnings clean locally.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T11:34:45.441636Z fe61e32 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe61e32c6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let Some(item) = &o.item else { return Ok(vec![Answer::default()]) };
let us = self.prices.price(&self.call(item)?)?;
let a = self.answer(item)?;
wait(issued + Duration::from_secs_f64(us / 1e6));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle negative extrapolated prices before constructing a duration

When a request's context falls outside the measured range, the linear extrapolation can produce a negative duration even when every measurement is positive. For example, measurements of 100 µs at context 16 and 340 µs at context 40 price a one-token context at −50 µs. Prices::read accepts that report, but Duration::from_secs_f64 then panics, killing the scheduler instead of returning an error. Validate the extrapolated price and return a descriptive error or apply an explicit nonnegative pricing policy before constructing the duration.

AGENTS.md reference: AGENTS.md:L111-L112

Useful? React with 👍 / 👎.

…a bench report measured

A server is what it decides and what its GPU takes to run each decision.
`KernScheduler` already runs its ranks' orders through `Run`, so
`priced::Priced` replaces the second and leaves the first alone: it
answers an order once the time `kern bench` measured for the call's shape
has passed, and hands back one fixed token a row. The frontend, the
scheduler and the rank's pool are the server's own code, on a machine
with no GPU, starting in three seconds.

A price is read off the report of the workload `kern workload` writes
from a manifest's bounds: a step at its own size, a chunk between the
measured chunks around its rows, each plus what a token of context adds.
A size nobody measured is an error that names it. A report of another
manifest, a second rank, a speculative round and the pooled tier are
refused.

The real rank's `rank item` debug line now carries the call's shape, so
a real server's orders can be priced off the same report and compared.

Measured against the real server (Qwen3.8-27B, one GB300, open-loop
Poisson load, three load points, docs/serve.md): TPOT p50 within +0.1%
to +0.3%, TTFT p50 +1.4% to +2.1%, E2E p50 within 1.4% where the real
server repeats itself. Order by order, launch to done differs from the
price by -0.3% to -0.6% of the summed prices, writing inputs adds 0.2%
to 0.5%, and the time between two orders is the same on both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: JinYan Su <751080330@qq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant