[Fix] [Intel] spec: Fix XPU nightly dflash stop_regex and DSpark capture check (#45033)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ashwini rathi
2026-10-20 12:27:36 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 72d886efb8
commit d1c3346f74
4 changed files with 46 additions and 6 deletions
+19 -4
View File
@@ -1898,7 +1898,8 @@ class Req(ReqDllmMixin):
*,
stop_str: Optional[str] = None,
stop_regex: Optional[str] = None,
) -> int:
full_window_matched: bool = True,
) -> Optional[int]:
"""Map a matched stop string/regex to output_ids length (stop included)."""
def matched(text: str) -> bool:
@@ -1917,6 +1918,8 @@ class Req(ReqDllmMixin):
if matched(self.tokenizer.decode(token_window[:token_count])):
return start + token_count
if not full_window_matched:
return None
# The full tail window is already known to match by the caller.
return len(self.output_ids)
@@ -1964,12 +1967,24 @@ class Req(ReqDllmMixin):
)
break
if matched:
finished_len = self._locate_str_stop_finished_len(
new_accepted_len, stop_regex=stop_regex_str
)
elif new_accepted_len > 1:
# An end-anchored pattern can match after a token
# accepted mid-step but not after the last one.
finished_len = self._locate_str_stop_finished_len(
new_accepted_len,
stop_regex=stop_regex_str,
full_window_matched=False,
)
else:
finished_len = None
if finished_len is not None:
self.finished_reason = FINISHED_MATCHED_REGEX(
matched=stop_regex_str
)
self.finished_len = self._locate_str_stop_finished_len(
new_accepted_len, stop_regex=stop_regex_str
)
self.finished_len = finished_len
return True
return False
@@ -16,9 +16,12 @@ from sglang.srt.speculative.dspark_components.dspark_draft import (
step_logits_width,
)
from sglang.srt.speculative.spec_tp_sync import SpecTpSync
from sglang.srt.utils import is_xpu
logger = logging.getLogger(__name__)
_is_xpu = is_xpu()
class DsparkDraftSampler:
"""The eager path's markov block, run as the draft cuda graph's tail."""
@@ -109,7 +112,13 @@ class DsparkDraftSampler:
def _step_logits(self, base_logits: torch.Tensor) -> torch.Tensor:
if self.step_logits is None:
# The runner's warmup calls the tail eagerly before capture.
assert not torch.cuda.is_current_stream_capturing()
# torch.cuda's capture query raises on XPU builds.
capturing = (
torch.xpu.is_current_stream_capturing()
if _is_xpu
else torch.cuda.is_current_stream_capturing()
)
assert not capturing
self.step_logits = torch.empty(
(self.max_bs, self.gamma, _step_logits_width(self.model)),
dtype=self.markov_head.step_logits_dtype(base_logits.dtype),