|
@@ -1,28 +1,39 @@ |
|
|
# ABP server |
|
|
|
|
|
|
|
|
|
|
|
This server does a few things: |
|
|
|
|
|
|
|
|
|
|
|
- Keeps a graph state in memory using a data structure that is compatible with `abp` |
|
|
|
|
|
- Serves a JSON representation of that object |
|
|
|
|
|
- Accepts updates to that object via POST requests |
|
|
|
|
|
- Displays a 3D representation of the state |
|
|
|
|
|
- Randomly updates the state every five seconds |
|
|
|
|
|
|
|
|
# Graph state server |
|
|
|
|
|
Graph states are a way of efficiently representing the state of a system of qubits. This tool simulates the behaviour of the graph state and shows an interactive 3D representation of the state. Interaction with the simulation is done either by clicking on things in the web browser or through an API. |
|
|
|
|
|
|
|
|
## Using the interface |
|
|
## Using the interface |
|
|
Sessions are identified by a UUID such as `oranges-arkansas-mexico-fish`. You can share this URL with other people to share your screen and edit collaboratively. |
|
|
|
|
|
|
|
|
The state is initialized as a blank canvas without any qubits. |
|
|
|
|
|
|
|
|
- Click on the grid to make a new node |
|
|
|
|
|
- Ctrl-click a node to act a Hadamard gate |
|
|
|
|
|
- Select a node, then shift-click another node to act a CZ gate |
|
|
|
|
|
|
|
|
- Click on the grid to make a new qubit |
|
|
|
|
|
- Hold Ctrl and click on a qubit to act a Hadamard gate |
|
|
|
|
|
- Click on a qubit to view its properties |
|
|
|
|
|
- Select a qubit, then shift-click another node to act a CZ gate |
|
|
- Press space to rotate the grid |
|
|
- Press space to rotate the grid |
|
|
|
|
|
|
|
|
|
|
|
Arbitrary 3D structures can be constructed by rotating the grid. |
|
|
|
|
|
|
|
|
|
|
|
The URL contains a unique ID such as `oranges-arkansas-mexico-fish`. You can share this URL with other people to share your screen and edit collaboratively. |
|
|
|
|
|
|
|
|
## Python package |
|
|
## Python package |
|
|
The underlying graph state simulator is based on Anders' and Briegel's method. Full docs for the Python package are [here](https://peteshadbolt.co.uk/static/abp/). |
|
|
The underlying graph state simulator is based on Anders' and Briegel's method. Full docs for the Python package are [here](https://peteshadbolt.co.uk/static/abp/). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## API |
|
|
## API |
|
|
|
|
|
|
|
|
We expose an API so that you can programmatically read and write states to/from the server and simulate mouse clicks. |
|
|
|
|
|
|
|
|
Here's a complete example of sending a state from Python to the server: |
|
|
|
|
|
|
|
|
|
|
|
:::python |
|
|
|
|
|
import requests, json, abp |
|
|
|
|
|
|
|
|
|
|
|
# Make a new graph and position the nodes |
|
|
|
|
|
g = abp.NXGraphState(range(10)) |
|
|
|
|
|
g.layout() |
|
|
|
|
|
|
|
|
|
|
|
# Serialize |
|
|
|
|
|
data = json.dumps(test_graph().to_json()) |
|
|
|
|
|
|
|
|
|
|
|
# Post to the server |
|
|
|
|
|
URL = "https://abv.peteshadbolt.co.uk/oranges-arkansas-mexico-fish" |
|
|
|
|
|
requests.post("{}/graph".format(URL), data=data) |
|
|
|
|
|
|
|
|
### Endpoints |
|
|
### Endpoints |
|
|
|
|
|
|
|
@@ -37,7 +48,7 @@ We expose an API so that you can programmatically read and write states to/from |
|
|
|
|
|
|
|
|
### Data format |
|
|
### Data format |
|
|
|
|
|
|
|
|
If you do an HTTPS GET against `/<uuid>/graph`, you will receive some JSON. |
|
|
|
|
|
|
|
|
An HTTP GET to `/<uuid>/graph` will return some JSON. |
|
|
|
|
|
|
|
|
:::bash |
|
|
:::bash |
|
|
$ curl https://abv.peteshadbolt.co.uk/<uuid>/graph |
|
|
$ curl https://abv.peteshadbolt.co.uk/<uuid>/graph |
|
|