sequence 0.8.1.dev229865249__tar.gz → 0.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sequence-0.8.1.dev229865249/sequence.egg-info → sequence-0.8.2}/PKG-INFO +3 -12
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/README.md +2 -11
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/pyproject.toml +2 -2
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/__init__.py +1 -1
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/app/request_app.py +1 -1
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/detector.py +9 -2
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/memory.py +3 -2
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/optical_channel.py +2 -2
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/generation/single_heralded.py +7 -5
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/purification/bbpssw_bds.py +10 -16
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/purification/bbpssw_circuit.py +3 -3
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/purification/bbpssw_protocol.py +5 -2
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/swapping.py +1 -1
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/process.py +2 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/quantum_manager.py +142 -25
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/quantum_utils.py +52 -19
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/timeline.py +6 -1
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/network_management/network_manager.py +10 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/network_management/reservation.py +101 -52
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/resource_management/memory_manager.py +10 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/resource_management/resource_manager.py +1 -1
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/router_net_topo.py +0 -5
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/utils/config_generator.py +13 -59
- {sequence-0.8.1.dev229865249 → sequence-0.8.2/sequence.egg-info}/PKG-INFO +3 -12
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/LICENSE +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/requirements.txt +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/app/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/app/random_request.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/app/teleport_app.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/beam_splitter.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/bsm.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/circuit.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/fiber_stretcher.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/interferometer.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/light_source.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/mirror.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/photon.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/spdc_lens.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/switch.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/transducer.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/components/transmon.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/constants.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/entanglement_protocol.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/generation/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/generation/barret_kok.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/generation/generation_base.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/generation/generation_message.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/purification/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/entanglement_management/teleportation.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/app.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/css_styles.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/default_params.json +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/graph_comp.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/layout.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/menus.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/run_gui.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/simulator_bindings.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/starlight.json +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/gui/user_templates.json +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/entity.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/event.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/eventlist.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/kernel/quantum_state.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/message.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/network_management/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/network_management/routing.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/protocol.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/qkd/BB84.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/qkd/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/qkd/cascade.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/qlan/correction.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/qlan/graph_gen.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/qlan/measurement.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/resource_management/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/resource_management/rule_manager.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/dqc_net_topo.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/node.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/qkd_topo.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/qlan/client.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/qlan/orchestrator.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/qlan_star_topo.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/topology/topology.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/utils/__init__.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/utils/encoding.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/utils/log.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence/utils/noise.py +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence.egg-info/SOURCES.txt +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence.egg-info/dependency_links.txt +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence.egg-info/requires.txt +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/sequence.egg-info/top_level.txt +0 -0
- {sequence-0.8.1.dev229865249 → sequence-0.8.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sequence
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
Summary: Simulator of QUantum Network Communication (SeQUeNCe) is an open-source tool that allows modeling of quantum networks including photonic network components, control protocols, and applications.
|
|
5
5
|
Author-email: "Xiaoliang Wu, Joaquin Chung, Alexander Kolar, Alexander Kiefer, Eugene Wang, Tian Zhong, Rajkumar Kettimuthu, Martin Suchara, Robert Hayek, Ansh Singal, Caitao Zhan" <czhan@anl.gov>
|
|
6
6
|
Maintainer-email: Caitao Zhan <czhan@anl.gov>
|
|
@@ -75,7 +75,7 @@ SeQUeNCe is an open source, discrete-event simulator for quantum networks. As de
|
|
|
75
75
|
These modules can be edited by users to define additional functionality and test protocol schemes, or may be used as-is to test network parameters and topologies.
|
|
76
76
|
|
|
77
77
|
## Installing
|
|
78
|
-
SeQUeNCe requires [Python](https://www.python.org/downloads/) 3.
|
|
78
|
+
SeQUeNCe requires [Python](https://www.python.org/downloads/) 3.11 or later. You can simply install SeQUeNCe using `pip`:
|
|
79
79
|
```
|
|
80
80
|
pip install sequence
|
|
81
81
|
```
|
|
@@ -116,16 +116,7 @@ python gui.py
|
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
## Usage Examples
|
|
119
|
-
Many examples of SeQUeNCe in action can be found in the [example](/example) folder.
|
|
120
|
-
|
|
121
|
-
### Starlight Experiments
|
|
122
|
-
Code for the experiments performed in our paper can be found in the file `starlight_experiments.py`. This script uses the `starlight.json` file (also within the example folder) to specify the network topology.
|
|
123
|
-
|
|
124
|
-
### Jupyter Notebook Examples
|
|
125
|
-
The example folder contains several scripts that can be run with jupyter notebook for easy editing and visualization. These examples include:
|
|
126
|
-
* `BB84_eg.ipynb`, which uses the BB84 protocol to distribute secure keys between two quantum nodes
|
|
127
|
-
* `two_node_eg.ipynb`, which performs entanglement generation between two adjacent quantum routers
|
|
128
|
-
* `three_node_eg_ep_es.ipynb`, which performs entanglement generation, purification, and swapping for a linear network of three quantum routers
|
|
119
|
+
Many examples of SeQUeNCe in action can be found in the [example](/example) folder. The example includes jupyter notebook demos, and code used in published papers.
|
|
129
120
|
|
|
130
121
|
## Additional Tools
|
|
131
122
|
|
|
@@ -37,7 +37,7 @@ SeQUeNCe is an open source, discrete-event simulator for quantum networks. As de
|
|
|
37
37
|
These modules can be edited by users to define additional functionality and test protocol schemes, or may be used as-is to test network parameters and topologies.
|
|
38
38
|
|
|
39
39
|
## Installing
|
|
40
|
-
SeQUeNCe requires [Python](https://www.python.org/downloads/) 3.
|
|
40
|
+
SeQUeNCe requires [Python](https://www.python.org/downloads/) 3.11 or later. You can simply install SeQUeNCe using `pip`:
|
|
41
41
|
```
|
|
42
42
|
pip install sequence
|
|
43
43
|
```
|
|
@@ -78,16 +78,7 @@ python gui.py
|
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
## Usage Examples
|
|
81
|
-
Many examples of SeQUeNCe in action can be found in the [example](/example) folder.
|
|
82
|
-
|
|
83
|
-
### Starlight Experiments
|
|
84
|
-
Code for the experiments performed in our paper can be found in the file `starlight_experiments.py`. This script uses the `starlight.json` file (also within the example folder) to specify the network topology.
|
|
85
|
-
|
|
86
|
-
### Jupyter Notebook Examples
|
|
87
|
-
The example folder contains several scripts that can be run with jupyter notebook for easy editing and visualization. These examples include:
|
|
88
|
-
* `BB84_eg.ipynb`, which uses the BB84 protocol to distribute secure keys between two quantum nodes
|
|
89
|
-
* `two_node_eg.ipynb`, which performs entanglement generation between two adjacent quantum routers
|
|
90
|
-
* `three_node_eg_ep_es.ipynb`, which performs entanglement generation, purification, and swapping for a linear network of three quantum routers
|
|
81
|
+
Many examples of SeQUeNCe in action can be found in the [example](/example) folder. The example includes jupyter notebook demos, and code used in published papers.
|
|
91
82
|
|
|
92
83
|
## Additional Tools
|
|
93
84
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sequence"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.2"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name = "Xiaoliang Wu, Joaquin Chung, Alexander Kolar, Alexander Kiefer, Eugene Wang, Tian Zhong, Rajkumar Kettimuthu, Martin Suchara, Robert Hayek, Ansh Singal, Caitao Zhan", email = "czhan@anl.gov" }
|
|
6
6
|
]
|
|
@@ -13,7 +13,7 @@ requires-python = ">=3.11, <3.14"
|
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Programming Language :: Python :: 3.11",
|
|
15
15
|
"Programming Language :: Python :: 3.12",
|
|
16
|
-
"Programming Language :: Python :: 3.13"
|
|
16
|
+
"Programming Language :: Python :: 3.13"
|
|
17
17
|
]
|
|
18
18
|
dynamic = ["dependencies"]
|
|
19
19
|
keywords = ["quantum", "network", "discrete", "event", "simulator"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
__all__ = ['app', 'components', 'entanglement_management', 'kernel', 'network_management', 'qkd', 'resource_management',
|
|
2
2
|
'topology', 'utils', 'message', 'protocol', 'gui', 'qlan']
|
|
3
3
|
|
|
4
|
-
__version__ = '0.8.
|
|
4
|
+
__version__ = '0.8.2'
|
|
5
5
|
|
|
6
6
|
def __dir__():
|
|
7
7
|
return sorted(__all__)
|
|
@@ -11,6 +11,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
11
11
|
from numpy import eye, kron, exp, sqrt
|
|
12
12
|
from scipy.linalg import fractional_matrix_power
|
|
13
13
|
from math import factorial
|
|
14
|
+
import gmpy2
|
|
14
15
|
|
|
15
16
|
if TYPE_CHECKING:
|
|
16
17
|
from ..kernel.timeline import Timeline
|
|
@@ -26,6 +27,9 @@ from ..kernel.process import Process
|
|
|
26
27
|
from ..utils.encoding import time_bin, fock
|
|
27
28
|
from ..utils import log
|
|
28
29
|
|
|
30
|
+
gmpy2.get_context().precision = 80 # 80 bits ~ 24 decimal digits ~ sufficient for 10,000 years of ps timing
|
|
31
|
+
from gmpy2 import mpfr, rint, ceil
|
|
32
|
+
|
|
29
33
|
|
|
30
34
|
class Detector(Entity):
|
|
31
35
|
"""Single photon detector device.
|
|
@@ -40,6 +44,7 @@ class Detector(Entity):
|
|
|
40
44
|
dark_count (float): average number of false positive detections per second.
|
|
41
45
|
count_rate (float): maximum detection rate; defines detector cooldown time.
|
|
42
46
|
time_resolution (int): minimum resolving power of photon arrival time (in ps).
|
|
47
|
+
next_detection_time (int): time of next possible detection event.
|
|
43
48
|
photon_counter (int): counts number of detection events.
|
|
44
49
|
"""
|
|
45
50
|
|
|
@@ -119,9 +124,11 @@ class Detector(Entity):
|
|
|
119
124
|
now = self.timeline.now()
|
|
120
125
|
|
|
121
126
|
if now > self.next_detection_time:
|
|
122
|
-
|
|
127
|
+
index = rint(mpfr(now) / mpfr(self.time_resolution))
|
|
128
|
+
time = int(index) * self.time_resolution
|
|
123
129
|
self.notify({'time': time})
|
|
124
|
-
|
|
130
|
+
period = int(ceil(mpfr("1e12") / mpfr(self.count_rate))) # period in ps
|
|
131
|
+
self.next_detection_time = now + period
|
|
125
132
|
|
|
126
133
|
def notify(self, info: dict[str, Any]):
|
|
127
134
|
"""Custom notify function (calls `trigger` method)."""
|
|
@@ -312,7 +312,7 @@ class Memory(Entity):
|
|
|
312
312
|
Will notify upper entities of expiration via the `pop` interface.
|
|
313
313
|
Will modify the quantum state of the memory.
|
|
314
314
|
"""
|
|
315
|
-
|
|
315
|
+
#log.logger.debug(f'Memory {self.name} has expired at time {self.timeline.now()}')
|
|
316
316
|
if self.is_in_application:
|
|
317
317
|
pass
|
|
318
318
|
|
|
@@ -411,6 +411,7 @@ class Memory(Entity):
|
|
|
411
411
|
self.timeline.remove_event(self.expiration_event)
|
|
412
412
|
|
|
413
413
|
decay_time = self.timeline.now() + int(self.cutoff_ratio * self.coherence_time * 1e12)
|
|
414
|
+
#log.logger.debug(f'Memory {self.name} is set to expire at time {decay_time}')
|
|
414
415
|
process = Process(self, "expire", [])
|
|
415
416
|
event = Event(decay_time, process)
|
|
416
417
|
self.timeline.schedule(event)
|
|
@@ -425,7 +426,7 @@ class Memory(Entity):
|
|
|
425
426
|
Args:
|
|
426
427
|
time (int): new expiration time.
|
|
427
428
|
"""
|
|
428
|
-
|
|
429
|
+
#log.logger.debug(f'Memory expiry is updated')
|
|
429
430
|
time = max(time, self.timeline.now())
|
|
430
431
|
if self.expiration_event is None:
|
|
431
432
|
if time >= self.timeline.now():
|
|
@@ -21,7 +21,7 @@ from ..kernel.process import Process
|
|
|
21
21
|
from ..utils import log
|
|
22
22
|
from ..constants import SPEED_OF_LIGHT, MICROSECOND, SECOND, EPSILON
|
|
23
23
|
|
|
24
|
-
gmpy2.get_context().precision =
|
|
24
|
+
gmpy2.get_context().precision = 80 # 80 bits ~ 24 decimal digits ~ sufficient for 10,000 years of ps timing
|
|
25
25
|
EPSILON_MPFR = gmpy2.mpfr(EPSILON)
|
|
26
26
|
PS_PER_SECOND = gmpy2.mpz(SECOND)
|
|
27
27
|
|
|
@@ -143,7 +143,7 @@ class QuantumChannel(OpticalChannel):
|
|
|
143
143
|
log.logger.info("{} send qubit with state {} to {} by Channel {}".format(
|
|
144
144
|
self.sender.name, qubit.quantum_state, self.receiver, self.name))
|
|
145
145
|
|
|
146
|
-
assert self.delay >= 0 and self.loss
|
|
146
|
+
assert self.delay >= 0 and self.loss <= 1, f"QuantumChannel init() function has not been run for {self.name}"
|
|
147
147
|
assert source == self.sender
|
|
148
148
|
|
|
149
149
|
# remove lowest time bin
|
|
@@ -86,9 +86,9 @@ class SingleHeraldedA(EntanglementGenerationA, QuantumCircuitMixin):
|
|
|
86
86
|
|
|
87
87
|
self._entanglement_succeed()
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
else:
|
|
90
|
+
self._entanglement_fail()
|
|
91
|
+
return False
|
|
92
92
|
|
|
93
93
|
return True
|
|
94
94
|
|
|
@@ -169,7 +169,8 @@ class SingleHeraldedA(EntanglementGenerationA, QuantumCircuitMixin):
|
|
|
169
169
|
process = Process(self, "start", []) # for the second round
|
|
170
170
|
else:
|
|
171
171
|
process = Process(self, "update_memory", [])
|
|
172
|
-
|
|
172
|
+
priority = self.owner.timeline.schedule_counter
|
|
173
|
+
event = Event(future_start_time, process, priority)
|
|
173
174
|
self.owner.timeline.schedule(event)
|
|
174
175
|
self.scheduled_events.append(event)
|
|
175
176
|
|
|
@@ -198,7 +199,8 @@ class SingleHeraldedA(EntanglementGenerationA, QuantumCircuitMixin):
|
|
|
198
199
|
process = Process(self, "start", []) # for the second round
|
|
199
200
|
else:
|
|
200
201
|
process = Process(self, "update_memory", [])
|
|
201
|
-
|
|
202
|
+
priority = self.owner.timeline.schedule_counter
|
|
203
|
+
event = Event(future_start_time, process, priority)
|
|
202
204
|
self.owner.timeline.schedule(event)
|
|
203
205
|
self.scheduled_events.append(event)
|
|
204
206
|
|
|
@@ -4,12 +4,13 @@ This module defines code to support the BBPSSW protocol for entanglement purific
|
|
|
4
4
|
Success results are pre-determined based on network parameters.
|
|
5
5
|
Also defined is the message type used by the BBPSSW code.
|
|
6
6
|
"""
|
|
7
|
+
from __future__ import annotations
|
|
7
8
|
|
|
8
9
|
from typing import List, Tuple
|
|
9
10
|
from typing import TYPE_CHECKING
|
|
10
11
|
|
|
11
12
|
import numpy as np
|
|
12
|
-
|
|
13
|
+
import numpy.typing as npt
|
|
13
14
|
|
|
14
15
|
if TYPE_CHECKING:
|
|
15
16
|
from ...components.memory import Memory
|
|
@@ -39,7 +40,7 @@ class BBPSSW_BDS(BBPSSWProtocol):
|
|
|
39
40
|
is_twirled (bool): whether we twirl the input and output BDS. True: BBPSSW, False: DEJMPS. (default True)
|
|
40
41
|
"""
|
|
41
42
|
|
|
42
|
-
def __init__(self, owner:
|
|
43
|
+
def __init__(self, owner: Node, name: str, kept_memo: Memory, meas_memo: Memory, is_twirled=True):
|
|
43
44
|
"""Constructor for purification protocol.
|
|
44
45
|
|
|
45
46
|
args:
|
|
@@ -53,6 +54,7 @@ class BBPSSW_BDS(BBPSSWProtocol):
|
|
|
53
54
|
|
|
54
55
|
self.is_twirled = is_twirled
|
|
55
56
|
self.ep_matched = False
|
|
57
|
+
self.protocol_type = 'bbpssw_bds'
|
|
56
58
|
|
|
57
59
|
def start(self) -> None:
|
|
58
60
|
"""Method to start entanglement purification.
|
|
@@ -109,7 +111,8 @@ class BBPSSW_BDS(BBPSSWProtocol):
|
|
|
109
111
|
keys = [self.kept_memo.qstate_key, remote_kept_memo.qstate_key]
|
|
110
112
|
self.owner.timeline.quantum_manager.set(keys, new_bds)
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
log.logger.debug(f'Starting BBPSSW from {self.owner} to {self.remote_node_name}')
|
|
115
|
+
message = BBPSSWMessage(BBPSSWMsgType.PURIFICATION_RES, self.remote_protocol_name, meas_res=self.meas_res, protocol_type=self.protocol_type)
|
|
113
116
|
self.owner.send_message(self.remote_node_name, message)
|
|
114
117
|
|
|
115
118
|
def received_message(self, src: str, msg: BBPSSWMessage) -> None:
|
|
@@ -122,18 +125,9 @@ class BBPSSW_BDS(BBPSSWProtocol):
|
|
|
122
125
|
Side Effects:
|
|
123
126
|
Will call `update_resource_manager` method.
|
|
124
127
|
"""
|
|
125
|
-
|
|
126
|
-
# check the status of entanglement
|
|
127
|
-
if self.meas_memo.entangled_memory['node_id'] is None or self.kept_memo.entangled_memory['node_id'] is None:
|
|
128
|
-
log.logger.info(f'No entanglement for {self.meas_memo} or {self.kept_memo}.')
|
|
129
|
-
# when the AC Protocol expires, the purification protocol on the primary node will get removed, but the purification protocol on the non-primary node is still there
|
|
130
|
-
self.owner.protocols.remove(self)
|
|
131
|
-
return
|
|
132
|
-
|
|
133
128
|
if msg.msg_type == BBPSSWMsgType.PURIFICATION_RES:
|
|
134
|
-
|
|
135
129
|
purification_success = (self.meas_res == msg.meas_res)
|
|
136
|
-
log.logger.info(self.owner.name + f
|
|
130
|
+
log.logger.info(self.owner.name + f'received result message, succeeded={purification_success}')
|
|
137
131
|
assert src == self.remote_node_name
|
|
138
132
|
|
|
139
133
|
self.update_resource_manager(self.meas_memo, "RAW")
|
|
@@ -145,7 +139,7 @@ class BBPSSW_BDS(BBPSSWProtocol):
|
|
|
145
139
|
remote_kept_memory.bds_decohere()
|
|
146
140
|
self.kept_memo.bds_decohere()
|
|
147
141
|
self.kept_memo.fidelity = self.kept_memo.get_bds_fidelity()
|
|
148
|
-
self.update_resource_manager(self.kept_memo, state="
|
|
142
|
+
self.update_resource_manager(self.kept_memo, state="PURIFIED")
|
|
149
143
|
else:
|
|
150
144
|
log.logger.info(f'Purification failed because measure results: {self.meas_res}, {msg.meas_res}')
|
|
151
145
|
self.update_resource_manager(self.kept_memo, state="RAW")
|
|
@@ -153,8 +147,8 @@ class BBPSSW_BDS(BBPSSWProtocol):
|
|
|
153
147
|
else:
|
|
154
148
|
raise Exception(f'{msg.msg_type} unknown')
|
|
155
149
|
|
|
156
|
-
def purification_res(self) -> tuple[float,
|
|
157
|
-
"""Method to calculate the correct success
|
|
150
|
+
def purification_res(self) -> tuple[float, npt.NDArray]:
|
|
151
|
+
"""Method to calculate the correct success probability of a purification trial with BDS input.
|
|
158
152
|
|
|
159
153
|
The four BDS density matrix elements of kept entangled pair conditioned on successful purification.
|
|
160
154
|
|
|
@@ -4,7 +4,7 @@ This module defines code to support the BBPSSW protocol for entanglement purific
|
|
|
4
4
|
Success results are pre-determined based on network parameters.
|
|
5
5
|
Also defined is the message type used by the BBPSSW code.
|
|
6
6
|
"""
|
|
7
|
-
|
|
7
|
+
from __future__ import annotations
|
|
8
8
|
from functools import lru_cache
|
|
9
9
|
from typing import TYPE_CHECKING
|
|
10
10
|
|
|
@@ -44,7 +44,7 @@ class BBPSSWCircuit(BBPSSWProtocol):
|
|
|
44
44
|
circuit.cx(0, 1)
|
|
45
45
|
circuit.measure(1)
|
|
46
46
|
|
|
47
|
-
def __init__(self, owner:
|
|
47
|
+
def __init__(self, owner: Node, name: str, kept_memo: Memory, meas_memo: Memory):
|
|
48
48
|
"""Constructor for purification protocol.
|
|
49
49
|
|
|
50
50
|
args:
|
|
@@ -117,7 +117,7 @@ class BBPSSWCircuit(BBPSSWProtocol):
|
|
|
117
117
|
self.update_resource_manager(self.meas_memo, "RAW")
|
|
118
118
|
if self.meas_res == msg.meas_res:
|
|
119
119
|
self.kept_memo.fidelity = self.improved_fidelity(self.kept_memo.fidelity)
|
|
120
|
-
self.update_resource_manager(self.kept_memo, state="
|
|
120
|
+
self.update_resource_manager(self.kept_memo, state="PURIFIED")
|
|
121
121
|
else:
|
|
122
122
|
self.update_resource_manager(self.kept_memo, state="RAW")
|
|
123
123
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
from abc import ABC, abstractmethod
|
|
2
3
|
from enum import Enum, auto
|
|
3
4
|
from typing import TYPE_CHECKING, List, Dict, Type, Optional
|
|
@@ -29,9 +30,10 @@ class BBPSSWMessage(Message):
|
|
|
29
30
|
receiver (str): name of destination protocol instance.
|
|
30
31
|
"""
|
|
31
32
|
|
|
32
|
-
def __init__(self, msg_type: BBPSSWMsgType, receiver: str, meas_res: int,
|
|
33
|
+
def __init__(self, msg_type: BBPSSWMsgType, receiver: str, meas_res: int, protocol_type: str='bbpssw'):
|
|
33
34
|
super().__init__(msg_type, receiver)
|
|
34
35
|
self.meas_res = meas_res
|
|
36
|
+
self.protocol_type = protocol_type
|
|
35
37
|
|
|
36
38
|
def __str__(self):
|
|
37
39
|
return f"\"BBPSSW: type={self.msg_type}, meas_res={self.meas_res}\""
|
|
@@ -41,7 +43,7 @@ class BBPSSWProtocol(EntanglementProtocol, ABC):
|
|
|
41
43
|
_registry: dict[str, type['BBPSSWProtocol']] = {}
|
|
42
44
|
_global_formalism: str = KET_STATE_FORMALISM
|
|
43
45
|
|
|
44
|
-
def __init__(self, owner:
|
|
46
|
+
def __init__(self, owner: Node, name: str, kept_memo: Memory, meas_memo: Memory, **kwargs):
|
|
45
47
|
"""Constructor for purification protocol.
|
|
46
48
|
|
|
47
49
|
args:
|
|
@@ -58,6 +60,7 @@ class BBPSSWProtocol(EntanglementProtocol, ABC):
|
|
|
58
60
|
self.remote_node_name: str = ''
|
|
59
61
|
self.remote_protocol_name: str = ''
|
|
60
62
|
self.remote_memories: list[str] = []
|
|
63
|
+
self.protocol_type = 'bbpssw'
|
|
61
64
|
self.meas_res = None
|
|
62
65
|
if self.meas_memo is None:
|
|
63
66
|
self.memories.pop()
|
|
@@ -141,7 +141,7 @@ class EntanglementSwappingA(EntanglementProtocol):
|
|
|
141
141
|
elif node == self.right_memo.entangled_memory["node_id"]:
|
|
142
142
|
self.right_protocol_name = protocol
|
|
143
143
|
else:
|
|
144
|
-
raise Exception("Cannot pair protocol {} with {}"
|
|
144
|
+
raise Exception(f"Cannot pair protocol {self.name} with {protocol}")
|
|
145
145
|
|
|
146
146
|
def start(self) -> None:
|
|
147
147
|
"""Method to start entanglement swapping protocol.
|
|
@@ -12,6 +12,7 @@ class Process:
|
|
|
12
12
|
|
|
13
13
|
Attributes:
|
|
14
14
|
owner (Any): the object of process.
|
|
15
|
+
number (int): the process number.
|
|
15
16
|
activation (str): the function name of object.
|
|
16
17
|
activation_args (list[Any]): the (non-keyword) arguments of object's function.
|
|
17
18
|
activation_kwargs (dict[Any, Any]): the keyword arguments of object's function.
|
|
@@ -19,6 +20,7 @@ class Process:
|
|
|
19
20
|
|
|
20
21
|
def __init__(self, owner: Any, activation_method: str, activation_args: list[Any], activation_kwargs: dict[Any, Any] = {}):
|
|
21
22
|
self.owner = owner
|
|
23
|
+
self.number = None
|
|
22
24
|
self.activation = activation_method
|
|
23
25
|
self.activation_args = activation_args
|
|
24
26
|
self.activation_kwargs = activation_kwargs
|