Skip to content

feat(router): make the two-tier cost function the default KV policy (DYN-5308) - #162

Draft
ishandhanani wants to merge 5 commits into
mainfrom
idhanani/dyn-5308-two-tier-default
Draft

ishandhanani wants to merge 5 commits into
mainfrom
idhanani/dyn-5308-two-tier-default

Conversation

@ishandhanani

@ishandhanani ishandhanani commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Makes the two-tier cost function (dynamo-two-tier-cost-fn) the default worker-selection policy for --router-mode kv, and logs a startup notice so users know about the change. Closes DYN-5308.

  • lib/router-plugins/builtin/src/two_tier_cost_fn.rs: new default_factory() that hosts install as the default. It uses the upstream sgl-router thresholds (cache_threshold 0.5, balance_abs_threshold 32, balance_rel_threshold 1.1) and keeps session-affinity targets exclusive, as the previous default did.
  • Where the previous default read no cache overlap (plain disagg decode, the --load-aware preset, overlap_score_credit: 0), the default two-tier picker declares only WorkerInputs::LOAD and selects the worker with the fewest active requests. The host therefore runs no KV indexer or event subscription for those routers, as before. Configured dynamo-two-tier-cost-fn instances are unchanged.
  • lib/llm/src/kv_router/plugins.rs: the installed registry and the fallback registry both use the two-tier default factory.
  • lib/llm/src/entrypoint/input/http.rs: logs a WARN at frontend startup when --router-mode kv runs without a configured worker-selection policy:

    Starting with Dynamo 1.8, --router-mode kv defaults to the two-tier cost function (dynamo-two-tier-cost-fn). To keep the previous cost function, select a dynamo-default-cost-fn instance in --router-policy-config.

  • Docs: the router configuration page describes the new default and how to opt out.

To opt out, configure an instance of the previous cost function:

worker_selection:
  aggregated: previous
  prefill: previous
  instances:
    - name: previous
      type: dynamo-default-cost-fn

Behavior changes for default --router-mode kv

  • Cost-function flags have no effect. overlap_score_weight/overlap_score_credit (except 0, which turns off the cache tier), router_temperature, prefill_load_scale, and the host, disk, and shared cache weights all tune the previous cost function. Two-tier reads only its three thresholds.
  • PATCH /router_policy returns 422 for default pools, because two-tier has no runtime parameters. GET /router_policy lists them with configuration: null.
  • The load signal is the active request count, not prefill tokens or decode blocks. This also applies to plain decode pools. Ties go to the first candidate row, where the previous default sampled randomly among ties.

Open items

  • Threshold values: per the ticket, confirm with Guan before merge. The defaults are the sgl-router cache_aware_zmq values.
  • Release timing: main is still 1.7.0 and release/1.7.0 is not cut yet. Merge after the cut so this ships in 1.8 as the notice says.

Validation

  • cargo test -p dynamo-custom-policy-builtin: all pass.
  • cargo test -p dynamo-llm --lib: 3920 passed, 0 failed. Two existing tests changed:
    • selection_matches_frozen_frontend_trace now pins dynamo_custom_policy_builtin::default_factory(), so the frozen trace keeps covering the additive cost function.
    • kv_chooser_ignores_stale_presence now asserts that the default pool reports no runtime parameters.
  • Not run: the Python bindings crate and e2e router tests. No end-to-end routing benchmark yet comparing two-tier against the previous default.

@github-actions github-actions Bot added feat documentation Improvements or additions to documentation router labels Nov 1, 2026
@ishandhanani
ishandhanani force-pushed the idhanani/dyn-5308-two-tier-default branch from ead35f9 to 2bc1b6a Compare November 1, 2026 15:36
jthomson04 and others added 5 commits November 1, 2026 18:45
…ai-dynamo#17699)

Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…namo#17700)

Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Add the factory hosts will install to make dynamo-two-tier-cost-fn the
default worker-selection policy. It keeps session-affinity targets exclusive
and, on plain decode pools and with zero overlap credit (the load-aware
preset), declares load-only inputs so those routers still run no KV indexer.
Hosts still install the current default.

The HTTP frontend logs a startup notice when --router-mode kv runs without a
configured worker-selection policy, and the router configuration docs
announce the 1.8 change and the dynamo-default-cost-fn opt-out.

Part of DYN-5308

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
The test's frontends subscribe to KV events over NATS, but the mockers
published on the runtime default (ZMQ), so the routers never saw the prefix
blocks. The test still passed because the previous default broke equal-cost
ties at random; the two-tier default breaks them by row order and failed
every attempt.

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Hosts now install dynamo-two-tier-cost-fn as the default worker-selection
policy for --router-mode kv. The startup notice and router docs now describe
the default as current.

The frozen frontend selection trace pins the previous cost function so it
keeps covering it, and the stale-presence test expects the default pool to
report no runtime parameters.

Closes DYN-5308

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani
ishandhanani force-pushed the idhanani/dyn-5308-two-tier-default branch from 18bc21c to 09ac594 Compare November 2, 2026 04:09

This branch had an error being deployed

1 failed deployment
external_collaborator — 09ac594c Deployed Nov 2, 2026 by ishandhanani via ok-to-test #444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feat router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants