Ssd Varlen Metadata#

void trt_edgellm::mamba::fillUniformValidLens(
int32_t *d_valid_lens,
int32_t batch,
int32_t seq_len,
cudaStream_t stream
)#

Fill d_valid_lens[0..batch) with uniform seq_len value. Used by the runner when caller’s context_lengths is null (uniform batch); the kernel’s padded_mode end-of-seq clamp still requires a valid_lens tensor.

void trt_edgellm::mamba::buildSSDPackedVarlenMetadata(
int32_t *d_seq_idx,
int32_t *d_chunk_indices,
int32_t *d_chunk_offsets,
int32_t *d_seq_chunk_cumsum,
int32_t const *d_cu_seqlens,
int32_t num_seqs,
int32_t total_tokens,
int32_t chunk_size,
int32_t total_slots,
cudaStream_t stream
)#

Packed counterpart of buildSSDVarlenMetadata: sequence b owns tokens [d_cu_seqlens[b], d_cu_seqlens[b + 1]) of one flat axis of total_tokens tokens. total_slots must be at least ssdPackedLogicalChunkUpperBound(num_seqs, total_tokens, chunk_size); offsets are clamped to the token axis and writes stay within total_slots. Single-block kernel: num_seqs <= 1024.

void trt_edgellm::mamba::fillValidLensFromCuSeqlens(
int32_t *d_valid_lens,
int32_t const *d_cu_seqlens,
int32_t num_seqs,
int32_t total_tokens,
cudaStream_t stream
)#

Fill d_valid_lens[b] with the length of packed sequence b, clamped to the token axis like the chunk metadata.

void trt_edgellm::mamba::buildSSDVarlenMetadata(
int32_t *d_seq_idx,
int32_t *d_chunk_indices,
int32_t *d_chunk_offsets,
int32_t *d_seq_chunk_cumsum,
int32_t const *d_context_lengths,
int32_t batch,
int32_t seq_len,
int32_t chunk_size,
cudaStream_t stream
)#

Build varlen metadata fully on-device (CUDA-graph-compatible – no host sync). The logical chunk upper bound is batch * (ceil(seq_len / chunk_size) + maybe_unaligned_chunk); trailing slack in chunk_indices is filled with sentinel -1 so the kernel’s chunk_indices[physical_chunk+1] lookup is safe up to the upper bound.