Skip to content

test: prompt_cache_e2e dense multi-turn assertion under-allows for block flooring with thinking models #1156

Closed

Description

@inureyes

Problem / Background

prompt_cache_e2e::multi_turn_chat_reports_cached_tokens_and_lowers_prefill_latency (an #[ignore]d test run manually with local qwen3-0.6b-4bit weights) fails deterministically at turn 3: cached_tokens is 64 against a previous prompt length of 73, but the assertion at tests/prompt_cache_e2e.rs:359 allows only 4 tokens of slack.

Attribution is settled by a two-arm measurement: the pre-epic baseline 9c154ff3 fails with token-for-token identical values (cached 0/48/64/96/112 across 5 turns), so this is pre-existing and not a regression from epic #1148. Reproduced 2026-08-15 on main a206f089 and on the baseline with identical numbers; the full turn table is in epic #1148's summary comment.

Mechanism. Dense trie adoption is block-floored to multiples of 16 (all observed cached values are multiples of 16). With max_tokens=16, the qwen3 thinking model produces empty assistant content (all 16 tokens go to the unterminated think block), so the history re-render diverges right at the previous prompt boundary, and flooring can cost up to 15 tokens, which exceeds the 4-token slack.

Proposed Solution

One of:

  • Raise the slack to one block minus 1 (15 tokens).
  • Derive the slack from the paged block size constant instead of hardcoding 4, so the assertion stays correct if the block size changes.
  • Make the fixture avoid the empty-content case: use a non-thinking model, or a larger max_tokens so assistant content is non-empty and the re-rendered history does not diverge at the previous prompt boundary.

The other assertions in the test (cached > 0, monotonic growth) are sound and should stay strict.

Acceptance Criteria

  • The multi-turn test passes deterministically with the local qwen3-0.6b-4bit fixture across all 5 turns
  • The slack in the under-allowance assertion is either derived from the block size constant or documented with the block-flooring rationale
  • The strict assertions (cached_tokens > 0 from turn 2, monotonic growth) remain unchanged

Technical Considerations

Refs epic #1148 (integration verification that surfaced this, full turn table in its summary comment). The deterministic token-identical failure on both arms rules out cache-policy changes from the epic as a cause.

Activity

  1. added
    type:bugBug fixes, error corrections, or issue resolutions
    area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)
    and removed on Aug 14, 2026
  2. added a commit that references this issue on Aug 14, 2026
    20c0c1b
  3. self-assigned this
    on Aug 31, 2026
  4. added a commit that references this issue on Oct 27, 2026
    2aedd59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:lowLow prioritystatus:doneCompletedtype:bugBug fixes, error corrections, or issue resolutions

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions