Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ repos:
radio_access_network_positioning_antennas|
benchmark_dynamical_localization|
benchmark_ghz|
advection_equation_2nd_place_submission|
advection_equation_winning_submission|
select_structures_BE|
quantum_walks_via_efficient_blockencoding|
stateprep_guassian_using_qsvt|
modular_exp_example
)\.ipynb$
additional_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ def run_statevector_simulation(
if show_circuit:
show(qprog)
if print_circuit_info:
circuit_metrics = get_transpiled_circuit_metrics(qprog)
print("Circuit Width:", qprog.data.width)
print("Circuit Depth:", qprog.transpiled_circuit.depth)
print("Gate Counts:", qprog.transpiled_circuit.count_ops)
print("Circuit Depth:", circuit_metrics.depth)
print("Gate Counts:", circuit_metrics.count_ops)

if filter_ancilla:
df = calculate_state_vector(qprog, filters={"ancilla": 0})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
"metadata": {},
"outputs": [],
"source": [
"qasm_string = str(qprog.transpiled_circuit.qasm)"
"qasm_string = export(qprog, TargetLanguage.QASM3, transpilation_config=True)"
]
},
{
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": 1,
"id": "4",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -365,7 +365,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "9",
"metadata": {},
"outputs": [
Expand All @@ -375,15 +375,15 @@
"text": [
"Checkerboard matrix:\n",
"\n",
"[[ 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45]\n",
" [-0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27]\n",
" [ 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45]\n",
" [-0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27]\n",
" [ 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45]\n",
" [-0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27]\n",
" [ 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45]\n",
" [-0.45 0.27 -0.45 0.27 -0.45 0.27 -0.45 0.27]]\n",
"Values (val_even, val_odd): [0.27, -0.45]\n"
"[[0.1 0.32 0.1 0.32 0.1 0.32 0.1 0.32]\n",
" [0.32 0.1 0.32 0.1 0.32 0.1 0.32 0.1 ]\n",
" [0.1 0.32 0.1 0.32 0.1 0.32 0.1 0.32]\n",
" [0.32 0.1 0.32 0.1 0.32 0.1 0.32 0.1 ]\n",
" [0.1 0.32 0.1 0.32 0.1 0.32 0.1 0.32]\n",
" [0.32 0.1 0.32 0.1 0.32 0.1 0.32 0.1 ]\n",
" [0.1 0.32 0.1 0.32 0.1 0.32 0.1 0.32]\n",
" [0.32 0.1 0.32 0.1 0.32 0.1 0.32 0.1 ]]\n",
"Values (val_even, val_odd): [0.1, 0.32]\n"
]
}
],
Expand Down Expand Up @@ -463,18 +463,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "11",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_338747/1591233878.py:72: ClassiqDeprecationWarning: Accessing 'quantum_program.transpiled_circuit.depth' is deprecated. Use 'classiq.get_transpiled_circuit_metrics(quantum_program)' instead.\n",
" circuit_depth = qprog.transpiled_circuit.depth\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand Down Expand Up @@ -556,7 +548,7 @@
"qprog = synthesize(qmod)\n",
"# show(qprog)\n",
"circuit_width = qprog.data.width\n",
"circuit_depth = qprog.transpiled_circuit.depth\n",
"circuit_depth = get_transpiled_circuit_metrics(qprog).depth\n",
"print(\"The circuit width is:\", circuit_width)\n",
"print(\"The circuit depth is:\", circuit_depth)"
]
Expand All @@ -571,25 +563,18 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "13",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Submitting state-vector job to simulator\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The reduced state vector for j when s=0, data=0 is:\n",
"[0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25]\n",
"[0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59]\n",
"Theoretical reduced state vector for j when l=0 and data=0 is:\n",
"[-0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25]\n"
"[0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59]\n"
]
}
],
Expand Down Expand Up @@ -683,7 +668,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "18",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -777,31 +762,16 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "19",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_338747/1456868348.py:57: ClassiqDeprecationWarning: Accessing 'quantum_program.transpiled_circuit.depth' is deprecated. Use 'classiq.get_transpiled_circuit_metrics(quantum_program)' instead.\n",
" circuit_depth = qprog.transpiled_circuit.depth\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Submitting state-vector job to simulator\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The circuit width is: 18\n",
"The circuit depth is: 293\n"
"The circuit depth is: 249\n"
]
},
{
Expand Down Expand Up @@ -872,7 +842,7 @@
"qprog = synthesize(qmod)\n",
"# show(qprog)\n",
"circuit_width = qprog.data.width\n",
"circuit_depth = qprog.transpiled_circuit.depth\n",
"circuit_depth = get_transpiled_circuit_metrics(qprog).depth\n",
"print(\"The circuit width is:\", circuit_width)\n",
"print(\"The circuit depth is:\", circuit_depth)\n",
"\n",
Expand Down Expand Up @@ -947,7 +917,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"id": "25",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1037,31 +1007,16 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"id": "26",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_338747/1064328549.py:52: ClassiqDeprecationWarning: Accessing 'quantum_program.transpiled_circuit.depth' is deprecated. Use 'classiq.get_transpiled_circuit_metrics(quantum_program)' instead.\n",
" circuit_depth = qprog.transpiled_circuit.depth\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Submitting state-vector job to simulator\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The circuit width is: 10\n",
"The circuit depth is: 2129\n"
"The circuit depth is: 2112\n"
]
},
{
Expand Down Expand Up @@ -1128,7 +1083,7 @@
"qprog = synthesize(qmod)\n",
"# show(qprog)\n",
"circuit_width = qprog.data.width\n",
"circuit_depth = qprog.transpiled_circuit.depth\n",
"circuit_depth = get_transpiled_circuit_metrics(qprog).depth\n",
"print(\"The circuit width is:\", circuit_width)\n",
"print(\"The circuit depth is:\", circuit_depth)\n",
"\n",
Expand Down Expand Up @@ -1236,7 +1191,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"id": "29",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1316,31 +1271,16 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"id": "30",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_338747/163062579.py:92: ClassiqDeprecationWarning: Accessing 'quantum_program.transpiled_circuit.depth' is deprecated. Use 'classiq.get_transpiled_circuit_metrics(quantum_program)' instead.\n",
" circuit_depth = qprog.transpiled_circuit.depth\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Submitting state-vector job to simulator\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The circuit width is: 10\n",
"The circuit depth is: 266\n"
"The circuit depth is: 253\n"
]
},
{
Expand Down Expand Up @@ -1447,7 +1387,7 @@
"qprog = synthesize(qmod)\n",
"# show(qprog)\n",
"circuit_width = qprog.data.width\n",
"circuit_depth = qprog.transpiled_circuit.depth\n",
"circuit_depth = get_transpiled_circuit_metrics(qprog).depth\n",
"print(\"The circuit width is:\", circuit_width)\n",
"print(\"The circuit depth is:\", circuit_depth)\n",
"\n",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1.28.0\n"
"1.34.1\n"
]
}
],
Expand Down Expand Up @@ -510,18 +510,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Quantum program link: https://platform.classiq.io/circuit/3IoePDlRq4wMzyUqhvkVtjGeWS1\n"
"Quantum program link: https://platform.classiq.io/circuit/3LgmhlgxbAGzPpjqKzJQHzeNerW\n"
]
},
{
"data": {
"application/vnd.classiq+qviz": "{\"program_id\": \"3IoePDlRq4wMzyUqhvkVtjGeWS1\"}",
"application/vnd.classiq+qviz": "{\"program_id\": \"3LgmhlgxbAGzPpjqKzJQHzeNerW\"}",
"text/plain": [
"https://platform.classiq.io/circuit/3IoePDlRq4wMzyUqhvkVtjGeWS1?login=True&version=22"
"https://platform.classiq.io/circuit/3LgmhlgxbAGzPpjqKzJQHzeNerW?login=True&version=24"
]
},
"metadata": {
"url": "https://platform.classiq.io/circuit/3IoePDlRq4wMzyUqhvkVtjGeWS1?login=True&version=22"
"url": "https://platform.classiq.io/circuit/3LgmhlgxbAGzPpjqKzJQHzeNerW?login=True&version=24"
},
"output_type": "display_data"
}
Expand Down Expand Up @@ -559,7 +559,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/dor/Sources/Classiq/library-13/lib/python3.13/site-packages/classiq/execution/execution_session.py:741: UserWarning: Non-zero amplitudes were detected in states with non-zero auxiliary values. Thus, the returned results may contain duplicates (i.e., multiple amplitudes corresponding to the same output values). The total probability associated with non-zero auxiliary states is 1.6804183104557338e-05\n",
"/home/dor/Sources/Classiq/library-13/lib/python3.13/site-packages/classiq/execution/execution_session.py:787: UserWarning: Non-zero amplitudes were detected in states with non-zero auxiliary values. Thus, the returned results may contain duplicates (i.e., multiple amplitudes corresponding to the same output values). The total probability associated with non-zero auxiliary states is 1.6804183104557338e-05\n",
" return job.get_sample_result(_http_client=self._async_client).dataframe\n"
]
},
Expand All @@ -580,28 +580,12 @@
"Mean Squared Error (MSE): 2.2611239365422727e-11\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_346561/1619421991.py:21: ClassiqDeprecationWarning: Accessing 'quantum_program.transpiled_circuit.depth' is deprecated. Use 'classiq.get_transpiled_circuit_metrics(quantum_program)' instead.\n",
" \"depth\": qprog.transpiled_circuit.depth,\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'depth': 9396, 'width': 12, 'cx_count': 5157}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_346561/1619421991.py:23: ClassiqDeprecationWarning: Accessing 'quantum_program.transpiled_circuit.count_ops' is deprecated. Use 'classiq.get_transpiled_circuit_metrics(quantum_program)' instead.\n",
" \"cx_count\": qprog.transpiled_circuit.count_ops.get(\n"
]
}
],
"source": [
Expand All @@ -621,10 +605,11 @@
" # Generate the optimized quantum circuit\n",
"\n",
" # Extract metrics\n",
" circuit_metrics = get_transpiled_circuit_metrics(qprog)\n",
" metrics = {\n",
" \"depth\": qprog.transpiled_circuit.depth,\n",
" \"depth\": circuit_metrics.depth,\n",
" \"width\": qprog.data.width,\n",
" \"cx_count\": qprog.transpiled_circuit.count_ops.get(\n",
" \"cx_count\": circuit_metrics.count_ops.get(\n",
" \"cx\", 0\n",
" ), # Default to 0 if 'cx' not found\n",
" }\n",
Expand Down
Loading
Loading