Skip to content

Support spec v2 tree drafting (eagle topk>1) with page_size==1#26866

Merged
hnyls2002 merged 15 commits into
mainfrom
lsyin/spec-v2-topk
Jun 1, 2026
Merged

Support spec v2 tree drafting (eagle topk>1) with page_size==1#26866
hnyls2002 merged 15 commits into
mainfrom
lsyin/spec-v2-topk

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Routes eagle/eagle3 topk>1 to the spec-v2 (overlap) worker when page_size==1 instead of forcing v1, and fixes the v2 tree path: compact the accepted tree path to the front of each per-req block, wire up the (previously stubbed) accepted-KV move, fix its accept_index OOB, and fix the bonus-token stride for bs>1. Validated on EAGLE3 (Llama-3.1-8B) topk=4: greedy output is token-identical to topk=1 across short/long/concurrent bs>1. topk>1 with page_size>1 still falls back to v1.


CI States

Latest PR Test (Base): ❌ Run #26784184010
Latest PR Test (Extra): ❌ Run #26784183914

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Eagle speculative decoding implementation (v2) to support tree drafting (topk > 1). It restricts tree drafting to page_size == 1, fixes an illegal memory access in move_accepted_tokens_to_target_kvcache by iterating over ai_size instead of size, and introduces a compaction mechanism (_compact_accepted_to_front) to align the accepted path to the front of each per-request block. The review feedback highlights an optimization opportunity to reduce VRAM allocation by sizing temporary cache location tensors to ai_size instead of size, and a potential correctness issue where routed_experts_output and indexer_topk_output are not compacted when topk > 1 is active.

Comment thread python/sglang/srt/speculative/eagle_worker_v2.py Outdated
Comment thread python/sglang/srt/speculative/eagle_worker_v2.py Outdated
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_eagle_infer_a.py TestEAGLE3EngineSpecV2Tree

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test_eagle_infer_a.py TestEAGLE3EngineSpecV2Tree:

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_eagle_infer_a.py

TestEAGLE3EngineSpecV2Tree: No test file found matching TestEAGLE3EngineSpecV2Tree under test/registered/ or python/sglang/multimodal_gen/test/.

# Conflicts:
#	test/registered/spec/eagle/test_eagle_infer_a.py
@hnyls2002

hnyls2002 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/spec/eagle/test_spec_eagle.py test/registered/spec/eagle/test_spec_eagle_topk.py test/registered/spec/eagle/test_spec_eagle_page.py test/registered/spec/eagle/test_spec_eagle_triton.py test/registered/spec/eagle/test_spec_eagle_fa3.py test/registered/spec/eagle/test_spec_eagle_parity.py test/registered/spec/eagle/test_spec_eagle_stress.py test/registered/spec/eagle/test_deepseek_v3_fp4_mtp_small.py
(3 tries)

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/spec/eagle/test_spec_eagle_topk.py:

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle_topk.py

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/spec/eagle/test_spec_eagle_topk.py test/registered/spec/eagle/test_spec_eagle_stress.py:

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle_topk.py

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle_stress.py

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/spec/eagle/test_spec_eagle_topk.py test/registered/spec/eagle/test_spec_eagle_stress.py:

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle_topk.py

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle_stress.py

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/spec/eagle/test_spec_eagle.py test/registered/spec/eagle/test_spec_eagle_topk.py test/registered/spec/eagle/test_spec_eagle_page.py test/registered/spec/eagle/test_spec_eagle_triton.py test/registered/spec/eagle/test_spec_eagle_fa3.py test/registered/spec/eagle/test_spec_eagle_parity.py test/registered/spec/eagle/test_spec_eagle_stress.py test/registered/spec/eagle/test_deepseek_v3_fp4_mtp_small.py:

🚀 1-gpu-5090 (4 tests): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle.py
cd test/ && python3 registered/spec/eagle/test_spec_eagle_topk.py
cd test/ && python3 registered/spec/eagle/test_spec_eagle_page.py
cd test/ && python3 registered/spec/eagle/test_spec_eagle_triton.py

🚀 1-gpu-h100 (3 tests): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_spec_eagle_fa3.py
cd test/ && python3 registered/spec/eagle/test_spec_eagle_parity.py
cd test/ && python3 registered/spec/eagle/test_spec_eagle_stress.py

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_deepseek_v3_fp4_mtp_small.py

@hnyls2002
hnyls2002 merged commit 1d4ee06 into main Jun 1, 2026
98 of 110 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/spec-v2-topk branch June 1, 2026 22:37
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_eagle_dp_attention.py

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant