Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2018975
[Perf] [DSV4.1] DSpark draft: restage the draft graph's sampling para…
YAMY1234 Oct 20, 2026
1f8e4f3
[Perf] DSV4 DSpark: the draft runner's metadata prep through the glue…
YAMY1234 Oct 20, 2026
cead65c
[Perf] MXFP4 trtllm-gen MoE: pass the finalized output shape on defer…
YAMY1234 Oct 20, 2026
725c0fc
[Perf] [NVIDIA] DSpark: fused static accept tail (static greedy accep…
YAMY1234 Oct 20, 2026
7828175
[Perf] DSV4.1 DSpark: step inputs in one launch; verify ids from the …
YAMY1234 Oct 20, 2026
e0b18eb
[Perf] [NVIDIA] DSpark: defer the static verify's draft context-KV co…
YAMY1234 Oct 20, 2026
157b13b
[Perf] cuda graph: replay fill fast paths (skip the padding reset of …
YAMY1234 Oct 20, 2026
11a36d3
[Perf] DSV4.1 DSpark: the target verify runner's metadata prep throug…
YAMY1234 Oct 20, 2026
5a0dbed
[Perf] DSV4.1 DSpark: engram history commit and block accept lens ins…
YAMY1234 Oct 20, 2026
0d9304b
[Perf] DSV4.1 DSpark: the draft graph's metadata prep on a side stream
YAMY1234 Oct 20, 2026
67edc98
[Perf] DSV4.1 DSpark: POST_FOLD, relay seq lens and bonus from the ve…
YAMY1234 Oct 20, 2026
fb38ac5
[Perf] [NVIDIA] DSpark: project the deferred context KV inside the ve…
YAMY1234 Oct 20, 2026
fab2184
[Perf] DSV4.1 DSpark: the simulated bonus reads the shared length as …
YAMY1234 Oct 20, 2026
e05d7b0
[Perf] DSV4.1 DSpark: the deferred commit's staging in one launch
YAMY1234 Oct 20, 2026
c2cfb27
[Perf] DSV4.1 DSpark: build the target verify metadata beside the dra…
YAMY1234 Oct 20, 2026
4c2831f
[Perf] DSV4.1 DSpark: a pre-planned verify replay skips its input re-…
YAMY1234 Oct 20, 2026
c9df4af
[Perf] cuda graph: skip the replay view once the metadata glue graph …
YAMY1234 Oct 20, 2026
31806c8
[Perf] DSV4.1 DSpark: draw the simulated acceptance before the draft …
YAMY1234 Oct 20, 2026
35ec4f1
[Perf] [NVIDIA] DSpark: block-wise rejection sampling for the sampled…
YAMY1234 Oct 20, 2026
6410850
[Perf] [NVIDIA] DSpark: a CUDA graph of the static verify's temperatu…
YAMY1234 Oct 20, 2026
759de9f
[Fix] DSpark: address review on the metadata glue and early verify st…
YAMY1234 Oct 22, 2026
b69cdf6
Merge upstream main and resolve decode graph capture conflicts
Oasis-Git Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion python/sglang/kernels/ops/embeddings/engram_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ def _engram_commit_history_kernel(
tokens_ptr,
slots_ptr,
commit_ptr,
live_ptr,
gate_ptr,
HISTORY_STRIDE: tl.constexpr,
HISTORY_WIDTH: tl.constexpr,
TOKEN_STRIDE: tl.constexpr,
BLOCK: tl.constexpr,
GATED: tl.constexpr,
):
row = tl.program_id(0)
if GATED:
# Captured rows past the live batch, or a step the graph does not commit.
if (tl.load(live_ptr + row) == 0) | (tl.load(gate_ptr) == 0):
return
slot = tl.load(slots_ptr + row).to(tl.int64)
commit = tl.load(commit_ptr + row)
col = tl.arange(0, BLOCK)
Expand All @@ -60,8 +67,12 @@ def engram_commit_history(
verify_ids: torch.Tensor,
req_slots: torch.Tensor,
commit_lens: torch.Tensor,
live_rows: Optional[torch.Tensor] = None,
gate: Optional[torch.Tensor] = None,
) -> None:
"""Update distinct live request slots with anchor + correct drafts, not bonus."""
"""Update distinct live request slots with anchor + correct drafts, not bonus.
With ``live_rows`` and ``gate``, rows whose live entry is 0 are skipped, and all
rows when ``gate[0]`` is 0."""
bs = req_slots.numel()
width = history.shape[1]
if bs == 0 or width == 0:
Expand All @@ -73,10 +84,13 @@ def engram_commit_history(
verify_ids,
req_slots,
commit_lens,
live_rows if live_rows is not None else commit_lens,
gate if gate is not None else commit_lens,
HISTORY_STRIDE=history.stride(0),
HISTORY_WIDTH=width,
TOKEN_STRIDE=verify_ids.stride(0),
BLOCK=triton.next_power_of_2(width),
GATED=live_rows is not None,
num_warps=4,
)

Expand Down
28 changes: 28 additions & 0 deletions python/sglang/kernels/ops/speculative/cache_locs.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ def assign_extend_cache_locs_uniform(
PAGE_SIZE: tl.constexpr = 1,
num_v_pages=0,
num_swa_pages=0,
positions_out=None,
anchor_src=None,
anchor_out=None,
anchor_stride=0,
):
"""Uniform-length variant of assign_extend_cache_locs: every row extends
exactly draft_token_num tokens, so the end offset is start +
Expand All @@ -556,6 +560,8 @@ def assign_extend_cache_locs_uniform(
kv_start = tl.load(start_offset + pid)
token_pool = req_to_token + tl.load(req_pool_indices + pid) * pool_len
out_cache_ptr = out_cache_loc + pid * draft_token_num
if anchor_out is not None:
tl.store(anchor_out + pid * anchor_stride, tl.load(anchor_src + pid))

offs = tl.arange(0, BLOCK_SIZE)
num_loop = tl.cdiv(draft_token_num, BLOCK_SIZE)
Expand All @@ -564,6 +570,12 @@ def assign_extend_cache_locs_uniform(
mask = o < draft_token_num
data = tl.load(token_pool + kv_start + o, mask=mask)
tl.store(out_cache_ptr + o, data, mask=mask)
if positions_out is not None:
tl.store(
positions_out + pid * draft_token_num + o,
kv_start.to(tl.int64) + o,
mask=mask,
)
if full_v2p is not None:
page = data // PAGE_SIZE
valid = mask & (data >= 0) & (page < num_v_pages)
Expand Down Expand Up @@ -594,6 +606,9 @@ def assign_extend_cache_locs_uniform_func(
full_out: Optional[torch.Tensor] = None,
swa_out: Optional[torch.Tensor] = None,
page_size: int = 1,
positions_out: Optional[torch.Tensor] = None,
anchor_src: Optional[torch.Tensor] = None,
anchor_out: Optional[torch.Tensor] = None,
) -> torch.Tensor:
"""assign_extend_cache_locs for the uniform case (all rows extend exactly
draft_token_num tokens, e.g. spec target-verify prep). Computes end
Expand All @@ -602,6 +617,8 @@ def assign_extend_cache_locs_uniform_func(
and SWA write windows in the same launch; the returned ids stay virtual.
Mapping tables and output buffers must be contiguous, with one output
per gathered token. Translation is rank-local (no DCP widening).
``positions_out`` ([batch, draft_token_num] int64) gets start + column and
``anchor_out[:, 0]`` gets ``anchor_src``, in the same launch.
"""
if full_v2p is not None:
assert full_out is not None and full_out.numel() == batch_size * draft_token_num
Expand Down Expand Up @@ -632,11 +649,22 @@ def assign_extend_cache_locs_uniform_func(
PAGE_SIZE=page_size,
num_v_pages=0 if full_v2p is None else full_v2p.numel(),
num_swa_pages=0 if swa_v2p is None else swa_v2p.numel(),
positions_out=positions_out,
anchor_src=anchor_src,
anchor_out=anchor_out,
anchor_stride=0 if anchor_out is None else anchor_out.stride(0),
)
return out_cache_loc

# NPU / CPU platforms: fall back to the end_offset-tensor path.
assert full_v2p is None, "fused write translation requires a Triton device"
if positions_out is not None:
positions_out.copy_(
start_offset.to(torch.int64).view(-1, 1)
+ torch.arange(draft_token_num, device=start_offset.device)
)
if anchor_out is not None:
anchor_out[:, 0].copy_(anchor_src.view(-1))
return assign_extend_cache_locs_func(
req_pool_indices=req_pool_indices,
req_to_token=req_to_token,
Expand Down
Loading
Loading