Skip to content

Commit

Permalink
fix(frontend): use proper inputsets in key value database example
Browse files Browse the repository at this point in the history
  • Loading branch information
umut-sahin committed Aug 6, 2024
1 parent 941d78b commit a3cc2f1
Showing 1 changed file with 39 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,23 +550,32 @@
" # Initialize the state to all zeros\n",
" self._state = np.zeros(STATE_SHAPE, dtype=np.int64)\n",
"\n",
" ## Input sets for initialization of the circuits\n",
" # The input sets are used to initialize the circuits with the correct parameters\n",
" sample_state = np.array(\n",
" [\n",
" [i % 2] + encode_key(i).tolist() + encode_value(i).tolist()\n",
" for i in range(STATE_SHAPE[0])\n",
" ]\n",
" )\n",
"\n",
" # The input set for the query circuit\n",
" inputset_binary = [\n",
" insert_replace_inputset = [\n",
" (\n",
" np.zeros(STATE_SHAPE, dtype=np.int64), # state\n",
" np.ones(NUMBER_OF_KEY_CHUNKS, dtype=np.int64) * (2**CHUNK_SIZE - 1), # key\n",
" # state\n",
" sample_state,\n",
" # key\n",
" encode_key(i),\n",
" # value\n",
" encode_key(i),\n",
" )\n",
" for i in range(20)\n",
" ]\n",
" # The input set for the insert and replace circuits\n",
" inputset_ternary = [\n",
" query_inputset = [\n",
" (\n",
" np.zeros(STATE_SHAPE, dtype=np.int64), # state\n",
" np.ones(NUMBER_OF_KEY_CHUNKS, dtype=np.int64) * (2**CHUNK_SIZE - 1), # key\n",
" np.ones(NUMBER_OF_VALUE_CHUNKS, dtype=np.int64) * (2**CHUNK_SIZE - 1), # value\n",
" # state\n",
" sample_state,\n",
" # key\n",
" encode_key(i),\n",
" )\n",
" for i in range(20)\n",
" ]\n",
"\n",
" ## Circuit compilation\n",
Expand Down Expand Up @@ -599,23 +608,23 @@
"\n",
" print(\"Compiling insertion circuit...\")\n",
" start = time.time()\n",
" self._insert_circuit = insert_compiler.compile(inputset_ternary, configuration)\n",
" self._insert_circuit = insert_compiler.compile(insert_replace_inputset, configuration)\n",
" end = time.time()\n",
" print(f\"(took {end - start:.3f} seconds)\")\n",
"\n",
" print()\n",
"\n",
" print(\"Compiling replacement circuit...\")\n",
" start = time.time()\n",
" self._replace_circuit = replace_compiler.compile(inputset_ternary, configuration)\n",
" self._replace_circuit = replace_compiler.compile(insert_replace_inputset, configuration)\n",
" end = time.time()\n",
" print(f\"(took {end - start:.3f} seconds)\")\n",
"\n",
" print()\n",
"\n",
" print(\"Compiling query circuit...\")\n",
" start = time.time()\n",
" self._query_circuit = query_compiler.compile(inputset_binary, configuration)\n",
" self._query_circuit = query_compiler.compile(query_inputset, configuration)\n",
" end = time.time()\n",
" print(f\"(took {end - start:.3f} seconds)\")\n",
"\n",
Expand Down Expand Up @@ -1063,10 +1072,24 @@
"execution": {
"timeout": 10800
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit a3cc2f1

Please sign in to comment.