Skip to content

Commit

Permalink
Minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfeco committed Feb 23, 2024
1 parent bb6f35f commit 5d3d42f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 49 deletions.
6 changes: 3 additions & 3 deletions tnbs/BTC_02_AE/ae_sine_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ def select_ae(ae_method):
"""

folder_json = os.getcwd()
folder_json = re.sub(
r"WP3_Benchmark/(?=WP3_Benchmark/)*.*", "WP3_Benchmark/", folder_json)
folder_json = folder_json + "tnbs/BTC_02_AE/jsons"
#folder_json = re.sub(
# r"WP3_Benchmark/(?=WP3_Benchmark/)*.*", "WP3_Benchmark/", folder_json)
folder_json = folder_json + "/jsons"
lista_ae_ = []
if ae_method == "MLAE":
lista_ae_.append(folder_json+"/integral_mlae_configuration.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "69e54053-190f-431b-b3da-5342a480f21f",
"metadata": {},
Expand Down Expand Up @@ -151,9 +150,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:tnbs2c] *",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "conda-env-tnbs2c-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -165,7 +164,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
17 changes: 5 additions & 12 deletions tnbs/BTC_04_PH/PH/notebooks/02_Ansatzes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"source": [
"## 1. ansatzes module\n",
"\n",
"One mandatory step for using the Parent Hamiltonian, **PH**, library (see notebook **02_Using_PH_Class.ipynb**) is computing for a given ansatz its complete state. This is the amplitudes of the state in the computational $n$ qubit basis. \n",
"One mandatory step for using the Parent Hamiltonian, **PH**, library (see notebook **03_Using_PH_Class.ipynb**) is computing for a given ansatz its complete state. This is the amplitudes of the state in the computational $n$ qubit basis. \n",
"\n",
"In the *ansatzes* module of the **PH** library, several functions and classes for dealing with this part of the computation were done.\n"
]
Expand All @@ -101,6 +101,7 @@
"metadata": {},
"outputs": [],
"source": [
"sys.path.append(\"../\")\n",
"from ansatzes import SolveCircuit"
]
},
Expand Down Expand Up @@ -978,21 +979,13 @@
" * --count: give the number of all the possible recoverings from **get\\_jobs.json** file.\n",
" * --exe: for executing the complete recovery.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5061b17e-8031-4203-a6f7-ba3ced2c8fff",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:tnbs2c] *",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "conda-env-tnbs2c-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1004,7 +997,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions tnbs/BTC_04_PH/PH/notebooks/03_Using_PH_Class.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"source": [
"## 1. Input Ansatz\n",
"\n",
"To create a Parent Hamiltonian (**PH**) with our software we need, given an input ansatz, the complete state of the ansatz. This is the amplitudes of the state of the ansatz in the computational $n$ qubit basis. In the module *ansatzes* of the **PH** library several ansatzes are defined and a *SolveCircuit* class for simulating and getting results using **Atos myqlm** is provided (see notebook **01_Ansatzes.ipynb** for an explanation and use of this module). Here we use the **ansatz_qlm_01** that is the **Atos myqlm** implementation of the ansatz in the github:\n",
"To create a Parent Hamiltonian (**PH**) with our software we need, given an input ansatz, the complete state of the ansatz. This is the amplitudes of the state of the ansatz in the computational $n$ qubit basis. In the module *ansatzes* of the **PH** library several ansatzes are defined and a *SolveCircuit* class for simulating and getting results using **Atos myqlm** is provided (see notebook **02_Ansatzes.ipynb** for an explanation and use of this module). Here we use the **ansatz_qlm_01** that is the **Atos myqlm** implementation of the ansatz in the github:\n",
"\n",
"https://github.com/FumiKobayashi/Parent_Hamiltonian_as_a_benchmark_problem_for_variational_quantum_eigensolvers\n",
"\n",
Expand Down Expand Up @@ -962,7 +962,7 @@
"source": [
"**Example**\n",
"\n",
"We are going to use the example provided in the **01_Ansatzes.ipynb** where we have used the **ansatzes.py** module for doing computations for a **simple_02** ansatz of 6 **qubits** and **depth** 2. We need to have the following files in the folder **Saves**:\n",
"We are going to use the example provided in the **02_Ansatzes.ipynb** where we have used the **ansatzes.py** module for doing computations for a **simple_02** ansatz of 6 **qubits** and **depth** 2. We need to have the following files in the folder **Saves**:\n",
"\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_parameters.csv\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_state.csv\n",
Expand Down Expand Up @@ -1024,7 +1024,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
17 changes: 8 additions & 9 deletions tnbs/BTC_04_PH/PH/notebooks/04_ParentHamiltonian_execution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"source": [
"## 1. Ansatz Definition and Solving\n",
"\n",
"We neeed to define an ansatz circuit and solving it for getting its state (see **01_Ansatzes.ipynb**. We can use the functions from **ansatzes** module"
"We neeed to define an ansatz circuit and solving it for getting its state (see **02_Ansatzes.ipynb**. We can use the functions from **ansatzes** module"
]
},
{
Expand Down Expand Up @@ -184,7 +184,7 @@
"source": [
"### Ansatz Solution\n",
"\n",
"Now we need to fix the parameters of the ansatz and solving it(see notebook **01_Ansatzes.ipynb**)"
"Now we need to fix the parameters of the ansatz and solving it(see notebook **02_Ansatzes.ipynb**)"
]
},
{
Expand Down Expand Up @@ -247,7 +247,7 @@
"source": [
"## 2. Parent Hamiltonian Computation\n",
"\n",
"With the obtained state of the ansatz, we need to compute the Parent Hamiltonian and get its Pauli string decomposition. Here we use the **parent\\_hamiltonian** module (see notebook **02_Using_PH_Class.ipynb** for more information)"
"With the obtained state of the ansatz, we need to compute the Parent Hamiltonian and get its Pauli string decomposition. Here we use the **parent\\_hamiltonian** module (see notebook **03_Using_PH_Class.ipynb** for more information)"
]
},
{
Expand Down Expand Up @@ -475,7 +475,7 @@
"source": [
"**Example**\n",
"\n",
"We are going to use the example provided in the **01_Ansatzes.ipynb** and **02_Using_PH_Class.ipynb** notebooks where we have used the **ansatzes.py** module for doing computations for a **simple_02** ansatz of 6 **qubits** and **depth** 2, and the **parent_hamiltonian.py** module for computing the corresponding Pauli decomposition of its parent Hamiltonian. We need to have the following files in the folder **Saves**:\n",
"We are going to use the example provided in the **02_Ansatzes.ipynb** and **03_Using_PH_Class.ipynb** notebooks where we have used the **ansatzes.py** module for doing computations for a **simple_02** ansatz of 6 **qubits** and **depth** 2, and the **parent_hamiltonian.py** module for computing the corresponding Pauli decomposition of its parent Hamiltonian. We need to have the following files in the folder **Saves**:\n",
"\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_parameters.csv\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_state.csv\n",
Expand All @@ -485,12 +485,11 @@
"\n",
"Now we can use the **vqe_step.py** module for executing a **VQE** step by using the following command (we have set truncation to 3 so all Pauli coefficients lower than $10^{-3}$ will be pruned):\n",
"\n",
" python vqe_step.py -basefn Saves/ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c -qpu_ph c -truncation 3 \n",
"--savee\n",
" python vqe_step.py -basefn Saves/ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c -qpu_ph c -truncation 3 --save\n",
"\n",
"Now in the **Saves** folder, we should find the following fils (in addition to the other ones)\n",
"\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_phexe.csv)"
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_phexe.csv"
]
},
{
Expand All @@ -500,7 +499,7 @@
"source": [
"## 7. Massive VQE step computations\n",
"\n",
"As for the case of masive ansatz state and parent hamiltonian computations (see Notebook 01_Ansatzes.ipynb and 02_Using_PH_Class.ipynb) we can execute masive **VQE** step computations.For this the 2 following files can be used:\n",
"As for the case of masive ansatz state and parent hamiltonian computations (see Notebook **02_Ansatzes.ipynb and 03_Using_PH_Class.ipynb**) we can execute masive **VQE** step computations.For this the 2 following files can be used:\n",
"\n",
"* **vqe\\_step.json**: JSON file with the configuration for the **VQE** step computations. For each desired computation a complete dictionary should be provided. The keys are:\n",
" * save: for saving or not the results\n",
Expand Down Expand Up @@ -534,7 +533,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
12 changes: 6 additions & 6 deletions tnbs/BTC_04_PH/PH/notebooks/05_CompleteWorkflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"\n",
"The **PH** pacakge has a very modular structure for dealing with the different parts of the **PH** benchmark test case:\n",
"\n",
"* module **ansatzes** deals with ansatz circuit creation and solving (see notebook: **01_Ansatzes.ipynb**)\n",
"* module **parent_hamiltonian**: has functions and class for computing the Parent Hamiltonian and its Pauli String decomposition (see notebook **02_Using_PH_Class.ipynb**)\n",
"* module *vqe_step*: deals with the computation of the ground state energy for a given ansatz and parent hamiltonian (see notebook **03_ParentHamiltonian_execution.ipynb**).\n",
"* module **ansatzes** deals with ansatz circuit creation and solving (see notebook: **02_Ansatzes.ipynb**)\n",
"* module **parent_hamiltonian**: has functions and class for computing the Parent Hamiltonian and its Pauli String decomposition (see notebook **03_Using_PH_Class.ipynb**)\n",
"* module *vqe_step*: deals with the computation of the ground state energy for a given ansatz and parent hamiltonian (see notebook **04_ParentHamiltonian_execution.ipynb**).\n",
"\n",
"In this notebook the module **workflow** is reviewed. This module group all the aforementioned modules for execute a complete Benchamrk Test Case for a **PH Kernel**\n"
]
Expand Down Expand Up @@ -242,7 +242,7 @@
"source": [
"Examples:\n",
"\n",
"We can reproduce the examples from notebooks **01_Ansatzes.ipynb**, **02_Using_PH_Class.ipynb** and **03_ParentHamiltonian_execution.ipynb**: we are going to develop the complete workflow for an ansatz *simple_02* of 6 *qubits* and with *depth* 3. We are going to use a *truncation* of 3 ($10^{-3}$) for pruning the Pauli decomposition. We are going to save all into the *Saves2* folder:\n",
"We can reproduce the examples from notebooks **02_Ansatzes.ipynb**, **03_Using_PH_Class.ipynb** and **04_ParentHamiltonian_execution.ipynb**: we are going to develop the complete workflow for an ansatz *simple_02* of 6 *qubits* and with *depth* 3. We are going to use a *truncation* of 3 ($10^{-3}$) for pruning the Pauli decomposition. We are going to save all into the *Saves2* folder:\n",
"\n",
" python workflow.py -nqubits 6 -depth 2 -ansatz simple02 -qpu_ansatz c -truncation 3 -qpu_ph c -folder Saves2 --save\n",
"\n",
Expand All @@ -253,7 +253,7 @@
"* \n",
"ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_pauli.cs\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_solve_ansatz_time.cs\n",
"* \r\n",
"* \n",
"ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_ph_time.c\n",
"* ansatz_simple02_nqubits_6_depth_2_qpu_ansatz_c_state.csv"
]
Expand Down Expand Up @@ -294,7 +294,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
12 changes: 2 additions & 10 deletions tnbs/BTC_04_PH/PH/notebooks/06_ParentHamiltonian_with_MPS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,8 @@
"\n",
"For doing a parent Hamiltonian computation for a *simple01* ansatz of 24 *qubits* with *depth* 4 type and with a truncation for SVD of 0.001 type\n",
"\n",
" python parent_hamiltonian_mps.py -nqubits 24 -depth 4 --truncate -t_v 0.001 --t_inv --save --exe -folder SavesMPSg program"
" python parent_hamiltonian_mps.py -nqubits 24 -depth 4 --truncate -t_v 0.001 --t_inv --save --exe -folder SavesMPS"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4eef6f38-0988-45c1-9bdf-c173b0891f3b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -446,7 +438,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"$$\\newcommand{\\ket}[1]{\\left|{#1}\\right\\rangle}$$\n",
"$$\\newcommand{\\bra}[1]{\\left\\langle{#1}\\right|}$$\n",
"\n",
"As explained in notebooks: *02_Using_PH_Class.ipynb* and *05_ParentHamiltonian_with_MPS.ipynb* the main operation needed for computing a **PH** from an ansatz is the calculation of density matrices. In this notebook, we explain how to compute them when the **MPS** representation is given."
"As explained in notebooks: *03_Using_PH_Class.ipynb* and *06_ParentHamiltonian_with_MPS.ipynb* the main operation needed for computing a **PH** from an ansatz is the calculation of density matrices. In this notebook, we explain how to compute them when the **MPS** representation is given."
]
},
{
Expand Down Expand Up @@ -294,7 +294,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 5d3d42f

Please sign in to comment.