Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
32 changes: 0 additions & 32 deletions examples/stack/bqc/README.md

This file was deleted.

4 changes: 1 addition & 3 deletions examples/stack/bqc/example_bqc_nv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from netqasm.sdk.qubit import Qubit

from pydynaa import EventExpression
from squidasm.run.stack.config import NVQDeviceConfig, StackNetworkConfig
from squidasm.run.stack.config import StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.csocket import ClassicalSocket
Expand Down Expand Up @@ -244,8 +244,6 @@ def trap_round(

cfg_file = os.path.join(os.path.dirname(__file__), "config_nv.yaml")
cfg = StackNetworkConfig.from_file(cfg_file)
cfg.stacks[0].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg.stacks[1].qdevice_cfg = NVQDeviceConfig.perfect_config()

# computation_round(cfg, num_times, alpha=PI_OVER_2, beta=PI_OVER_2)
trap_round(cfg=cfg, num_times=num_times, dummy=2)
Binary file modified examples/stack/bqc/fig/5_6_generic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/stack/bqc/fig/trap_dummy_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/stack/bqc/fig/trap_dummy_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
StackConfig,
StackNetworkConfig,
)
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.program import Program, ProgramContext, ProgramMeta

Expand Down Expand Up @@ -186,8 +185,8 @@ def post_create(conn, q, pair):


if __name__ == "__main__":
LogManager.set_log_level("WARNING")
# LogManager.log_to_file(os.path.join(os.path.dirname(__file__), "debug.log"))
LogManager.set_log_level("DEBUG")
LogManager.log_to_file(os.path.join(os.path.dirname(__file__), "debug.log"))

num_times = 1

Expand All @@ -208,6 +207,6 @@ def post_create(conn, q, pair):
client_program = ClientProgram(num_repetitions=2)
server_program = ServerProgram(num_repetitions=2)

results = run(cfg, {"client": client_program, "server": server_program}, num_times)
# results = run(cfg, {"client": client_program, "server": server_program}, num_times)

print(results)
# print(results)
75 changes: 75 additions & 0 deletions examples/stack/qne_bqc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

## Prerequisites
`squidasm` relies on [NetSquid](https://netsquid.org/).
To install NetSquid, an account is needed. See the NetSquid website how this is done.

### Installation
Clone the squidasm repostitory and checkout the `qne-hardware` branch:
```
git clone https://github.com/QuTech-Delft/squidasm
cd squidasm
git checkout qne-hardware
```

Make sure you have two environment variables set with your NetSquid username and password.
These are needed for the installation of squidasm.
```
export NETSQUIDPYPI_USER=<username>
export NETSQUIDPYPI_PWD=<password>
```

Install `squidasm`:
```
make install-tests
```

After installation, the simulations can be run as described below.

## BQC application

We consider a simple BQC application consisting of a client and a server.
A server performs an Effective Computation (EC) on behalf of the client.

In the so-called *computation rounds*, the client makes the server perform the EC.
In the *trap rounds*, the client sends dummy information to the server just to check
if the server is behaving honestly.

### Effective Computation (EC)
Effective Computation (**EC**): `H Rz[beta] H Rz[alpha] |+>` followed by a measurement in the Z-basis.
(Exact prepared state: `Z^(m1) H Rz[beta] H Rz[alpha] |+>` )
![](fig/5_6_effective.png)

### EC implementation using Remote State Preparation and Measurement Based Quantum Computation
The following circuit produces equivalent results to the EC.
It is a 'blind version' of the EC.
![](fig/5_6_generic.png)

Blue values are sent from server to client.
Red values are computed by the client and sent to the server.

### Inputs
- `alpha`: parameter of EC
- `beta`: parameter of EC
- `theta1`: randomly chosen by client from `[0, pi/4, ..., 7pi/4]`. Does not affect the EC.
- `theta2`: randomly chosen by client from `[0, pi/4, ..., 7pi/4]`. Does not affect the EC.

### Expected measurement outcomes
- `p1`: uniformly random
- `p2`: uniformly random
- `m1`: uniformly random
- `m2`: outcome of **EC**. Expected statistics depend on alpha and beta.


## Simulation scripts
Examples of simulation code are in the `examples/stack` directory. The `examples/stack/qne_bqc` directory in there can be used to do simulations for the QNE parameter estimation.
It contains BQC application code file and some configuration files. `example_bqc_nv.py` is the full BQC application, including trap rounds and
computation of the error rate. Simply running the file with

```
python examples/stack/qne_bqc/example_bqc_nv.py
```
will run the simulation. The data it produces is simply printed or ignored.
One can simply add code to e.g. store the data to a file or to create plots from them.

The `config_nv.yaml` file contains configuration parameters for the hardware of the nodes and the entanglement link.
Check https://docs.netsquid.org/snippets/netsquid-nv/modules/magic_distributor.html#netsquid_nv.magic_distributor.NVSingleClickMagicDistributor for information about the link parameters, and the comments in the `config_nv.yaml` file itself for the node parameters.
83 changes: 83 additions & 0 deletions examples/stack/qne_bqc/config_nv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
qdevice_cfg: &qdevice_cfg
# number of qubits per NV
num_qubits: 2

# initialization error of the electron spin
electron_init_depolar_prob: 0.05

# error of the single-qubit gate
electron_single_qubit_depolar_prob: 0.0

# measurement errors (prob_error_X is the probability that outcome X is flipped to 1 - X)
prob_error_0: 0.05
prob_error_1: 0.005

# initialization error of the carbon nuclear spin
carbon_init_depolar_prob: 0.05

# error of the Z-rotation gate on the carbon nuclear spin
carbon_z_rot_depolar_prob: 0.001

# error of the native NV two-qubit gate
ec_gate_depolar_prob: 0.008

# delta_w and tau_decay
delta_w: 0
tau_decay: 1.0

# coherence times
electron_T1: 1_000_000_000
electron_T2: 300_000_000
carbon_T1: 150_000_000_000
carbon_T2: 1_500_000_000

# gate execution times
carbon_init: 310_000
carbon_rot_x: 500_000
carbon_rot_y: 500_000
carbon_rot_z: 500_000
electron_init: 2_000
electron_rot_x: 5_000
electron_rot_y: 5_000
electron_rot_z: 5_000
ec_controlled_dir_x: 500_000
ec_controlled_dir_y: 500_000
measure: 3_700

stacks:
- name: client
qdevice_typ: nv
qdevice_cfg:
<<: *qdevice_cfg
- name: server
qdevice_typ: nv
qdevice_cfg:
<<: *qdevice_cfg

link_cfg: &link_cfg
cycle_time: 5_000
alpha_A: 0.1
alpha_B: 0.1
length_A: 0.005
length_B: 0.005
p_loss_init_A: null
p_loss_length_A: null
speed_of_light_A: null
p_loss_init_B: null
p_loss_length_B: null
speed_of_light_B: null
dark_count_probability: null
detector_efficiency: null
visibility: null
num_resolving: null
std_electron_electron_phase_drift: null
coherent_phase: null
p_double_exc: null
p_fail_class_corr: null

links:
- stack1: client
stack2: server
typ: nv
cfg:
<<: *link_cfg
Loading