Skip to main content

t4a_cubecl_std/throughput/runners/
verify.rs

1use cubecl_common::profile::Duration;
2use cubecl_runtime::{client::Client, server::Handle, throughput::ThroughputError};
3
4/// Runs one pass and confirms it wrote `written`, before any pass is timed.
5///
6/// A launch that fails leaves its failure on the buffers it never wrote, and
7/// `sync` answers `Ok` regardless. A sample has no way to say so, and would
8/// time the launch overhead and report it as the probe's rate.
9///
10/// # Errors
11///
12/// [`ThroughputError::Launch`] when the pass did not run. The cause is logged
13/// by the device where it happened.
14pub fn verify(
15    client: &Client,
16    sample: impl Fn(usize) -> Duration,
17    written: &Handle,
18) -> Result<(), ThroughputError> {
19    sample(1);
20
21    cubecl_core::future::block_on(client.sync_buffers([written]))
22        .map_err(|_| ThroughputError::Launch)
23}