-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
2,197 additions
and
3,597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
anyio==4.2.0 | ||
anytree==2.8.0 | ||
argon2-cffi==23.1.0 | ||
argon2-cffi-bindings==21.2.0 | ||
arrow==1.3.0 | ||
asttokens==2.4.1 | ||
async-lru==2.0.4 | ||
attrs==23.2.0 | ||
Babel==2.14.0 | ||
beautifulsoup4==4.12.2 | ||
bitarray==2.9.2 | ||
bitstring==4.1.4 | ||
bleach==6.1.0 | ||
Brotli==1.1.0 | ||
cached-property==1.5.2 | ||
certifi==2023.11.17 | ||
cffi==1.16.0 | ||
charset-normalizer==3.3.2 | ||
clarabel==0.6.0 | ||
colorama==0.4.6 | ||
comm==0.2.1 | ||
contourpy==1.2.0 | ||
cryptography==41.0.7 | ||
cvxpy==1.4.1 | ||
cycler==0.12.1 | ||
debugpy==1.8.0 | ||
decorator==5.1.1 | ||
defusedxml==0.7.1 | ||
dill==0.3.7 | ||
ecos==2.0.11 | ||
entrypoints==0.4 | ||
exceptiongroup==1.2.0 | ||
executing==2.0.1 | ||
fastjsonschema==2.19.1 | ||
fonttools==4.47.2 | ||
fqdn==1.5.1 | ||
idna==3.6 | ||
importlib-metadata==7.0.1 | ||
importlib-resources==6.1.1 | ||
iniconfig==2.0.0 | ||
ipykernel==6.28.0 | ||
ipython==8.20.0 | ||
ipywidgets==8.1.1 | ||
isoduration==20.11.0 | ||
jax==0.4.23 | ||
jaxlib==0.4.23 | ||
jedi==0.19.1 | ||
Jinja2==3.1.3 | ||
joblib==1.3.2 | ||
json5==0.9.14 | ||
jsonpointer==2.4 | ||
jsonschema==4.20.0 | ||
jsonschema-specifications==2023.12.1 | ||
jupyter==1.0.0 | ||
jupyter_client==8.6.0 | ||
jupyter-console==6.6.3 | ||
jupyter_core==5.7.1 | ||
jupyter-events==0.9.0 | ||
jupyter-lsp==2.2.1 | ||
jupyter_server==2.12.4 | ||
jupyter_server_terminals==0.5.1 | ||
jupyterlab==4.0.10 | ||
jupyterlab_pygments==0.3.0 | ||
jupyterlab_server==2.25.2 | ||
jupyterlab-widgets==3.0.9 | ||
kiwisolver==1.4.5 | ||
MarkupSafe==2.1.3 | ||
matplotlib==3.8.2 | ||
matplotlib-inline==0.1.6 | ||
mistune==3.0.2 | ||
ml-dtypes==0.3.2 | ||
munkres==1.1.4 | ||
myqlm==1.9.5 | ||
myqlm-clinalg==0.1.3 | ||
myqlm-contrib==1.9.2 | ||
myqlm-fermion==1.1.1 | ||
myqlm-simulators==1.9.3 | ||
nb-conda-kernels==2.3.1 | ||
nbclient==0.8.0 | ||
nbconvert==7.14.1 | ||
nbformat==5.9.2 | ||
nest-asyncio==1.5.8 | ||
networkx==3.2.1 | ||
notebook==7.0.6 | ||
notebook_shim==0.2.3 | ||
numpy==1.26.3 | ||
opt-einsum==3.3.0 | ||
osqp==0.6.3 | ||
overrides==7.4.0 | ||
packaging==23.2 | ||
pandas==2.1.4 | ||
pandocfilters==1.5.0 | ||
parso==0.8.3 | ||
pexpect==4.8.0 | ||
pickleshare==0.7.5 | ||
pillow==10.2.0 | ||
pip==23.3.2 | ||
pkgutil_resolve_name==1.3.10 | ||
platformdirs==4.1.0 | ||
pluggy==1.3.0 | ||
ply==3.11 | ||
prettytable==3.9.0 | ||
prometheus-client==0.19.0 | ||
prompt-toolkit==3.0.42 | ||
psutil==5.9.7 | ||
ptyprocess==0.7.0 | ||
pure-eval==0.2.2 | ||
pycparser==2.21 | ||
pyDOE==0.3.8 | ||
Pygments==2.17.2 | ||
pyOpenSSL==23.3.0 | ||
pyparsing==3.1.1 | ||
PyQt5==5.15.9 | ||
PyQt5-sip==12.12.2 | ||
PySocks==1.7.1 | ||
pytest==7.4.4 | ||
python-dateutil==2.8.2 | ||
python-json-logger==2.0.7 | ||
pytz==2023.3.post1 | ||
PyYAML==6.0.1 | ||
pyzmq==25.1.2 | ||
qat-comm==1.4.5 | ||
qat-core==1.8.3 | ||
qat-devices==0.2.3 | ||
qat-hardware==1.3.3 | ||
qat-lang==3.0.3 | ||
qat-quops==1.3.2 | ||
qat-variational==1.4.3 | ||
qdldl==0.1.5.post2 | ||
qlmaas==1.9.3 | ||
qtconsole==5.5.1 | ||
QtPy==2.4.1 | ||
qutip==4.7.3 | ||
referencing==0.32.1 | ||
requests==2.31.0 | ||
rfc3339-validator==0.1.4 | ||
rfc3986-validator==0.1.1 | ||
rpds-py==0.17.1 | ||
SciPy==1.11.4 | ||
scs==3.2.3 | ||
Send2Trash==1.8.2 | ||
setuptools==69.0.3 | ||
sip==6.7.12 | ||
six==1.16.0 | ||
sniffio==1.3.0 | ||
soupsieve==2.5 | ||
stack-data==0.6.2 | ||
svgwrite==1.4.3 | ||
terminado==0.18.0 | ||
thrift==0.16.0 | ||
tinycss2==1.2.1 | ||
toml==0.10.2 | ||
tomli==2.0.1 | ||
tornado==6.3.3 | ||
tqdm==4.66.1 | ||
traitlets==5.14.1 | ||
types-python-dateutil==2.8.19.20240106 | ||
typing_extensions==4.9.0 | ||
typing-utils==0.1.0 | ||
tzdata==2023.4 | ||
uri-template==1.3.0 | ||
urllib3==2.1.0 | ||
Wand==0.6.13 | ||
wcwidth==0.2.13 | ||
webcolors==1.13 | ||
webencodings==0.5.1 | ||
websocket-client==1.7.0 | ||
wheel==0.42.0 | ||
widgetsnbextension==4.0.9 | ||
zipp==3.17.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
tnbs/BTC_04_PH/PH/notebooks/01_ParentHamiltonianBencmark.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "abc0ec77-a62e-47fd-9780-b6002e237eb5", | ||
"metadata": {}, | ||
"source": [ | ||
"# Parent Hamiltonian Benchmark\n", | ||
"\n", | ||
"Present notebook documents the **Parent Hamiltonian** (**PH**) **kernel** and its associated **Benchmark Test Case**. Additionally, explains how the benchmark can be executed.\n", | ||
"\n", | ||
"$$\\newcommand{\\braket}[2]{\\left\\langle{#1}\\middle|{#2}\\right\\rangle}$$\n", | ||
"$$\\newcommand{\\ket}[1]{\\left|{#1}\\right\\rangle}$$\n", | ||
"$$\\newcommand{\\bra}[1]{\\left\\langle{#1}\\right|}$$" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3b7ed307-b41f-4d76-9467-c73047f583d8", | ||
"metadata": {}, | ||
"source": [ | ||
"## 1. PH Kernel\n", | ||
"\n", | ||
"Given an ansatz with a state $\\ket{\\Psi \\left(\\theta\\right)}$, where $\\theta$ is a vector of parameters, the **PH kernel** aims to compute a Hamiltonian, $\\mathcal{H}$, such that the ansatz is its ground state with a fixed energy of 0. Such Hamiltonian is called the **Parent Hamiltonian**^of the ansatz (or of the state $\\ket{\\Psi \\left(\\theta\\right)}$)\n", | ||
"\n", | ||
"$$\\mathcal{H}\\ket{\\Psi \\left(\\theta\\right)} = 0 \\tag{1}$$\n", | ||
"\n", | ||
"In the **TNBS** it is expected to use the **PH kernel** for evaluating the performance of quantum architectures for running typical **VQE** circuits (or ansatzes).\n", | ||
"\n", | ||
"This kernel is based on the original *Parent Hamiltonian* paper:\n", | ||
"\n", | ||
"* Kobayashi, F., Mitarai, K., & Fujii, K. (2022). Parent Hamiltonian as a benchmark problem for variational quantum eigensolvers. Phys. Rev. A, 105, 052415 (https://doi.org/10.1103%2Fphysreva.105.052415)" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"id": "69e54053-190f-431b-b3da-5342a480f21f", | ||
"metadata": {}, | ||
"source": [ | ||
"## 2. BTC\n", | ||
"\n", | ||
"As a **BTC** for the **PH kernel** we are going to use the proposed ansatz on the original *Parent Hamiltonian* paper that is depicted in the following figure:\n", | ||
"\n", | ||
"\n", | ||
"![alternatvie text](./parent_hamiltonian.svg)\n", | ||
"\n", | ||
"\n", | ||
"The ansatz is the circuit inside the rectangle solid line and it can be composed of several layers. Each layer (rectangle dashed line) is composed of a $R_X(\\theta_i)$ gate by qubit, followed by a ladder of $CNOT$ gates and finally a $R_Z(\\theta_{i+1})$ by qubit.\n", | ||
"\n", | ||
"The angles of the different gates will be set to, follow the TNBS guidelines:\n", | ||
"\n", | ||
"$$\\delta \\theta = \\frac{\\pi}{4*(n_l+1)}$$ $$\\theta_i = (i+1) \\delta \\theta \\; i=0, 1, \\cdots 2n_l-1$$ where $n_l$ is the number of layers of the ansatz (the **depth** of the ansatz)\n", | ||
"\n", | ||
"For a fixed **number of qubits** and **depth** the corresponding **PH** of the ansatz should be computed and decomposed as linear decomposition following $(2)$: $$\\mathcal{H} = \\sum_{I=0}^{4^n-1} a_I P_{I}^n\\tag{2}$$ where $P_I^n$ is a generalized Pauli string: $$P_I^n=\\sigma_{i_0} \\otimes \\sigma_{i_1} \\cdots \\otimes \\sigma_{i_{n-1}}$$ where $i_j={0, 1, 2, 3}$.\n", | ||
"\n", | ||
"For each possible **Pauli** string the complete ansatz circuit should be executed and the corresponding expected value of the **Pauli** string should be computed (this is depicted in the figure with *Rotation to $P_i$ measurement basis* and the *$\\langle P_i \\rangle$* boxes). Finally, all the computed expected values ($\\langle P_i \\rangle$) should be gathered and the ground state energy ($E_0$) of the ansatz under the **PH** should be computed using $(3)$:$$E_0 = \\sum_{I=0}^{4^n-1} a_I \\langle P_i \\rangle \\tag{3}$$\n", | ||
"\n", | ||
"If all properly works the obtained $E_0$ should be as close to 0 as possible." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b14f7f06-162c-4934-b8ac-cbad1696b29d", | ||
"metadata": {}, | ||
"source": [ | ||
"## 3 Benchmark execution.\n", | ||
"\n", | ||
"In the present repository, we have computed the Pauli decomposition for ansatz circuits from 3 to 30 qubits and for 1 to 4 depths. The mandatory files are stored inside the **BTC_04_PH/configuration_files/**. There are 2 kinds of files:\n", | ||
"\n", | ||
"* *_parameters.csv* files: where the different parameters of the ansatz circuit are stored.\n", | ||
"* _pauli.csv* files: where the corresponding Pauli decomposition is stored.\n", | ||
"\n", | ||
"These files are mandatory for executing the **BTC** using the code of the repository." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2c8bd9ad-672e-48dc-91ba-66d10b969ce1", | ||
"metadata": {}, | ||
"source": [ | ||
"## 4. my_benchmark_execution.py\n", | ||
"\n", | ||
"The **my_benchmark_execution.py** module executes the benchmark for the **PH BTC**. This module needs the files stored in the **BTC_04_PH/configuration_files/** folder. \n", | ||
"\n", | ||
"The benchmark can be configured using the *kernel_configuration* and the *benchmark_arguments* dictionary at the end of the **my_benchmark_execution.py** module. \n", | ||
"\n", | ||
"For selecting the depths to execute the key *depth* from the *kernel_configuration* dictionary should be modified (a list with the different depths should be provided). Only depths from 1 to 4 can be provided (are the precomputed ansatz depths).\n", | ||
"For selecting the number of qubits to execute the key *list_of_qbits* from the *benchmark_arguments* should be modified (a list with different number of qubits should be provided). Only qubits from 3 to 30 can be provided (are the precomputed ansatz qubits).\n", | ||
"\n", | ||
"**NOTE** \n", | ||
"The bechmark will be executed for each number of qubits and depths. So if you provide:\n", | ||
"* depth : [2, 3]\n", | ||
"* list_of_qbits: [15, 18]\n", | ||
"\n", | ||
"then the ansatzes for 15 qubits and 2 and 3 depths, and for 18 and 2 of 3 ansatzes will be executed (4 different executions will be done).\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "69adb7fb-cf82-4e2a-976d-00c020a6302e", | ||
"metadata": {}, | ||
"source": [ | ||
"## 5. Generating the JSON file.\n", | ||
"\n", | ||
"Once the files from a complete benchmark execution are generated the information should be formated following the **NEASQC JSON schema**. For doing this the **neasqc_benchmark.py** module can be used. At the end of the file the path to the folder where all the files from benchmark are stored should be provided to the variable **folder**.\n", | ||
"\n", | ||
"For creating the JSON file following command should eb executed:\n", | ||
"\n", | ||
" python neasqc_benchmark.py" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0bdc2b52-0e67-4ad6-81fe-ee2e67ebcba7", | ||
"metadata": {}, | ||
"source": [ | ||
"## 6. Complete Workflow.\n", | ||
"\n", | ||
"The bash script **benchmark_exe.sh** allows to automatize the execution of the benchmark and the JSON file generation (once the *my_benchmark_execution.py* and the *neasqc_benchmark.py* are properly configured).\n", | ||
"\n", | ||
" bash benchmark_exe.sh" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7f94c0d3-3e96-49b8-86f7-686e3235ef5b", | ||
"metadata": {}, | ||
"source": [ | ||
"## 7. About the other notebooks.\n", | ||
"\n", | ||
"The other notebooks presented in the **BTC_04_PH/PH/notebooks/* folder gives more information about the **Parent Hamiltonian** and about the code used for generating the configuration files. The user can check it and can use for creating different ansatzes and its corresponding Pauli decomposition even can be used for creating **BTC** with higher depths (or even higher numbers of qubits). The notebooks are:\n", | ||
"\n", | ||
"* **02_Ansatzes.ipynb**: in this notebook the code for computing different ansatzes and their corresponding states are explained.\n", | ||
"* **03_Using_PH_Class.ipynb**: in this notebook the internal details of the **Parent Hamiltonian** computation are provided. Additionally, the mandatory code for creating the Pauli decomposition of the **PH** is described.\n", | ||
"* **04_ParentHamiltonian_execution.ipynb**: in this notebook the code used for, giving the ansatz and its corresponding **PH** Pauli decomposition, execute **VQE** step is explained.\n", | ||
"* **05_CompleteWorkflow.ipynb**: in this notebook the code for a complete workflow (creating the ansatz, computing the PH and executing the **VQE** step) is provided and explained.\n", | ||
"* **06_ParentHamiltonian_with_MPS.ipynb**: the main problem of the **PH** case is the need to compute the state of the ansatz for obtaining the **PH**. Using vector state simulators for this task can be very inefficient (and even unaffordable) when the number of qubits (or even the depth) increases. For this case techniques like *Matrix Product State* from **Tensor Networks** can be used. In this notebook, we explain how to use or naive implementation of these computations for obtaining the **PH** Pauli decomposition.\n", | ||
"* **07_Ansatz_MPS.ipynb**: this notebook explains how to use our **MPS** implementation for computing the state of the **BTC** ansatz.\n", | ||
"* **08_ReducedDensityMatriceswithMPS.ipynb**: this notebook shows how to use our **MPS** implementation for computing the **PH** Pauli decomposition." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b0d83731-ddea-495d-842e-776fea3640bd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python [conda env:tnbs2c] *", | ||
"language": "python", | ||
"name": "conda-env-tnbs2c-py" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.