Documentation
¶
Overview ¶
internal/cacheunit/align.go Package cacheunit computes prefix padding so the Static Prefix ends on a DeepSeek cache-unit boundary. V4 reuses a stored prefix only up to its last COMPLETE compression block; the tail incomplete block is always recomputed (DeepSeek-V4 report §3.5.2). Padding the prefix to a unit multiple maximizes the reusable, fully-persisted portion. unit must be measured empirically with bench/cmd/cacheprobe before enabling padding; unit<=0 means "unknown -> none".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignPadding ¶
AlignPadding returns the token count to append to a prefix of prefixTokens so its length is a multiple of unit. Returns 0 when unit<=0 or already aligned.
func PadText ¶
PadText returns deterministic filler to append to a prefix of prefixTokens so the total token count is a multiple of unit, as measured by count. Identical for a given (prefixTokens, unit) -> the frozen prefix stays byte-stable. count MUST be the same tokenizer used to fingerprint the prefix. "" when none.
DEPRECATED: use PadTextConcat instead. PadText assumes count(prefix)+count(pad)==count(prefix+pad), which is false for real tokenizers that merge tokens at the concatenation boundary. It is retained only for existing test compatibility.
func PadTextConcat ¶ added in v0.4.1
PadTextConcat returns deterministic filler to append to prefix so the combined token count (count(prefix + padding)) is a multiple of unit. Unlike PadText, it measures the concatenated result, so it is correct even when the tokenizer merges tokens at the concatenation boundary. Identical for a given (prefix, unit) -> the frozen prefix stays byte-stable. "" when unit <= 0 or the prefix is already aligned.
Types ¶
This section is empty.