-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from sequence-toolbox/RnD
Separate Parallel
- Loading branch information
Showing
39 changed files
with
410 additions
and
143 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
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
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
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
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
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
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,5 @@ | ||
Process Communication | ||
===================== | ||
|
||
.. automodule:: parallel.src.communication | ||
:members: |
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,5 @@ | ||
Parallel Quantum Manager | ||
============================ | ||
|
||
.. automodule:: parallel.src.p_quantum_manager | ||
:members: |
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,5 @@ | ||
Parallel Router Net Topology | ||
============================ | ||
|
||
.. automodule:: parallel.src.p_router_net_topo | ||
:members: |
2 changes: 1 addition & 1 deletion
2
docs/source/references/kernel/p_timeline.rst → ...source/references/parallel/p_timeline.rst
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Parallel Timeline | ||
================= | ||
|
||
.. automodule:: src.kernel.p_timeline | ||
.. automodule:: parallel.src.p_timeline | ||
:members: |
2 changes: 1 addition & 1 deletion
2
...erences/kernel/quantum_manager_client.rst → ...ences/parallel/quantum_manager_client.rst
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Quantum Manager Client | ||
====================== | ||
|
||
.. automodule:: src.kernel.quantum_manager_client | ||
.. automodule:: parallel.src.quantum_manager_client | ||
:members: |
2 changes: 1 addition & 1 deletion
2
...erences/kernel/quantum_manager_server.rst → ...ences/parallel/quantum_manager_server.rst
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Quantum Manager Server | ||
====================== | ||
|
||
.. automodule:: src.kernel.quantum_manager_server | ||
.. automodule:: parallel.src.quantum_manager_server | ||
:members: |
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,14 @@ | ||
Parallel | ||
======== | ||
|
||
The parallel `psequence` package provides a parallel execution implementation for SeQUeNCe. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
p_timeline | ||
p_router_net_topo | ||
p_quantum_manager | ||
quantum_manager_client | ||
quantum_manager_server | ||
communication |
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,158 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a1107282", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\"\"\"To modify the `improved_fidelity` static method of entanglement purification protocol (`BBPSSW`).\n", | ||
"\n", | ||
"The modification is aimed at demonstrating entanglement purification under a different error model,\n", | ||
"i.e. only single-qubit bit-flip errors exist. Thus the imperfect entangled states are no longer Werner-type\n", | ||
"but simply a mixture of two Bell states: `desired_state` and its counterpart under single-qubit bit-flip.\n", | ||
"In this case the improved fidelity is different from more general case where Werner states are considered.\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"from sequence.entanglement_management.purification import BBPSSW\n", | ||
"\n", | ||
"\n", | ||
"def test_fid(F):\n", | ||
" \"\"\"Only for testing this approach of modification.\"\"\"\n", | ||
" \n", | ||
" return 0.88\n", | ||
"\n", | ||
"def original_fid(F):\n", | ||
" \"\"\"Only for record of original method in script before modification.\"\"\"\n", | ||
" \n", | ||
" return (F ** 2 + ((1 - F) / 3) ** 2) / (F ** 2 + 2 * F * (1 - F) / 3 + 5 * ((1 - F) / 3) ** 2)\n", | ||
"\n", | ||
"def new_improved_fid(F):\n", | ||
" \"\"\"The improved fidelity corresponding under bit-flip error model.\"\"\"\n", | ||
" \n", | ||
" return F ** 2 / (F ** 2 + (1 - F) ** 2)\n", | ||
"\n", | ||
"BBPSSW.improved_fidelity = new_improved_fid" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "af43fb2c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\"\"\"To modify the `_set_state_with_fidelity` function defined in SeQUeNCe BSM modele.\n", | ||
"\n", | ||
"This modification is corresponding to the previous modification of purification improved fidelity.\n", | ||
"Previously the physically generated entangled states are of Werner type, to demonstrate the difference\n", | ||
"now they should be mixture of only two Bell states as discussed above.\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"import sequence.components.bsm as bsm_module\n", | ||
"from sequence.kernel.quantum_manager import KET_STATE_FORMALISM, DENSITY_MATRIX_FORMALISM\n", | ||
"\n", | ||
"\n", | ||
"BSM = bsm_module.BSM\n", | ||
"\n", | ||
"def test_method(keys, desired_state, fidelity, rng, qm):\n", | ||
" \"\"\"Only for testing this approach of modification.\"\"\"\n", | ||
" \n", | ||
" possible_states = [BSM._phi_plus, BSM._phi_minus,\n", | ||
" BSM._psi_plus, BSM._psi_minus]\n", | ||
" assert desired_state in possible_states\n", | ||
"\n", | ||
" if qm.formalism == KET_STATE_FORMALISM:\n", | ||
" qm.set(keys, desired_state)\n", | ||
"\n", | ||
" elif qm.formalism == DENSITY_MATRIX_FORMALISM:\n", | ||
" state = outer(desired_state, desired_state)\n", | ||
" qm.set(keys, state)\n", | ||
"\n", | ||
" else:\n", | ||
" raise Exception(\"Invalid quantum manager with formalism {}\".format(qm.formalism))\n", | ||
" \n", | ||
"def _set_state_with_fidelity(keys, desired_state, fidelity, rng, qm):\n", | ||
" \"\"\"Only for record of original method in script before modification.\"\"\"\n", | ||
"\n", | ||
" possible_states = [BSM._phi_plus, BSM._phi_minus,\n", | ||
" BSM._psi_plus, BSM._psi_minus]\n", | ||
" assert desired_state in possible_states\n", | ||
"\n", | ||
" if qm.formalism == KET_STATE_FORMALISM:\n", | ||
" probabilities = [(1 - fidelity) / 3] * 4\n", | ||
" probabilities[possible_states.index(desired_state)] = fidelity\n", | ||
" state_ind = rng.choice(4, p=probabilities)\n", | ||
" qm.set(keys, possible_states[state_ind])\n", | ||
"\n", | ||
" elif qm.formalism == DENSITY_MATRIX_FORMALISM:\n", | ||
" multipliers = [(1 - fidelity) / 3] * 4\n", | ||
" multipliers[possible_states.index(desired_state)] = fidelity\n", | ||
" state = zeros((4, 4))\n", | ||
" for mult, pure in zip(multipliers, possible_states):\n", | ||
" state = add(state, mult * outer(pure, pure))\n", | ||
" qm.set(keys, state)\n", | ||
"\n", | ||
" else:\n", | ||
" raise Exception(\"Invalid quantum manager with formalism {}\".format(qm.formalism))\n", | ||
"\n", | ||
"def new_set_state(keys, desired_state, fidelity, rng, qm):\n", | ||
" \"\"\"The new function to set generated entangled states under a different assumed error model.\"\"\"\n", | ||
"\n", | ||
" possible_states = [BSM._phi_plus, BSM._phi_minus,\n", | ||
" BSM._psi_plus, BSM._psi_minus]\n", | ||
" assert desired_state in possible_states\n", | ||
"\n", | ||
" if qm.formalism == KET_STATE_FORMALISM:\n", | ||
" probabilities = [0] * 4\n", | ||
" probabilities[possible_states.index(desired_state)] = fidelity\n", | ||
" if desired_state == BSM._psi_plus:\n", | ||
" probabilities[possible_states.index(BSM._phi_plus)] = 1 - fidelity\n", | ||
" elif desired_state == BSM._psi_minus:\n", | ||
" probabilities[possible_states.index(BSM._phi_minus)] = 1 - fidelity\n", | ||
" state_ind = rng.choice(4, p=probabilities)\n", | ||
" qm.set(keys, possible_states[state_ind])\n", | ||
"\n", | ||
" elif qm.formalism == DENSITY_MATRIX_FORMALISM:\n", | ||
" multipliers = [0] * 4\n", | ||
" multipliers[possible_states.index(desired_state)] = fidelity\n", | ||
" if desired_state == BSM._psi_plus:\n", | ||
" probabilities[possible_states.index(BSM._phi_plus)] = 1 - fidelity\n", | ||
" elif desired_state == BSM._psi_minus:\n", | ||
" probabilities[possible_states.index(BSM._phi_minus)] = 1 - fidelity\n", | ||
" state = zeros((4, 4))\n", | ||
" for mult, pure in zip(multipliers, possible_states):\n", | ||
" state = add(state, mult * outer(pure, pure))\n", | ||
" qm.set(keys, state)\n", | ||
"\n", | ||
" else:\n", | ||
" raise Exception(\"Invalid quantum manager with formalism {}\".format(qm.formalism))\n", | ||
"\n", | ||
"\n", | ||
"bsm_module._set_state_with_fidelity = new_set_state" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.8.13" | ||
} | ||
}, | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
install_no_pip: | ||
python3 setup.py install | ||
|
||
install: | ||
pip3 install . | ||
|
||
test_parallel: | ||
mpiexec -n 2 pytest ./tests_parallel --with-mpi |
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
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
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.