Conversation
|
👋 Hi bzsuni! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. Walkthrough
ChangesStop sequence precedence
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The updated stop precedence behavior has no identified merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Signed-off-by: bzsuni <bingzhe.sun@daocloud.io>
f234f8a to
d2eb2b6
Compare
There was a problem hiding this comment.
Hi @bzsuni, can you share more context / motivation on this change?
vLLM and SGLang behave differently on this functionality.
Before this PR, dynamo's stop sequence behavior fully matches sglang's stop sequence behavior across the board, but only matches vllm behavior on some of the cases, see below:
For decoded fragment "there", cells show the selected stop string:
| Stop list | Dynamo before PR | Dynamo after PR | SGLang 0.5.19 | vLLM 0.28.0 |
|---|---|---|---|---|
["her", "he"] |
"her" |
"her" |
"her" |
"he" |
["he", "her"] |
"he" |
"he" |
"he" |
"he" |
["re", "here"] |
"re" |
"here" |
"re" |
"re" |
["here", "re"] |
"here" |
"here" |
"here" |
"here" |
["here", "the"] |
"here" |
"the" |
"here" |
"the" |
After this PR, dynamo behavior does not fully match either vllm or sglang, it is a hybrid of the two.
I'm not sure if this is a net win, so I'm looking for more context/motivation from you on the change here to better understand the need.
There was a problem hiding this comment.
Thanks for the detailed comparison, @rmccorm4. I looked into this more and I think my original assumption in this PR was wrong.
Dynamo already processes engine output token-by-token in
Lines 1043 to 1072 in 0951489
token_ids, calls step() for each token, and returns as soon as one triggers a stop. So the speculative-decoding issue that motivated vLLM#49391 doesn't directly apply here.
The remaining Dynamo case is much narrower: multiple stop strings matching inside the decoded text of a single token. SGLang doesn't really define this case either — its detokenizer still has an explicit TODO for multiple stop strings being hit
So the earliest-start rule in this PR was based on my incorrect assumption. I don't see enough correctness benefit to justify changing Dynamo's existing semantics here, so I'm going to close this. Thanks for catching it.
Overview
When multiple stop strings match in one decoded fragment, the Rust frontend selects the first match in the request's
stoplist instead of the earliest match in the text.For example, decoding
therewithstop: ["re", "he"]returnsthe, while reversing the list returnst. The first ordering leaves the earlier"he"stop sequence in the returned text.This change selects the stop match with the earliest text position. If multiple stop strings match at the same position, it keeps the existing list-order precedence.
Details
Decoder::stepnow compares match offsets before truncating the decoded text and reporting the selected stop string.Reproduction
A local Rust check used a local copy of the DeepSeek-R1-Distill-Qwen-1.5B tokenizer, which encoded
thereas the single token18532, and passed it through the actualDecoderwith stop strings excluded from output:["re", "he"]thet["he", "re"]ttThis exercised the tokenizer and decoder without model inference or an HTTP server.
The regression test in
test_stop_behavior.rsuses["re", "he"]in bothinclude_stop_str_in_outputmodes, checking the output text and stop reason.Validation
The new regression test fails before the fix and passes afterward. The full stop-behavior test target also passes: 16 passed.
cargo test --locked --offline -j 4 -p dynamo-llm --no-default-features \ --test test_stop_behaviorRelated Issues
🚫 This PR is NOT linked to an issue:
Summary by CodeRabbit