Skip to content

vllm.v1.worker.gpu.sample.trace_replay

Classes:

Functions:

TraceReplayState

Per-request state for inference trace-replay.

When a request carries SamplingParams.trace_decode_token_ids, the sampler overwrites the sampled token at each decode step with the predetermined trace token, while real logprobs and ranks are still computed from the unmodified logit distribution. The replay step for a request is derived entirely from GPU state (total_len - prompt_len), so no CPU synchronization or async placeholder handling is needed.

apply_trace_tokens(sampled, idx_mapping, trace_token_ids, trace_len, total_len, prompt_len)

Overwrite sampled in place with trace tokens for the current step.

apply_trace_tokens_to_verified(sampled, num_sampled, draft_sampled, cu_num_logits, idx_mapping, trace_token_ids, trace_len, total_len, prompt_len)

Replace verified tokens with the trace, accepting each draft only if it equals the trace token at its position.