plan_chunk_len

Function plan_chunk_len 

Source
pub fn plan_chunk_len(
    offset: usize,
    total: usize,
    proposed: usize,
    block_size: Option<usize>,
    split: Option<usize>,
) -> usize
Expand description

2026-09-27: Length of the prefill chunk at offset of a total-token prompt, given the capped proposed length.

A last chunk (offset + proposed >= total) is returned unchanged. A non-last chunk ends at the last block_size boundary inside it (when that is past offset), then at split when it would still span it, and is finally rounded down to a multiple of 4 (the GDN WY4 rule for intermediate chunks). With chunk ends on block boundaries every later offset is block-aligned, so the rounding changes nothing when block_size is a multiple of 4.