perf(qwen35): add opt-in F32 rollback checkpoints for single-GPU inference#515
perf(qwen35): add opt-in F32 rollback checkpoints for single-GPU inference#515Amidwestnoob wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 11 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
@dusterbloom can you review this |
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/src/common/chain_rollback_policy.h">
<violation number="1" location="server/src/common/chain_rollback_policy.h:61">
P3: `RollbackDiag::print` passes `out` directly to `std::fprintf` after only checking `policy.diagnostics`. If someone ever calls it with a null FILE* while diagnostics is enabled — say, after a failed `tmpfile()` or `fopen` — the result is UB. Since `diagnostics` already has a guard, adding `if (!out) return;` would be consistent and prevent that crash class.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| void print(const ChainRollbackPolicy & policy, std::FILE * out) const { | ||
| if (!policy.diagnostics) return; |
There was a problem hiding this comment.
P3: RollbackDiag::print passes out directly to std::fprintf after only checking policy.diagnostics. If someone ever calls it with a null FILE* while diagnostics is enabled — say, after a failed tmpfile() or fopen — the result is UB. Since diagnostics already has a guard, adding if (!out) return; would be consistent and prevent that crash class.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/src/common/chain_rollback_policy.h, line 61:
<comment>`RollbackDiag::print` passes `out` directly to `std::fprintf` after only checking `policy.diagnostics`. If someone ever calls it with a null FILE* while diagnostics is enabled — say, after a failed `tmpfile()` or `fopen` — the result is UB. Since `diagnostics` already has a guard, adding `if (!out) return;` would be consistent and prevent that crash class.</comment>
<file context>
@@ -35,4 +37,41 @@ inline ChainRollbackPolicy resolve_chain_rollback_policy() {
+ void record_failed_fallback() { failed_fallback++; }
+ void record_legacy_replay() { legacy_replay++; }
+
+ void print(const ChainRollbackPolicy & policy, std::FILE * out) const {
+ if (!policy.diagnostics) return;
+ std::fprintf(out,
</file context>
| void print(const ChainRollbackPolicy & policy, std::FILE * out) const { | |
| if (!policy.diagnostics) return; | |
| void print(const ChainRollbackPolicy & policy, std::FILE * out) const { | |
| if (!out || !policy.diagnostics) return; | |
| std::fprintf(out, |
Summary
Adds an experimental, default-off F32 checkpoint mode for single-chain speculative rollback on memory-constrained single-GPU Qwen deployments.
The existing behavior remains unchanged unless explicitly enabled:
DFLASH_SINGLE_CHAIN_CHECKPOINT_F32=1 DFLASH_FAST_ROLLBACK_THRESHOLD=1 # valid range: 1-5Optional diagnostics:
Without the F32 opt-in, checkpoints remain F16 and the rollback threshold remains 5.
Motivation
On a single RTX 3090 running Qwen3.6-27B Q4, replaying rejected speculative tokens can cost more than restoring a saved recurrent-state checkpoint. F32 checkpoints permit direct restoration and avoid the conversion/replay path for sufficiently deep rollbacks.
This is intentionally separate from the split/layer-sharded work in #506. It targets a different deployment: one 24 GiB GPU, with no layer split.
Implementation
Validation
Final standalone branch, based on current
main:check: 15/15 tests passedFresh A/B/A validation on the standalone build, six prompt families and three repetitions per arm:
Independent final verification rebuilt and tested the exact diagnostics-centralized candidate, then repeated the A/B/A measurement:
The broader development campaign previously found threshold 2 to be the best pooled policy, but this PR deliberately uses the 6.46% threshold-1 result from the drift-free standalone candidate as its directly reproducible point estimate. The independent rerun supports that figure while showing the honest run-to-run range above.
Limitations
Suggested test configuration