Skip to content

Speculative Decoding with NGRAM support for XPU - #31362

Merged
mingfeima merged 8 commits into
sgl-project:mainfrom
ANSHUMAN87:jh-spec-ngram-support
Sep 23, 2026
Merged

mingfeima merged 8 commits into
sgl-project:mainfrom
ANSHUMAN87:jh-spec-ngram-support

Conversation

@ANSHUMAN87

@ANSHUMAN87 ANSHUMAN87 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds support for NGRAM on XPU target.

JH...!


CI States

Latest PR Test (Base): ❌ Run #35699830673
Latest PR Test (Extra): ❌ Run #35699830563
Latest PR Test (AMD ROCm 10): ❌ Run #35699830695

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@ANSHUMAN87
ANSHUMAN87 marked this pull request as draft July 15, 2026 18:29
@ANSHUMAN87
ANSHUMAN87 force-pushed the jh-spec-ngram-support branch from 6b8e0e3 to 609404b Compare July 15, 2026 18:34

@siju-samuel siju-samuel 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.

resolve merge conflicts
Zero tests for a hand-written kernel implementation
Add E2E XPU data on accuracy/accept-lentgh etc

@ANSHUMAN87

Copy link
Copy Markdown
Contributor Author

resolve merge conflicts Zero tests for a hand-written kernel implementation Add E2E XPU data on accuracy/accept-lentgh etc

Conflict resolved.
Now pytorch kernel is replaced with triton kernel and test case added. Please recheck.
Accuracy verification is in built to gsm8k test cases, which is passing.

Score: 81%
Accept Length: 1.9

JH...!

@ANSHUMAN87
ANSHUMAN87 requested a review from siju-samuel August 13, 2026 06:23
@mingfeima

Copy link
Copy Markdown
Collaborator

@ANSHUMAN87 Hi is this one ready?

cc @Valentine233

@mingfeima mingfeima added intel xpu intel gpu with device `torch.xpu` run-ci CI: run the baseline test suite on this PR labels Aug 20, 2026
@ANSHUMAN87

Copy link
Copy Markdown
Contributor Author

@ANSHUMAN87 Hi is this one ready?

cc @Valentine233

@mingfeima yes this PR is ready for review. Thanks!

JH...!

@Valentine233 Valentine233 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.

Please provide performance result.

@Valentine233

Copy link
Copy Markdown
Contributor

Hi, what is the status for this PR?

@ANSHUMAN87
ANSHUMAN87 force-pushed the jh-spec-ngram-support branch 2 times, most recently from d323a15 to cb2242e Compare September 16, 2026 09:24
@ANSHUMAN87
ANSHUMAN87 marked this pull request as ready for review September 16, 2026 09:25
@ANSHUMAN87

Copy link
Copy Markdown
Contributor Author

Perf Summary:

<style> </style>

NGRAM vs base (with corpus reset between batches): intel_xpu vs triton, on Qwen2.5-Coder-7B-Instruct (concurrency=4, page_size=1)

Backend Scenario BFS(min-max) Match Draft Tokens TPS Accept Len Speedup Status
intel_xpu (base, no-spec) - - - 111.97 - 1.000x ok
intel_xpu chain, 8 steps (BFS) 1-1 BFS 8 180.41 1.855 1.611x ok
intel_xpu chain, 12 steps (BFS) 1-1 BFS 12 163.49 1.855 1.460x ok
intel_xpu chain, 16 steps (BFS) 1-1 BFS 16 162.62 1.855 1.452x ok
intel_xpu chain, 8 steps (PROB) 1-1 PROB 8 180.28 1.855 1.610x ok
intel_xpu chain, 12 steps (PROB) 1-1 PROB 12 163.90 1.855 1.464x ok
intel_xpu chain, 16 steps (PROB) 1-1 PROB 16 163.84 1.855 1.463x ok
triton (base, no-spec) - - - 110.67 - 1.000x ok
triton chain (bfs=1) 1-1 BFS 8 141.16 1.855 1.275x ok
triton narrow BFS (bfs=2) 1-2 BFS 12 130.82 1.855 1.182x ok
triton default BFS (bfs=4) 1-4 BFS 12 134.62 1.910 1.216x ok
triton wide BFS (bfs=8) 1-8 BFS 16 134.70 1.910 1.217x ok
triton default PROB (bfs=4) 1-4 PROB 12 130.86 1.855 1.182x ok
triton wide PROB (bfs=8) 1-8 PROB 16 130.96 1.855 1.183x ok

Best config per backend

  • intel_xpu: chain, 8 steps (BFS) (bfs=1-1, match=BFS, draft_tokens=8) — speedup 1.611x, accept_length 1.855
  • triton: chain (bfs=1) (bfs=1-1, match=BFS, draft_tokens=8) — speedup 1.275x, accept_length 1.855

JH...!

@Valentine233

Copy link
Copy Markdown
Contributor

For perf result, why is BFS always 1-1 for intel_xpu?

@ANSHUMAN87
ANSHUMAN87 force-pushed the jh-spec-ngram-support branch from d1b82f8 to 798cd3f Compare September 18, 2026 06:02
@ANSHUMAN87

Copy link
Copy Markdown
Contributor Author

why is BFS always 1-1 for intel_xpu?

bfs>1 is equivalent to topk>1 for intel_xpu attention backend. For which currently we dont support.

@ANSHUMAN87
ANSHUMAN87 force-pushed the jh-spec-ngram-support branch from 81250e2 to dc02c07 Compare September 18, 2026 07:11

@mingfeima mingfeima left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

some minor changes needed. and please rebase to master.

@ANSHUMAN87
ANSHUMAN87 force-pushed the jh-spec-ngram-support branch 2 times, most recently from 6eae838 to cc858a3 Compare September 22, 2026 06:59
@ANSHUMAN87
ANSHUMAN87 force-pushed the jh-spec-ngram-support branch from cc858a3 to 296883b Compare September 22, 2026 07:03
@ANSHUMAN87

Copy link
Copy Markdown
Contributor Author

some minor changes needed. and please rebase to master.

Rebased.

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

Labels

intel jit-kernel run-ci CI: run the baseline test suite on this PR speculative-decoding xpu intel gpu with device `torch.xpu`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants