zkonduit / ezkl

ezkl is an engine for doing inference for deep learning models and other computational graphs in a zk-snark (ZKML). Use it from Python, Javascript, or the command line.
https://docs.ezkl.xyz/
934 stars 135 forks source link

Error while working with Onnx files generated by Pyezkl #182

Closed hsaleemsupra closed 1 year ago

hsaleemsupra commented 1 year ago

I am following the tutorial in Pyezkl repo. I am able to generate the network.onnx and inputs file. However running the following command to generate the proof: RUST_LOG=debug cargo run --bin ezkl -- --tolerance 2 --scale 4 --bits 16 -K 17 mock -D ./input.json -M ./network.onnx results in error: dimensionality error when manipulating a tensor

Here is the complete stack trace for the error:

[*] [0s, ezkl_lib::commands] - loading data from ./input.json
[*] [0s, ezkl_lib::graph::model] - visibility: (inputs: private, params: private, outputs: public)
[*] [0s, ezkl_lib::graph::node] - ------ scaled op node input 0: 7 -> 21
[*] [0s, ezkl_lib::graph::node] - ------ scaled op node input 9: 7 -> 21
[*] [0s, ezkl_lib::graph::node] - ------ scaled const node 4: 7 -> 28
[*] [0s, ezkl_lib::pfsys] - public inputs lengths: [75, 12]
[*] [0s, ezkl_lib::pfsys] - loading params from "kzg.params"
[*] [0s, ezkl_lib::execute] - downsizing params to 17 logrows
[*] [0s, ezkl_lib::graph::model] - visibility: (inputs: private, params: private, outputs: public)
[*] [0s, ezkl_lib::graph::node] - ------ scaled op node input 0: 7 -> 21
[*] [0s, ezkl_lib::graph::node] - ------ scaled op node input 9: 7 -> 21
[*] [0s, ezkl_lib::graph::node] - ------ scaled const node 5: 7 -> 28
[*] [0s, ezkl_lib::graph] - total var len: 8470
[*] [0s, ezkl_lib::graph] - number of advices used: 3
[*] [0s, ezkl_lib::graph] - number of fixed used: 0
[*] [0s, ezkl_lib::graph] - number of instances used: 2
[*] [0s, ezkl_lib::graph::model] - configuring model
[W] [0s, ezkl_lib::circuit] - assiging lookup input
[*] [0s, ezkl_lib::graph::model] - model layout
[W] [0s, ezkl_lib::tensor::val] - using 'get_inner' in constraints can create soundness issues.
[E] [0s, ezkl_lib::graph::model] - dimensionality error when manipulating a tensor
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Synthesis', Desktop/git/ezkl/src/graph/mod.rs:131:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
alexander-camuto commented 1 year ago

Hey @hsaleemsupra many thanks for flagging this. Some of the recent performance improvements we rolled out didn't have N-dim matrix multiplication in mind, hence the issues you see in the tutorial.

I've rolled out N-dim matmul with our new arguments in #184. Tested it locally and it fixes your issue :) Let me know if that branch works for you as well.