fix(sglang): derive enable_eagle from SpeculativeAlgorithm.is_eagle() (covers EAGLE3)#10982
Draft
yifjiang wants to merge 1 commit into
Draft
fix(sglang): derive enable_eagle from SpeculativeAlgorithm.is_eagle() (covers EAGLE3)#10982yifjiang wants to merge 1 commit into
yifjiang wants to merge 1 commit into
Conversation
Contributor
|
👋 Hi yifjiang! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
635fe3d to
f6d54b0
Compare
f6d54b0 to
25ec553
Compare
… (covers EAGLE3)
ModelRuntimeConfig.enable_eagle was set from a hand-maintained name set
("EAGLE", "NEXTN"). The KV router uses enable_eagle to bigram-align the frontend's
prompt-block hashes so they match the worker's KV events. But sglang's radix cache
bigrams its KV-event hashes iff SpeculativeAlgorithm.is_eagle() (srt/managers/scheduler.py)
= {EAGLE, EAGLE3, FROZEN_KV_MTP}, so the name set had drifted from the real predicate:
- EAGLE3 was missing -> an EAGLE3 worker publishes enable_eagle=false -> the frontend
hashes prompt blocks at plain page_size while the worker emits bigram-keyed hashes ->
overlap is always 0 -> KV-aware routing is cache-blind for EAGLE3.
- "NEXTN" in the set is dead: ServerArgs normalizes NEXTN/EAGLE to EAGLE (or FROZEN_KV_MTP
for Gemma4 drafts) before register sees it, so the literal never matches "NEXTN" -- and
FROZEN_KV_MTP (is_eagle()=true) was also missing.
Derive enable_eagle from spec_algorithm.is_eagle() so it stays in lockstep with the radix's
bigram condition by construction; this covers EAGLE3 and FROZEN_KV_MTP and drops the dead
literal. Add a parametrized unit test pinning the enabled set to is_eagle().
Signed-off-by: Yifan Jiang <19356972+yifjiang@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
25ec553 to
e4b95f4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
components/src/dynamo/sglang/register.pysetsModelRuntimeConfig.enable_eagle = Truefrom a hand-maintained name set("EAGLE", "NEXTN"). The KV router usesenable_eagle(lib/llm/src/discovery/watcher.rs) to bigram-align the frontend's prompt-block hashes (window = stride + 1,lib/kv-router/src/protocols.rs) so they match the worker's KV events.But the worker's radix cache bigram-keys its KV-event hashes iff
SpeculativeAlgorithm.is_eagle()(srt/managers/scheduler.py) ={EAGLE, EAGLE3, FROZEN_KV_MTP}. The name set had drifted from that predicate:enable_eagle=false→ the frontend hashes at plainpage_sizewhile the worker emits bigram-keyed hashes → overlap is always 0 → KV-aware routing is cache-blind for EAGLE3 (falls back to load-only)."NEXTN"is dead:ServerArgs.upper()s the value and_resolve_speculative_algorithm_aliasnormalizesNEXTN/EAGLE→EAGLE(orFROZEN_KV_MTPfor Gemma4 drafts) beforeregistersees it, so the literal never matches"NEXTN"— andFROZEN_KV_MTP(is_eagle()=true) was also missing.Fix
Derive
enable_eaglefromspec_algorithm.is_eagle()— the same predicate the radix cache uses — so the frontend window and the worker's events stay in lockstep by construction; this covers EAGLE3 and FROZEN_KV_MTP and drops the dead literal:e2e before/after (public repro)
Stock dynamo + sglang (
nvcr.io/nvidia/ai-dynamo/sglang-runtime:1.3.0-dev.1-cuda12, sglang 0.5.12.post1),Qwen/Qwen3-4B+AngelSlim/Qwen3-4B_eagle3(EAGLE3 draft), single warm node,--router-mode kv --router-kv-events, EAGLE3 spec, a repeated ~930-token prefix (page-size 16→ 58 blocks). Same binary, same models — onlyregister.pydiffers between phases:enable_eagleregister.py)falsetrueBefore, the router's Formula logged
with 0.00 effective cached blockson every warm request (EAGLE3 worker's bigram events never matched the plain-token frontend hashes). After, the same warm prefix logswith 58.00 effective cached blocks— the worker's events now match, so KV-aware routing sees the cache. (The bug andenable_eagle: falsewere also reproduced on a separate EAGLE3 deployment; this Qwen3-4B run is the public, reproducible demonstration.)Testing
test_eagle_enabled_for_speculative_algorithmpins the enabled set tois_eagle():EAGLE/EAGLE3/FROZEN_KV_MTP→ True;DFLASH/NGRAM/STANDALONE/NONE/None→ False — guarding against the set drifting again.lib/kv-router/src/protocols.rs::test_compute_block_hash_for_seq_eagle_windowsexercisesis_eagle = Some(true)→ thestride+1bigram window. So onceenable_eagletracksis_eagle(), EAGLE3/FROZEN_KV_MTP flow through the same validated bigram-window path EAGLE already used.Scope
Any EAGLE3 (or FROZEN_KV_MTP) model under
--router-mode kvwith ≥2 workers and worker KV events; single-worker / no-router / no-kv-events unaffected.