fix(qwen4exp): validate prefix snapshot budget

GA
14h ago
+284-27

Summary

Fixes #894, where Qwen4Exp prefix caching could silently become ineffective under concurrent workloads because the available snapshot budget was insufficient to hold a viable checkpoint.

Changes

  • Add a minimum viable snapshot allowance to qwen4exp_fit_chunk().
  • Calculate the minimum checkpoint size dynamically using qwen4exp_snapshot_bytes(), accounting for restore-point spacing and context length.
  • Reject snapshot reservations that cannot accommodate a complete checkpoint, allowing the remaining memory to be used for prefill chunk sizing.
  • Clamp automatic and explicitly configured concurrent prefix-cache budgets against the backend snapshot allowance.
  • Disable concurrent prefix caching when the engine does not support prefix storage or the effective snapshot budget is zero.
  • Preserve single-sequence prefix-cache behavior.
  • Add unit tests covering snapshot budget boundaries, concurrent budget clamping, and cache disabling.

Testing

  • Added unit tests in test_qwen4exp_chunk.cpp and test_server_unit.cpp.
  • git diff --check passes.
  • Native C++ compilation and unit tests were not run locally because the required C++ toolchain is unavailable in the development environment.

CI validation is needed for native compilation and test execution.