Skip to content

refactor(router): give the kernel its own config slice - #134

Closed
ishandhanani wants to merge 1 commit into
idhanani/dyn-178-admissionfrom
idhanani/dyn-179-router-config-slice
Closed

ishandhanani wants to merge 1 commit into
idhanani/dyn-178-admissionfrom
idhanani/dyn-179-router-config-slice

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Step 6-0 of the router split v2 (DYNO-179). Stacked on #133. Behavior-preserving: the scheduler kernel gets a configuration slice of its own, the first boundary the kernel crate needs.

Summary

  • RouterConfig (scheduling/router_config.rs, the kernel's config module after the move) holds exactly what the kernel reads of the flat config today: selection: SelectionConfig (handed to the policy factory), conditional_disagg: ConditionalDisaggConfig (its two busy thresholds feed the load report), use_kv_events, track_prefill_tokens and assume_kv_reuse with assume_kv_reuse(override) mirroring the flat config's helper, queue_recheck_interval, and profiles: PolicyProfileSource, a closure that resolves a partition's PolicyProfile by model name (queueing_enabled(model) asks it).
  • Validated<RouterConfig>. RouterConfig::validate(self) runs the selection slice's own checks (the same finite, non-negative checks the flat config applies, cache-hit weights included) plus a non-zero recheck interval, which the flat config cannot produce, and yields the newtype with a private constructor; SelectionCore::new_inner accepts nothing else (invariant G4). impl From<&KvRouterConfig> for RouterConfig lives in scheduling/config.rs with the flat config; it clones the flat config into the profile source so profiles resolve lazily through the policy file it already loaded, failing at partition creation exactly where policy_profile failed before.
  • Overlap takes the weights. CacheHitWeights { host, disk } is a two-field view of the selection slice's host_cache_hit_weight/disk_cache_hit_weight (From<&SelectionConfig>, From<&KvRouterConfig>), so the knob has one home and both the policies that score tiers themselves and the kernel's overlap analysis read it. OverlapAnalysis::new(&CacheHitWeights, ..), cache_hit_estimates_from_tiered_matches(&CacheHitWeights, ..), TieredOverlapRefresher::new(provider, CacheHitWeights, block_size); the core derives it from config.selection, lib/llm's two call sites and the mocker's three pass CacheHitWeights::from(&config); CacheHitWeights::default() is the flat config's defaults (0.75 host, 0.25 disk).
  • Unchanged surface. SelectionCore::try_new_local* still take KvRouterConfig and convert after apply_policy_config/validate_config, so tests, benches, and the service builder keep their calls; the builder converts once before new_inner.

Audit behind the field list (inventory split-v2/inventory-scheduler.md §4): overlap.rs and overlap_refresh.rs read the two weights; core/mod.rs reads use_kv_events; core/workers.rs builds a partition's scheduler from the selection slice, the profile, the recheck interval, and track_prefill_tokens; core/{queries,reservations,run}.rs read track_prefill_tokens, assume_kv_reuse(override), and the conditional-disagg thresholds; queue.rs, local.rs, types.rs, filter.rs never name the flat config.

Validation

  • cargo test -p dynamo-kv-router --features standalone-selection,standalone-slot-tracker,metrics,testing: 532 lib + 2 plugin-API + 7 standalone-HTTP tests pass.
  • cargo clippy -- -D warnings: kv-router (all targets, same features), dynamo-llm, dynamo-mocker, dynamo-ext-proc, dynamo-custom-policy-builtin, dynamo-bench (--tests), dynamo-sglang-sidecar: clean.
  • Builtin policy tests 56+5+1+3+20+3+4; cargo test -p dynamo-llm kv_router 485 and --lib watcher 36; cargo test -p dynamo-mocker --lib 304.
  • scripts/router_layering_check.sh: 24 checks, 0 failures. CODEOWNERS --strict clean. cargo fmt --all -- --check clean.
  • scripts/router_move_diff.py 37e939a361 WORKTREE over scheduling/{config,overlap,overlap_refresh,mod}.rs, services/selection/{core,service.rs}, lib/llm kv_router.rs, the two mocker files (+ router_config.rs on the head side): common=16814 new=198 dropped=58; every new line is the RouterConfig/Validated/CacheHitWeights code and the self.config.* reads, every dropped line a kv_router_config read or the old KvRouterConfig parameter (artifact: s6-0-move-diff.txt).
  • Not a move, so no bench: no hot-path code changed (the overlap analysis reads two f64s from a 16-byte struct instead of from the flat config).

Step 6-0 of the router split (DYNO-179). The scheduler kernel stops
reading the flat KvRouterConfig. RouterConfig (scheduling/
router_config.rs) holds exactly what the kernel reads: the worker-
selection and conditional-disagg slices, use_kv_events,
track_prefill_tokens and assume_kv_reuse with their override-aware
helpers, the queue recheck interval, and a PolicyProfileSource that
resolves a partition's profile by model name. RouterConfig::validate
runs the selection slice's checks plus a non-zero recheck interval and
yields Validated<RouterConfig>, the only config SelectionCore::new_inner
accepts (invariant G4); the flat config converts with
From<&KvRouterConfig>, resolving profiles lazily through the policy
file it loaded so a bad file still fails where policy_profile failed
before.

OverlapAnalysis::new, cache_hit_estimates_from_tiered_matches, and
TieredOverlapRefresher::new take CacheHitWeights, a two-field view of
the selection slice's host and disk cache-hit weights, instead of the
whole flat config; the kernel derives it from config.selection, and
lib/llm and the mocker pass CacheHitWeights::from(&config) at their
five call sites. SelectionCore holds the validated slice; its
try_new_local constructors still take KvRouterConfig and convert, so
tests and benches are unchanged.

Validation: cargo test -p dynamo-kv-router --features
standalone-selection,standalone-slot-tracker,metrics,testing (532 lib +
2 plugin-API + 7 standalone HTTP); clippy -D warnings on kv-router
(all targets, same features), dynamo-llm, dynamo-mocker, dynamo-ext-proc,
dynamo-custom-policy-builtin, dynamo-bench (--tests), dynamo-sglang-sidecar;
builtin tests 56+5+1+3+20+3+4; cargo test -p dynamo-llm kv_router (485)
and --lib watcher (36); dynamo-mocker --lib 304; router layering gate
24/24; CODEOWNERS strict clean; cargo fmt --check clean; move-diff vs
37e939a lists only the RouterConfig/Validated/CacheHitWeights additions
and the removed KvRouterConfig reads (summary common=16814 new=198
dropped=58).

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani

Copy link
Copy Markdown
Owner Author

Landed upstream as ai-dynamo#18055 (squash commit 79692cf on main, 2026-11-11). Closing this fork review unit.

This branch had an error being deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant