diff --git a/crates/leleka-runtime/src/qwen_forward/original_serve_host.rs b/crates/leleka-runtime/src/qwen_forward/original_serve_host.rs index ebf2320a..30c9430b 100644 --- a/crates/leleka-runtime/src/qwen_forward/original_serve_host.rs +++ b/crates/leleka-runtime/src/qwen_forward/original_serve_host.rs @@ -97,7 +97,7 @@ pub(in crate::qwen_forward) struct OriginalServeHost<'a, 'ctx> { window_origin: Option, /// A draft launched behind the enqueued commit, completed after the publication (`launch_draft`). launched: Option, - /// The round whose adaptive swaps are still to be planned and queued (`LELEKA_SERVE_ADAPT_DEFER`, default on): the host does that + /// The round whose adaptive swaps are still to be planned and queued (`LELEKA_SERVE_ADAPT_DEFER=on`, default off): the host does that /// work while the GPU runs the draft instead of before the commit and the draft are enqueued. deferred_adaptation: Option, } @@ -247,10 +247,12 @@ impl<'a, 'ctx> OriginalServeHost<'a, 'ctx> { } } -/// `LELEKA_SERVE_ADAPT_DEFER=off`: plan and queue the adaptive swaps before the commit (the earlier order; the A/B control). +/// `LELEKA_SERVE_ADAPT_DEFER=on`: plan and queue the adaptive swaps after the draft is launched instead of before the commit. OFF by default: measured on the +/// 5090 (seed off, frozen 245k session, turns 1-4, per round) it moved 0.09 ms of host work out of the commit path but the swap copies then start later and the +/// next round's `apply_pending` waits 0.10 ms longer (0.17 -> 0.26 ms), a net loss of about 0.09 ms (docs/experiments/decode-tail-5090.md). fn adapt_defer() -> bool { static ON: std::sync::OnceLock = std::sync::OnceLock::new(); - *ON.get_or_init(|| !std::env::var("LELEKA_SERVE_ADAPT_DEFER").is_ok_and(|v| v == "off" || v == "0")) + *ON.get_or_init(|| std::env::var("LELEKA_SERVE_ADAPT_DEFER").is_ok_and(|v| v == "on" || v == "1")) } impl<'a, 'ctx> OriginalServeHost<'a, 'ctx> { @@ -456,7 +458,7 @@ impl<'a, 'ctx> NativeServeHost<'ctx> for OriginalServeHost<'a, 'ctx> { // run on the tier's own stream beside the commit and the draft (no work for the all-CPU tier). // The planning and the queueing are host work (0.6 ms on an adaptation round) that sat between the window and the commit/draft // launch; with the deferral they run once the draft is launched (`run_deferred_adaptation`) or, at the latest, at the join, - // always before the next round's `apply_pending`. LELEKA_SERVE_ADAPT_DEFER=off runs them here as before. + // always before the next round's `apply_pending`. Opt-in (LELEKA_SERVE_ADAPT_DEFER=on); by default they run here as before. if adapt_defer() { if self.deferred_adaptation.is_some() { return Err(Error::IdentityMismatch);