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 {