Skip to content

Commit 918985c

Browse files
authored
feat(provers): Add optional cycle tracking to proving report (#358)
1 parent cb84829 commit 918985c

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

crates/prover/airbender/src/prover.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ impl zkVMProver for AirbenderProver {
147147
.map_err(|err| Error::ExecutePanic(panic_msg(err)))??;
148148

149149
let start = Instant::now();
150-
let (proof, receipt) = match gpu_prover.prove(&input_words)? {
150+
let (proof, receipt, cycles) = match gpu_prover.prove(&input_words)? {
151151
ProveResult {
152152
proof: Proof::Real(proof),
153153
receipt,
154-
..
154+
cycles,
155155
} if proof.level() == airbender_host::ProverLevel::RecursionUnified => {
156-
(proof.into_inner(), receipt)
156+
(proof.into_inner(), receipt, cycles)
157157
}
158158
_ => Err(Error::Sdk(airbender_host::HostError::Prover(
159159
"Expected Proof::Real in ProverLevel::RecursionUnified".to_string(),
@@ -164,7 +164,10 @@ impl zkVMProver for AirbenderProver {
164164
Ok((
165165
words_to_le_bytes(receipt.output).into(),
166166
AirbenderProof(proof),
167-
ProgramProvingReport::new(proving_time),
167+
ProgramProvingReport {
168+
proving_time,
169+
total_num_cycles: Some(cycles),
170+
},
168171
))
169172
}
170173
}

crates/prover/core/src/report.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ impl ProgramExecutionReport {
3030

3131
/// ProgramProvingReport produces information about proving a particular
3232
/// program's instance.
33+
///
34+
/// Note: Execution is fused into the proving pipeline.
35+
/// To get separate execution metrics, call `execute()` before `prove()`.
3336
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3437
pub struct ProgramProvingReport {
3538
pub proving_time: Duration,
39+
pub total_num_cycles: Option<u64>,
3640
}
3741
impl ProgramProvingReport {
3842
pub fn new(proving_time: Duration) -> Self {
39-
Self { proving_time }
43+
Self {
44+
proving_time,
45+
total_num_cycles: None,
46+
}
4047
}
4148
}

crates/prover/risc0/src/prover.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ impl zkVMProver for Risc0Prover {
163163
Ok((
164164
public_values,
165165
proof,
166-
ProgramProvingReport::new(proving_time),
166+
ProgramProvingReport {
167+
proving_time,
168+
total_num_cycles: Some(prove_info.stats.total_cycles),
169+
},
167170
))
168171
}
169172
}

0 commit comments

Comments
 (0)