Skip to content

Commit 1d3b474

Browse files
committed
fixes
1 parent b13d46b commit 1d3b474

File tree

21 files changed

+173
-3735934
lines changed

21 files changed

+173
-3735934
lines changed

circuit_defs/prover_examples/src/gpu.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// use std::{alloc::Global, collections::HashMap, sync::Arc};
2-
//
2+
//
33
// use cs::utils::split_timestamp;
44
// pub use gpu_prover::allocator::host::ConcurrentStaticHostAllocator;
55
// use gpu_prover::circuit_type::{CircuitType, DelegationCircuitType};
@@ -26,7 +26,7 @@
2626
// merkle_trees::{DefaultTreeConstructor, MerkleTreeConstructor},
2727
// risc_v_simulator::cycle::{IMStandardIsaConfig, IWithoutByteAccessIsaConfigWithDelegation},
2828
// };
29-
//
29+
//
3030
// use prover::{
3131
// definitions::OPTIMAL_FOLDING_PROPERTIES,
3232
// prover_stages::Proof,
@@ -37,30 +37,30 @@
3737
// worker::Worker,
3838
// VectorMemoryImplWithRom,
3939
// };
40-
//
40+
//
4141
// use setups::{DelegationCircuitPrecomputations, MainCircuitPrecomputations};
4242
// use trace_and_split::{
4343
// fs_transform_for_memory_and_delegation_arguments, run_and_split_for_gpu, FinalRegisterValue,
4444
// };
45-
//
45+
//
4646
// use crate::{NUM_QUERIES, POW_BITS};
47-
//
47+
//
4848
// pub fn initialize_host_allocator_if_needed() {
4949
// if !ProverContext::is_global_host_allocator_initialized() {
5050
// // allocate 8 x 1 GB ((1 << 8) << 22) of pinned host memory with 4 MB (1 << 22) chunking
5151
// ProverContext::initialize_global_host_allocator(8, 1 << 8, 22).unwrap();
5252
// }
5353
// }
54-
//
54+
//
5555
// pub fn create_default_prover_context<'a>() -> ProverContext {
5656
// initialize_host_allocator_if_needed();
5757
// let mut prover_context_config = ProverContextConfig::default();
5858
// prover_context_config.allocation_block_log_size = 22;
59-
//
59+
//
6060
// let prover_context = ProverContext::new(&prover_context_config).unwrap();
6161
// prover_context
6262
// }
63-
//
63+
//
6464
// pub fn gpu_prove_image_execution_for_machine_with_gpu_tracers<
6565
// ND: NonDeterminismCSRSource<VectorMemoryImplWithRom>,
6666
// C: MachineConfig,
@@ -87,7 +87,7 @@
8787
// .lde_factor;
8888
// assert_eq!(cycles_per_circuit + 1, trace_len);
8989
// let max_cycles_to_run = num_instances_upper_bound * cycles_per_circuit;
90-
//
90+
//
9191
// // Guess circuit type based on the machine type.
9292
// let circuit_type = match std::any::TypeId::of::<C>() {
9393
// id if id == std::any::TypeId::of::<IMStandardIsaConfig>() => {
@@ -104,7 +104,7 @@
104104
// panic!("Unsupported machine type");
105105
// }
106106
// };
107-
//
107+
//
108108
// let (
109109
// main_circuits_witness,
110110
// inits_and_teardowns,
@@ -117,9 +117,9 @@
117117
// non_determinism,
118118
// worker,
119119
// );
120-
//
120+
//
121121
// let (num_paddings, inits_and_teardowns) = inits_and_teardowns;
122-
//
122+
//
123123
// let mut memory_trees = vec![];
124124
// // commit memory trees
125125
// for (circuit_sequence, witness_chunk) in main_circuits_witness.iter().enumerate() {
@@ -138,7 +138,7 @@
138138
// inits_and_teardowns,
139139
// trace,
140140
// };
141-
//
141+
//
142142
// let mut transfer = TracingDataTransfer::new(circuit_type, data, prover_context)?;
143143
// transfer.schedule_transfer(prover_context)?;
144144
// let job = commit_memory(
@@ -152,16 +152,16 @@
152152
// )?;
153153
// job.finish()?
154154
// };
155-
//
155+
//
156156
// memory_trees.push(gpu_caps);
157157
// }
158-
//
158+
//
159159
// // same for delegation circuits
160160
// let mut delegation_memory_trees = vec![];
161-
//
161+
//
162162
// let mut delegation_types: Vec<_> = delegation_circuits_witness.keys().copied().collect();
163163
// delegation_types.sort();
164-
//
164+
//
165165
// for delegation_type in delegation_types.iter().cloned() {
166166
// let els = &delegation_circuits_witness[&delegation_type];
167167
// let delegation_type_id = delegation_type as u32;
@@ -198,23 +198,23 @@
198198
// };
199199
// per_tree_set.push(gpu_caps);
200200
// }
201-
//
201+
//
202202
// delegation_memory_trees.push((delegation_type_id, per_tree_set));
203203
// }
204-
//
204+
//
205205
// let setup_caps = DefaultTreeConstructor::dump_caps(&risc_v_circuit_precomputations.setup.trees);
206-
//
206+
//
207207
// // commit memory challenges
208208
// let memory_challenges_seed = fs_transform_for_memory_and_delegation_arguments(
209209
// &setup_caps,
210210
// &final_register_values,
211211
// &memory_trees,
212212
// &delegation_memory_trees,
213213
// );
214-
//
214+
//
215215
// let external_challenges =
216216
// ExternalChallenges::draw_from_transcript_seed(memory_challenges_seed, true);
217-
//
217+
//
218218
// let input = final_register_values
219219
// .iter()
220220
// .map(|el| (el.value, split_timestamp(el.last_access_timestamp)))
@@ -229,18 +229,18 @@
229229
// external_challenges.memory_argument.memory_argument_gamma,
230230
// );
231231
// let mut delegation_argument_sum = Mersenne31Quartic::ZERO;
232-
//
232+
//
233233
// let mut aux_memory_trees = vec![];
234-
//
234+
//
235235
// println!(
236236
// "Producing proofs for main RISC-V circuit, {} proofs in total",
237237
// main_circuits_witness.len()
238238
// );
239-
//
239+
//
240240
// let total_proving_start = std::time::Instant::now();
241-
//
241+
//
242242
// let main_circuits_witness_len = main_circuits_witness.len();
243-
//
243+
//
244244
// let mut gpu_setup_main = {
245245
// let setup_row_major = &risc_v_circuit_precomputations.setup.ldes[0].trace;
246246
// let mut setup_evaluations = Vec::with_capacity_in(
@@ -279,7 +279,7 @@
279279
// setup.schedule_transfer(setup_evaluations, prover_context)?;
280280
// setup
281281
// };
282-
//
282+
//
283283
// // now prove one by one
284284
// let main_compiled_circuit = Arc::new(risc_v_circuit_precomputations.compiled_circuit.clone());
285285
// let mut main_proofs = vec![];
@@ -327,17 +327,17 @@
327327
// )?;
328328
// job.finish()?.0.into_regular().unwrap()
329329
// };
330-
//
330+
//
331331
// memory_grand_product.mul_assign(&gpu_proof.memory_grand_product_accumulator);
332332
// delegation_argument_sum.add_assign(&gpu_proof.delegation_argument_accumulator.unwrap());
333-
//
333+
//
334334
// aux_memory_trees.push(gpu_proof.memory_tree_caps.clone());
335-
//
335+
//
336336
// main_proofs.push(gpu_proof);
337337
// }
338-
//
338+
//
339339
// drop(gpu_setup_main);
340-
//
340+
//
341341
// if main_circuits_witness_len > 0 {
342342
// println!(
343343
// "=== Total proving time: {:?} for {} circuits - avg: {:?}",
@@ -346,7 +346,7 @@
346346
// total_proving_start.elapsed() / main_circuits_witness_len.try_into().unwrap()
347347
// )
348348
// }
349-
//
349+
//
350350
// // all the same for delegation circuit
351351
// let mut aux_delegation_memory_trees = vec![];
352352
// let mut delegation_proofs = vec![];
@@ -361,7 +361,7 @@
361361
// delegation_type_id,
362362
// els.len()
363363
// );
364-
//
364+
//
365365
// let idx = delegation_circuits_precomputations
366366
// .iter()
367367
// .position(|el| el.0 == delegation_type_id)
@@ -408,13 +408,13 @@
408408
// setup.schedule_transfer(setup_evaluations, prover_context)?;
409409
// setup
410410
// };
411-
//
411+
//
412412
// let mut per_tree_set = vec![];
413-
//
413+
//
414414
// let mut per_delegation_type_proofs = vec![];
415415
// for (_circuit_idx, el) in els.iter().enumerate() {
416416
// delegation_proofs_count += 1;
417-
//
417+
//
418418
// // and prove
419419
// let gpu_proof = {
420420
// let trace = el.clone();
@@ -444,21 +444,21 @@
444444
// )?;
445445
// job.finish()?.0.into_regular().unwrap()
446446
// };
447-
//
447+
//
448448
// memory_grand_product.mul_assign(&gpu_proof.memory_grand_product_accumulator);
449449
// delegation_argument_sum.sub_assign(&gpu_proof.delegation_argument_accumulator.unwrap());
450-
//
450+
//
451451
// per_tree_set.push(gpu_proof.memory_tree_caps.clone());
452-
//
452+
//
453453
// per_delegation_type_proofs.push(gpu_proof);
454454
// }
455-
//
455+
//
456456
// aux_delegation_memory_trees.push((delegation_type_id, per_tree_set));
457457
// delegation_proofs.push((delegation_type_id, per_delegation_type_proofs));
458-
//
458+
//
459459
// drop(gpu_setup_delegation);
460460
// }
461-
//
461+
//
462462
// if delegation_proofs_count > 0 {
463463
// println!(
464464
// "=== Total delegation proving time: {:?} for {} circuits - avg: {:?}",
@@ -467,25 +467,25 @@
467467
// delegation_proving_start.elapsed() / delegation_proofs_count
468468
// )
469469
// }
470-
//
470+
//
471471
// assert_eq!(memory_grand_product, Mersenne31Quartic::ONE);
472472
// assert_eq!(delegation_argument_sum, Mersenne31Quartic::ZERO);
473-
//
473+
//
474474
// let setup_caps = DefaultTreeConstructor::dump_caps(&risc_v_circuit_precomputations.setup.trees);
475-
//
475+
//
476476
// // compare challenge
477477
// let aux_memory_challenges_seed = fs_transform_for_memory_and_delegation_arguments(
478478
// &setup_caps,
479479
// &final_register_values,
480480
// &aux_memory_trees,
481481
// &aux_delegation_memory_trees,
482482
// );
483-
//
483+
//
484484
// assert_eq!(aux_memory_challenges_seed, memory_challenges_seed);
485-
//
485+
//
486486
// Ok((main_proofs, delegation_proofs, final_register_values))
487487
// }
488-
//
488+
//
489489
// pub fn trace_execution_for_gpu<
490490
// ND: NonDeterminismCSRSource<VectorMemoryImplWithRom>,
491491
// C: MachineConfig,
@@ -507,9 +507,9 @@
507507
// ) {
508508
// let cycles_per_circuit = domain_size - 1;
509509
// let max_cycles_to_run = num_instances_upper_bound * cycles_per_circuit;
510-
//
510+
//
511511
// let delegation_factories = setups::delegation_factories_for_machine::<C, A>();
512-
//
512+
//
513513
// let (
514514
// final_pc,
515515
// main_circuits_witness,
@@ -524,7 +524,7 @@
524524
// delegation_factories,
525525
// worker,
526526
// );
527-
//
527+
//
528528
// println!(
529529
// "Program finished execution with final pc = 0x{:08x} and final register state\n{}",
530530
// final_pc,
@@ -535,21 +535,21 @@
535535
// .collect::<Vec<_>>()
536536
// .join(", ")
537537
// );
538-
//
538+
//
539539
// // we just need to chunk inits/teardowns
540-
//
540+
//
541541
// let init_and_teardown_chunks = chunk_lazy_init_and_teardown(
542542
// main_circuits_witness.len(),
543543
// cycles_per_circuit,
544544
// &init_and_teardown_chunks,
545545
// worker,
546546
// );
547-
//
547+
//
548548
// let main_circuits_witness = main_circuits_witness
549549
// .into_iter()
550550
// .map(|c| c.into())
551551
// .collect_vec();
552-
//
552+
//
553553
// let init_and_teardown_chunks = (
554554
// init_and_teardown_chunks.0,
555555
// init_and_teardown_chunks
@@ -558,12 +558,12 @@
558558
// .map(|c| c.into())
559559
// .collect_vec(),
560560
// );
561-
//
561+
//
562562
// let delegation_circuits_witness = delegation_circuits_witness
563563
// .into_iter()
564564
// .map(|(k, v)| (k.into(), v.into_iter().map(|c| c.into()).collect_vec()))
565565
// .collect();
566-
//
566+
//
567567
// (
568568
// main_circuits_witness,
569569
// init_and_teardown_chunks,

circuit_defs/unrolled_circuits/unified_reduced_machine/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ pub fn get_circuit_for_rom_bound<const ROM_ADDRESS_SPACE_SECOND_WORD_BITS: usize
5454
&|cs| {
5555
reduced_machine_table_addition_fn(cs);
5656

57-
let extra_tables =
58-
create_reduced_machine_special_tables::<_, ROM_ADDRESS_SPACE_SECOND_WORD_BITS>(
59-
bytecode,
60-
ALLOWED_DELEGATION_CSRS,
61-
);
57+
let extra_tables = create_reduced_machine_special_tables::<
58+
_,
59+
ROM_ADDRESS_SPACE_SECOND_WORD_BITS,
60+
>(bytecode, ALLOWED_DELEGATION_CSRS);
6261
for (table_type, table) in extra_tables {
6362
cs.add_table_with_content(table_type, table);
6463
}
@@ -94,11 +93,10 @@ pub fn dump_ssa_form_for_rom_bound<const ROM_ADDRESS_SPACE_SECOND_WORD_BITS: usi
9493
&|cs| {
9594
reduced_machine_table_addition_fn(cs);
9695

97-
let extra_tables =
98-
create_reduced_machine_special_tables::<_, ROM_ADDRESS_SPACE_SECOND_WORD_BITS>(
99-
bytecode,
100-
ALLOWED_DELEGATION_CSRS,
101-
);
96+
let extra_tables = create_reduced_machine_special_tables::<
97+
_,
98+
ROM_ADDRESS_SPACE_SECOND_WORD_BITS,
99+
>(bytecode, ALLOWED_DELEGATION_CSRS);
102100
for (table_type, table) in extra_tables {
103101
cs.add_table_with_content(table_type, table);
104102
}

0 commit comments

Comments
 (0)