Skip to content

Commit 1ee66aa

Browse files
committed
Concat all witness into single witness.bin per template
1 parent 7bbf739 commit 1ee66aa

File tree

1 file changed

+15
-15
lines changed
  • expander_compiler/src/zkcuda/proving_system/expander_local_deferred

1 file changed

+15
-15
lines changed

expander_compiler/src/zkcuda/proving_system/expander_local_deferred/api.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,21 @@ fn dump_circuits_for_gpu<F: gkr_engine::FieldEngine>(
280280
}
281281
}
282282

283-
// Write witness (input_vals) per instance per layer
284-
// Each instance's layer 0 input_vals = the actual witness
285-
// Format: raw M31x16 values as [u32; 16] per element
286-
for (pi, circuit) in circuits.iter().enumerate() {
287-
let mut wf = std::fs::File::create(format!("{}/witness_{}.bin", dir, pi)).unwrap();
288-
// Only dump layer 0 input_vals (other layers computed by evaluate())
289-
let vals = &circuit.layers[0].input_vals;
290-
// SimdCircuitField = M31x16, each is [M31; 16] = [u32; 16] = 64 bytes
291-
let bytes: &[u8] = unsafe {
292-
std::slice::from_raw_parts(
293-
vals.as_ptr() as *const u8,
294-
vals.len() * std::mem::size_of_val(&vals[0]),
295-
)
296-
};
297-
wf.write_all(bytes).unwrap();
283+
// Write ALL witness data to ONE file: witness.bin
284+
// Layout: [instance_0_layer0_input_vals | instance_1_layer0_input_vals | ...]
285+
// Each instance = layer0.input_vals as raw M31x16 bytes (contiguous)
286+
{
287+
let mut wf = std::fs::File::create(format!("{}/witness.bin", dir)).unwrap();
288+
for circuit in circuits.iter() {
289+
let vals = &circuit.layers[0].input_vals;
290+
let bytes: &[u8] = unsafe {
291+
std::slice::from_raw_parts(
292+
vals.as_ptr() as *const u8,
293+
vals.len() * std::mem::size_of_val(&vals[0]),
294+
)
295+
};
296+
wf.write_all(bytes).unwrap();
297+
}
298298
}
299299

300300
eprintln!(" [dump] tmpl[{}] N={} layers={} → {}/", ti, pc, num_layers, dir);

0 commit comments

Comments
 (0)