Skip to content

vllm.v1.worker.replayssm_utils

Worker-owned FlashInfer ReplaySSM state and request lifecycle.

Classes:

Functions:

ReplaySSMModelContext dataclass

Shared replay plans with independent physical slots for each cache group.

Methods:

  • postprocess –

    Commit all groups before publishing their canonical prefix states.

  • reset_new_slots –

    Reset the trackers of fresh physical slots in all groups.

_materialize(num_reqs)

Publish all canonical prefix snapshots in one kernel launch.

postprocess(*, idx_mapping, query_metadata, query_metadata_is_cumulative, num_computed_tokens, num_computed_is_post_step, num_accepted_tokens, is_prefilling, live_cols, num_reqs)

Commit all groups before publishing their canonical prefix states.

reset_new_slots(*, idx_mapping, src_cols, dst_cols, num_reqs)

Reset the trackers of fresh physical slots in all groups.

Run after the align pre-copy, which copies continuing slots' pages.

_bind_replayssm_rand_seeds(forward_context, names)

Give each layer one slot of a shared Philox seed buffer.

The first executed layer refreshes the whole buffer with one launch per step instead of every layer drawing its own seed.

_compact_replayssm_requests_kernel(plan_flush_count, active_request_indices, num_reqs, MAX_NUM_REQS, BLOCK_SIZE)

Build the shared FlashInfer active-request list.

_postprocess_replayssm_kernel(idx_mapping, query_metadata, num_computed_tokens, num_accepted_tokens, is_prefilling, live_cols, block_table_ptrs, tracker_ptrs, tracker_slot_strides, layer_offsets, src_slots_ptrs, dst_slots_ptrs, plan_ring_start, plan_flush_count, block_table_strides, num_layers, MAX_NUM_REQS, MAMBA_BLOCK_SIZE, LOGICAL_WINDOW, RING_BUFFER_LEN, PAD_SLOT_ID, QUERY_METADATA_IS_CUMULATIVE, NUM_COMPUTED_IS_POST_STEP, HAS_IDX_MAPPING, MATERIALIZE_PREFIXES, LIVE_COL_IS_ZERO)

Commit a completed step and prepare an optional prefix snapshot.

_reinterpret_u64_as_i64(value)

Preserve a uint64 pointer bit pattern in a torch.int64 tensor.

_reset_new_replayssm_slots_kernel(idx_mapping, src_cols, dst_cols, block_table_ptrs, tracker_ptrs, tracker_slot_strides, layer_offsets, num_layers, block_table_strides, PAD_SLOT_ID, HAS_IDX_MAPPING)

Reset the trackers of a fresh destination slot in this cache group.

Source and destination are logical block-table columns. Their slot lookups distinguish a missing group-local source from a continuation. A continuation needs nothing here: the align pre-copy, which runs first, copies the source page, trackers included.

_store_trackers(tracker_ptrs, tracker_slot_strides, first_layer, num_layers, slot, start, committed, mask)

Write a slot's trackers to every layer of a cache group.

_tracker_row(tracker_ptrs, tracker_slot_strides, layer, slot)

Address of a slot's (ring_start, num_committed) pair in a layer's page.

assign_replayssm_decode_planners(kv_cache_config, forward_context)

Pick, per cache group, the layer that plans each Triton decode step, and bind the stochastic-rounding seed slots of the FlashInfer ReplaySSM layers.

The ring trackers live in each layer's Mamba page (the last state), so block copies, the align pre-copy and KV cache accounting handle them like the rings.

mamba_state_copy_boundary(num_tokens_running_state, new_num_computed, block_size)

Return the aligned Mamba state-copy decision and destination.