serve: the deferred adaptive planning is opt-in (LELEKA_SERVE_ADAPT_DEFER=on); default is the earlier order
Measured on the 5090 (seed off, upstream profile, frozen 245k corpus, turns 1-4, per round, spans of the same runs): deferral moved round.adapt 0.108 ms into the draft's shadow (adapt_deferred 0.085-0.092) but round.apply_pending rose from 0.157/0.169 to 0.255-0.278 because the swap copies start later and are the critical path: apply+adapt 0.251 (no defer) against 0.340-0.370 (defer). A net loss of about 0.09-0.12 ms per round, so it is no longer the default. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
b5d4a0db74
commit
9b03de2be9
@@ -97,7 +97,7 @@ pub(in crate::qwen_forward) struct OriginalServeHost<'a, 'ctx> {
|
||||
window_origin: Option<TargetStepOrigin>,
|
||||
/// A draft launched behind the enqueued commit, completed after the publication (`launch_draft`).
|
||||
launched: Option<OriginalLaunchedMtpDraft>,
|
||||
/// 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<u64>,
|
||||
}
|
||||
@@ -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<bool> = 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);
|
||||
|
||||
Reference in New Issue
Block a user