From 228552f1a3e80d4b8ee7b3dd5eaeaf3c58d56804 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 10 Nov 2026 00:25:29 +0100 Subject: [PATCH] Verify GPU plan: raise_after_staging back under complexity 10 (copy-kernel retain extracted) Co-Authored-By: Claude Sonnet 5.5 --- .../src/original_verify_gpu_plan/plan_phases.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs b/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs index f870b7c3..a439af2d 100644 --- a/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs +++ b/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs @@ -220,9 +220,7 @@ impl<'ctx> schedule::OriginalVerifyCpuSink<'_, 'ctx> { ) -> Result<()> { let flag_b = self.flag_b_host_address()?; if flag_b_route(kernel, pcie.is_some()) == FlagBRoute::AtOnce { - if kernel && !plan.pcie.is_empty() { - self.bank.retain_pcie_source(Rc::clone(pcie.as_ref().ok_or(Error::InvalidQwenShape)?.bank))?; - } + self.retain_for_copy_kernel(plan, pcie.as_ref(), kernel)?; return self.raise_flag_b(); } let source = pcie.ok_or(Error::InvalidQwenShape)?; @@ -236,6 +234,19 @@ impl<'ctx> schedule::OriginalVerifyCpuSink<'_, 'ctx> { self.raise_after_copies(copy, flag_b, write) } + /// The copy kernel reads the bank's registered bytes inside the graph: keep the bank retained until the window's fence. + fn retain_for_copy_kernel( + &mut self, + plan: &OriginalVerifyGpuPlan, + pcie: Option<&OriginalVerifyPcieSource<'_, 'ctx>>, + kernel: bool, + ) -> Result<()> { + if !kernel || plan.pcie.is_empty() { + return Ok(()); + } + self.bank.retain_pcie_source(Rc::clone(pcie.ok_or(Error::InvalidQwenShape)?.bank)) + } + /// Queues the flag B write behind the staging copies: a stream write when supported, else a host callback. fn raise_after_copies(&self, copy: &mut OriginalGpuStream<'ctx>, flag_b: usize, write: bool) -> Result<()> { if write {