Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
49 changes: 18 additions & 31 deletions algorithms/quantum_linear_solvers/hhl/hhl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -589,22 +589,9 @@
"qmod_hhl_exact = hhl_model(main, backend_preferences)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "31",
"metadata": {},
"outputs": [],
"source": [
"from classiq import write_qmod\n",
"\n",
"# Save qmod file\n",
"write_qmod(qmod_hhl_exact, \"hhl\", decimal_precision=20, symbolic_only=False)"
]
},
{
"cell_type": "markdown",
"id": "32",
"id": "31",
"metadata": {},
"source": [
"#### Synthesizing the Model (exact)"
Expand All @@ -613,7 +600,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "33",
"id": "32",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -646,7 +633,7 @@
}
},
"cell_type": "markdown",
"id": "34",
"id": "33",
"metadata": {},
"source": [
"![image.png](attachment:70e1642f-7684-4c35-82e7-81f3fecb9476.png)\n",
Expand All @@ -657,7 +644,7 @@
},
{
"cell_type": "markdown",
"id": "35",
"id": "34",
"metadata": {},
"source": [
"#### Statevector Simulation (exact)\n",
Expand All @@ -668,7 +655,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "36",
"id": "35",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -679,7 +666,7 @@
},
{
"cell_type": "markdown",
"id": "37",
"id": "36",
"metadata": {},
"source": [
"#### Results (exact)"
Expand All @@ -688,7 +675,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "38",
"id": "37",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
Expand Down Expand Up @@ -726,7 +713,7 @@
},
{
"cell_type": "markdown",
"id": "39",
"id": "38",
"metadata": {},
"source": [
"### Example: Approximated Hamiltonian Evolution (Suzuki-Trotter)\n",
Expand All @@ -736,7 +723,7 @@
},
{
"cell_type": "markdown",
"id": "40",
"id": "39",
"metadata": {},
"source": [
"For the QPE we are going to use Classiq's `suzuki-trotter` function of order one for Hamiltonian evolution $e^{-i H t}$ [[3](#Trotter)]. This function is an approximated one, where its `repetitions` parameter controls its error. For a QPE algorithm with estimator size $m$ a series of controlled-unitaries $U^{2^k}$ with $0 \\leq k \\leq n-1$ are applied, for each of which we would like to pass a different `repetitions` parameter depth (to keep a roughly same error, the repetitions for approximating $U=e^{2\\pi i 2^k A }$ is expected to be $\\sim 2^k$ times the repetitions of $U=e^{2\\pi i A }$). In Classiq this can be done by working with a [`qpe_flexible`](https://github.com/Classiq/classiq-library/blob/main/functions/qmod_library_reference/classiq_open_library/qpe/qpe.ipynb), and passing a \"rule\" for how to exponentiate each step within the QPE in `repetitions` parameter."
Expand All @@ -745,7 +732,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "41",
"id": "40",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -771,7 +758,7 @@
},
{
"cell_type": "markdown",
"id": "42",
"id": "41",
"metadata": {},
"source": [
"The parameters `R0` and `REPS_SCALING_FACTOR` dictate the number of repititions in the Suzuki-Trotter approximation. The specific number of repititions depend on the Hamiltonian, and therefore, were chosen by trial and error. For other examples, one would need to use different values for these parameters, please compare with specific example in [Flexible QPE tutorial](https://github.com/Classiq/classiq-library/blob/main/tutorials/advanced_tutorials/high_level_modeling_flexible_qpe/high_level_modeling_flexible_qpe.ipynb). The relevant literature that discusses the errors of product formulas is available in Ref. [[5](#trotter-error)]."
Expand All @@ -780,7 +767,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "43",
"id": "42",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -826,7 +813,7 @@
{
"cell_type": "code",
"execution_count": 17,
"id": "44",
"id": "43",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
Expand Down Expand Up @@ -878,15 +865,15 @@
},
{
"cell_type": "markdown",
"id": "45",
"id": "44",
"metadata": {},
"source": [
"We explored the HHL algorithm for solving linear systems using exact and approximated Hamiltonian simulations. The exact method, with a smaller circuit depth, is computationally less intensive but lacks scalability. In contrast, the approximated method, with a greater circuit depth, offers flexibility and can handle larger, more complex systems. This trade-off underscores the importance of selecting the appropriate method based on the problem's size and complexity."
]
},
{
"cell_type": "markdown",
"id": "46",
"id": "45",
"metadata": {},
"source": [
"## Technical Notes\n",
Expand All @@ -899,7 +886,7 @@
},
{
"cell_type": "markdown",
"id": "47",
"id": "46",
"metadata": {},
"source": [
"### Generalizations\n",
Expand Down Expand Up @@ -962,7 +949,7 @@
},
{
"cell_type": "markdown",
"id": "48",
"id": "47",
"metadata": {},
"source": [
"## References\n",
Expand Down Expand Up @@ -1007,7 +994,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
Loading