Skip to content

Commit

Permalink
*delete ezkl python proving cell for random forests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-crypto committed Jan 19, 2024
1 parent 1b2b5e9 commit 7af3b6a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 76 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export OS=linux
Finally run this cargo nextest test command to get the benchmarks:

```bash
source .env/bin/activate; cargo nextest run benchmarking_tests::tests::run_benchmarks_ --test-threads 1
source .env/bin/activate; cargo nextest run benchmarking_tests::tests::run_benchmarks_ --no-capture
```

The data will stored in a `benchmarks.json` file in the root directory.
Expand Down
75 changes: 0 additions & 75 deletions notebooks/random_forests/ezkl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -269,81 +269,6 @@
"assert os.path.isfile(settings_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47d01286",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import json\n",
"import time\n",
"import subprocess\n",
"\n",
"def get_memory_usage(pid):\n",
" \"\"\"Function to get memory usage of process by PID.\"\"\"\n",
" try:\n",
" # Execute Bash command to get memory usage\n",
" process = subprocess.Popen(['ps', '-o', 'rss=', '-p', str(pid)],\n",
" stdout=subprocess.PIPE,\n",
" stderr=subprocess.PIPE)\n",
" stdout, stderr = process.communicate()\n",
" # Convert output to int and return\n",
" return int(stdout)\n",
" except Exception as e:\n",
" print(f\"Error getting memory usage: {e}\")\n",
" return 0\n",
"\n",
"proof_path = os.path.join('test.pf')\n",
"# log time and memory it takes to generate proof\n",
"start = time.time()\n",
"pid = os.getpid()\n",
"initial_memory = get_memory_usage(pid)\n",
"\n",
"res = ezkl.prove(\n",
" witness_path,\n",
" compiled_model_path,\n",
" pk_path,\n",
" proof_path,\n",
" \"single\",\n",
")\n",
"\n",
"final_memory = get_memory_usage(pid)\n",
"end = time.time()\n",
"proving_time = end - start\n",
"memory_used = final_memory - initial_memory\n",
"\n",
"print(\"PROOF GENERATION TIME: \", proving_time)\n",
"print(\"MEMORY USAGE: \", memory_used, \"KB\")\n",
"\n",
"# define the path that stores the benchmarking results\n",
"benchmark_path = os.path.join('../../benchmarks.json')\n",
"\n",
"# assume benchmark file has already been created (run `bash benchmark_file.sh` to create it)\n",
"with open(benchmark_path, 'r') as f:\n",
" benchmark = json.load(f)\n",
"\n",
"proving_time =str(proving_time) + \"s\"\n",
"\n",
"memory_used = str(memory_used) + \"kb\"\n",
"\n",
"# Update the proving time in the loaded benchmark\n",
"benchmark['random_forests']['ezkl']['provingTime'].append(proving_time)\n",
"\n",
"# Update the memory usage in the loaded benchmark\n",
"benchmark['random_forests']['ezkl']['memoryUsage'].append(memory_used)\n",
"\n",
"\n",
"# Write the updated benchmark back to the file\n",
"with open(benchmark_path, 'w') as f:\n",
" json.dump(benchmark, f, indent=4)\n",
"\n",
"\n",
"print(res['instances'])\n",
"assert os.path.isfile(proof_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 7af3b6a

Please sign in to comment.