[Spec][Ngram] Followup fixes for MatchState incremental advance#22180
Merged
[Spec][Ngram] Followup fixes for MatchState incremental advance#22180
MatchState incremental advance#22180Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Collaborator
Author
|
/rerun-test test_ngram_corpus.py |
Contributor
|
✅ |
Collaborator
Author
|
/rerun-test test/registered/unit/spec/test_ngram_corpus.py |
Contributor
|
✅ |
Collaborator
Author
|
/rerun-test test/registered/unit/spec/test_ngram_corpus.py test/registered/unit/sampling/test_penaltylib.py test/registered/unit/sampling/test_sampling_params.py |
Contributor
|
✅ |
Collaborator
Author
|
/rerun-test test/registered/unit/spec/test_ngram_corpus.py |
Contributor
|
✅ |
Collaborator
Author
|
/rerun-test test/registered/spec/test_ngram_speculative_decoding.py |
Contributor
|
✅ |
Collaborator
Author
|
/tag-and-rerun-ci |
JustinTong0323
pushed a commit
to JustinTong0323/sglang
that referenced
this pull request
Apr 7, 2026
Fridge003
pushed a commit
that referenced
this pull request
Apr 7, 2026
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.
Followup fixes for #21243.
Summary
advanceMatchState_()— reuse a singlevector<NodeRef>across loop iterationsroot_directly instead of going throughresolve(state, rootRef())which was a tautological check on a freshly-created reftest_ngram_corpus.pyfromspec/utils/tounit/spec/and switch fromregister_cuda_citoregister_cpu_ci(ngram corpus is pure C++, no GPU needed)TestNgramCorpusMatchBenchmark— measures incremental advance vs full rebuild per-step latency withmax_trie_depth=18TrieNode::version/NodeRef::versioninvariant,reset()epoch-based invalidation, match state lifecycle inngram_worker.pyx/Nprogress tracking and timing torerun-test.yml(both CUDA and CPU jobs)Benchmark (CPU,
max_trie_depth=18)match()is O(D) incremental vs O(D²) rebuild, but only accounts for a fraction of totalbatch_getlatency (FFI +buildRecency+fillResultdominate). The 1.40x end-to-end speedup is consistent with expectations at D=18.