flashinfer.gdn_decode.gated_delta_rule_replayssm_commit¶
- flashinfer.gdn_decode.gated_delta_rule_replayssm_commit(checkpoint_state: Tensor, rawv_cache: Tensor, rawk_cache: Tensor, g_cache: Tensor, beta_cache: Tensor, state_indices: Tensor, accept_lens: Tensor, accept_paths: Tensor | None = None, *, track_state_indices: Tensor | None = None, track_steps: Tensor | None = None, use_qk_l2norm: bool = True, null_block_id: int = -1, backend: Literal['auto', 'simt', 'tcgen05'] = 'auto') None¶
Commit an accepted ReplaySSM prefix into all layers’ checkpoints.
Call
gated_delta_rule_mtp()withcache_replayssm=Truefor each layer first. Verify leaves checkpoints frozen. After acceptance is known, call this function once, then overwrite the windows during the next verify. The cache is not shifted or cleared; unaccepted tokens are discarded.- Parameters:
checkpoint_state (torch.Tensor) – Contiguous FP32
[layers, slots, HV, 128, 128]state, K-last. Updated in place. All tensors must be on the same SM100/SM103 or SM120 device.rawv_cache (torch.Tensor) – Contiguous BF16
[layers, slots, HV, T, 128]raw V windows.rawk_cache (torch.Tensor) – Contiguous BF16
[layers, slots, H, T, 128]pre-normalization K.g_cache (torch.Tensor) – Contiguous FP32
[layers, slots, HV, T]log-decay windows.beta_cache (torch.Tensor) – Contiguous FP32
[layers, slots, HV, T]sigmoid-beta windows.state_indices (torch.Tensor) – Contiguous int32
[B]pool slots. Live slots must be unique and in range. Slots <=null_block_idare ignored.accept_lens (torch.Tensor) – Contiguous int32
[B]accepted token counts in [0, T]. Zero is a no-op, including for optional track writes.accept_paths (torch.Tensor, optional) – Contiguous int32
[B, T]cache rows to replay, in order. Rowjof requestiis replayed only whenj < accept_lens[i]; later entries are padding and may hold any value. Lets tree speculation commit a root-to-node path that is not a contiguous prefix. Replayed rows must lie in [0, T) and must not repeat within a request. DefaultNonereplays rows0..accept_lens[i]-1and compiles a variant with no gather.track_state_indices (torch.Tensor, optional) – Contiguous int32
[B]destinations for an additional checkpoint. Live track slots must be in range, mutually distinct, and disjoint from every livestate_indicesslot. Paired withtrack_steps.track_steps (torch.Tensor, optional) – Contiguous int32
[B]zero-based token indices to save. A step outside the accepted prefix leaves the destination unchanged. Steps count positions along the accepted sequence, so underaccept_pathsstepjsaves the state after replayingaccept_paths[i, j].use_qk_l2norm (bool) – Normalize cached K with epsilon 1e-6. Must match verify. Default True.
null_block_id (int) – Largest reserved/invalid slot; must be >= -1. Default -1.
backend ({"auto", "simt", "tcgen05"}) – With normalized K and no tracking, auto selects TF32 tcgen05 for T=8, or T=6/7 when B>1 and
layers * B * HV >= 256. Otherwise, and whenevertrack_state_indicesis given, it uses FP32 SIMT. Shorter accepted prefixes may favor explicitsimt; auto does not read accepted lengths back to the host. Explicittcgen05supports normalized T=4..8 on SM100/SM103; SM120 always usessimt. With tracking it first runs a short FP32 SIMT pass that writes the tracked snapshots from the untouched checkpoint, so the snapshot is FP32 while the live slot is TF32 and the two can differ by about 1e-5. Usesimtto retain FP32 contractions.
Notes
Index values, accepted lengths,
accept_pathsrows and non-aliasing are caller contracts; they are not read back to the host. Out-of-range path rows are clamped into [0, T) rather than rejected, since checking them would need a device synchronization. All tensor base addresses must be 16-byte aligned for vectorized loads and TMA. Contiguous storage-offset views must also satisfy this alignment. Warm up before CUDA graph capture.