-
Notifications
You must be signed in to change notification settings - Fork 3
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
14 changed files
with
79 additions
and
79 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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
# QART | ||
Quantum Algorithms Represented Topologically (QART) is an open format for representing | ||
# QREF | ||
Quantum Resource Estimation Format (QREF) is an open format for representing | ||
quantum algorithms, optimized for usage in quantum resource estimation (QRE). | ||
|
||
QART comprises: | ||
QREF comprises: | ||
|
||
- Definition of data format, formalized as a JSON schema. | ||
- A Python library for validation of quantum programs written in QART format using [Pydantic](https://docs.pydantic.dev/). | ||
- Rudimentary visualization tool `qart-render`. | ||
- A Python library for validation of quantum programs written in QREF format using [Pydantic](https://docs.pydantic.dev/). | ||
- Rudimentary visualization tool `qref-render`. | ||
|
||
## Installation | ||
|
||
Using QART data format does not require installation - you can easily write quantum | ||
Using QREF data format does not require installation - you can easily write quantum | ||
programs in YAML or JSON. | ||
|
||
To install QART Python package, clone this repository and install it as usual with `pip`: | ||
To install QREF Python package, clone this repository and install it as usual with `pip`: | ||
|
||
```bash | ||
# Clone QART repo (you can use HTTP link as well) | ||
git clone [email protected]:PsiQ/qart.git | ||
cd qart | ||
# Clone QREF repo (you can use HTTP link as well) | ||
git clone [email protected]:PsiQ/qref.git | ||
cd qref | ||
pip install . | ||
``` | ||
|
||
## QART format | ||
## QREF format | ||
|
||
QART format represents quantum programs as a hierarchical directed acyclic graphs (DAGs). | ||
QREF format represents quantum programs as a hierarchical directed acyclic graphs (DAGs). | ||
That's a mouthful, so let us unpack what it means: | ||
|
||
- *hierarchical*: each node can contain subgraphs, i.e. routines can be nested inside | ||
|
@@ -36,7 +36,7 @@ Consider the following hierarchical DAG of a hypothetical quantum program: | |
|
||
![program example](example_routine.svg) | ||
|
||
It can be succinctly written in QART format as: | ||
It can be succinctly written in QREF format as: | ||
|
||
|
||
```yaml | ||
|
@@ -103,18 +103,18 @@ program: | |
``` | ||
For full description of QART format, check our [docs](https://example.com). | ||
For full description of QREF format, check our [docs](https://example.com). | ||
## Using QART package | ||
## Using QREF package | ||
### Using JSON schema for validating data in QART format | ||
### Using JSON schema for validating data in QREF format | ||
JSON schema for QART format can be obtained by calling `generate_program_schema` function. | ||
JSON schema for QREF format can be obtained by calling `generate_program_schema` function. | ||
Such schema can be then used for validating user's input, e.g. using `jsonschema` package: | ||
|
||
```python | ||
from jsonschema import validate | ||
from qart import generate_program_schema | ||
from qref import generate_program_schema | ||
# Hypothetical function loading your data as native Python dictionary. | ||
data = load_some_program() | ||
|
@@ -126,12 +126,12 @@ validate(schema, data) | |
|
||
### Validation using Pydantic models | ||
|
||
If you are familiar with Pydantic, you might find it easier to work with QART Pydantic | ||
If you are familiar with Pydantic, you might find it easier to work with QREF Pydantic | ||
models instead of interacting with JSON schema directly. In the example below, we create | ||
an instance of `SchemaV1` model from validated data stored in QART format: | ||
an instance of `SchemaV1` model from validated data stored in QREF format: | ||
|
||
```python | ||
from qart import SchemaV1 | ||
from qref import SchemaV1 | ||
data = load_some_program() | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
::: qart.experimental.rendering | ||
::: qref.experimental.rendering | ||
handler: python |
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,4 +1,4 @@ | ||
::: qart | ||
::: qref | ||
handler: python | ||
options: | ||
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 |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
|
||
## Installation | ||
|
||
To install QART Python package, clone QARt repository and install it as usual with `pip`: | ||
To install QREF Python package, clone QREF repository and install it as usual with `pip`: | ||
|
||
```bash | ||
# Clone QART repo (you can use HTTP link as well) | ||
git clone [email protected]:PsiQ/qart.git | ||
cd qart | ||
# Clone QREF repo (you can use HTTP link as well) | ||
git clone [email protected]:PsiQ/qref.git | ||
cd qref | ||
pip install . | ||
``` | ||
|
||
|
@@ -17,16 +17,16 @@ installation. | |
## Usage | ||
|
||
|
||
### Using JSON schema for validating data in QART format | ||
### Using JSON schema for validating data in QREF format | ||
|
||
JSON schema for QART format can be obtained by calling | ||
[`generate_program_schema`][qart.generate_program_schema] function. | ||
JSON schema for QREF format can be obtained by calling | ||
[`generate_program_schema`][qref.generate_program_schema] function. | ||
Such schema can be then used for validating user's input, e.g. using | ||
[`jsonschema`](https://pypi.org/project/jsonschema/) package: | ||
|
||
```python | ||
from jsonschema import validate | ||
from qart import generate_program_schema | ||
from qref import generate_program_schema | ||
|
||
# Hypothetical function loading your data as native Python dictionary. | ||
data = load_some_program() | ||
|
@@ -39,40 +39,40 @@ validate(schema, data) | |
### Validation using Pydantic models | ||
|
||
If you are familiar with [Pydantic](https://docs.pydantic.dev/latest/), you might find | ||
it easier to work with QART Pydantic models instead of interacting with JSON schema directly. | ||
In the example below, we create an instance of [`SchemaV1`][qart.SchemaV1] model from | ||
validated data stored in QART format: | ||
it easier to work with QREF Pydantic models instead of interacting with JSON schema directly. | ||
In the example below, we create an instance of [`SchemaV1`][qref.SchemaV1] model from | ||
validated data stored in QREF format: | ||
|
||
```python | ||
from qart import SchemaV1 | ||
from qref import SchemaV1 | ||
|
||
data = load_some_program() | ||
|
||
# This will raise if data is not valid | ||
program = SchemaV1.model_validate(data) | ||
``` | ||
|
||
### Rendering QART files using `qart-render` (experimental) | ||
### Rendering QREF files using `qref-render` (experimental) | ||
|
||
!!! Warning | ||
|
||
This feature is considered experimental and may occassionally produce | ||
incorrect results. | ||
|
||
|
||
QART comes with a CLI tool for rendering hierarchical graphs of quantum | ||
QREF comes with a CLI tool for rendering hierarchical graphs of quantum | ||
algorithms. To render an algorithm stored in a file named `my_program.yaml` into a | ||
file `my_program_graph.svg` run: | ||
|
||
```bash | ||
qart-render my_program.yaml my_program_graph.svg | ||
qref-render my_program.yaml my_program_graph.svg | ||
``` | ||
|
||
The `qart-render` tool supports `yaml` and `json` input formats, and all | ||
The `qref-render` tool supports `yaml` and `json` input formats, and all | ||
output formats supported by [graphviz](https://graphviz.org/). | ||
|
||
If, instead of using CLI, you'd like to invoke QART's rendering capabilities | ||
from Python script, you can look at [qart.experimental.rendering][qart.experimental.rendering] | ||
module which exposes experimental API for performing the same task as `qart-render`. | ||
If, instead of using CLI, you'd like to invoke QREF's rendering capabilities | ||
from Python script, you can look at [qref.experimental.rendering][qref.experimental.rendering] | ||
module which exposes experimental API for performing the same task as `qref-render`. | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Public API of QART.""" | ||
"""Public API of QREF.""" | ||
|
||
from typing import Any | ||
|
||
|
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.