Files
sglang/python
leavelet a4ec2236ef Fix spec-decode grammar mask crash under xgrammar 0.2.1 (strict tvm-ffi binding)
EAGLE verify's traverse_tree.dfs recurses with dfs(retrieve_next_token[curr], ...),
so curr (the fill_next_token_bitmask/accept_token index) degrades from a Python int
to a 0-dim torch tensor at recursion depth >= 2. xgrammar's Python signature is
unchanged across 0.1.27 -> 0.2.1, but the binding swapped pybind11 -> apache-tvm-ffi:
the old binding silently coerced the 0-dim tensor to int, the new one rejects it with
"Expected int but got ffi.Tensor", crashing the decode scheduler on grammar-constrained
(tool-call / structured-output) requests with draft depth >= 2.

Wrap the propagated indices in int(), matching upstream (PR #21722):
  - accept_token(int(draft_tokens[curr]))
  - dfs(int(retrieve_next_token[curr]), ...)
  - dfs(int(retrieve_next_sibling[curr]), ...)
Version-agnostic: correct on both 0.1.27 and 0.2.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 07:22:26 +00:00
..
2026-06-10 05:54:43 +08:00