-
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
Konrad Jałowiecki
committed
Mar 22, 2024
1 parent
e9ca12e
commit 420de9b
Showing
3 changed files
with
266 additions
and
2 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,2 +1,99 @@ | ||
# hqar | ||
Hierarchical Quantum Algorithms Representation | ||
# HQAR | ||
Hierarchical Quantum Algorithms Representation is an open format for representing | ||
quantum algorithms, optimized for usage in quantum resource estimation (QRE). | ||
|
||
HQAR comprises: | ||
|
||
- Definition of data format, formalized as a JSON schema. | ||
- A Python library for validation of quantum programs written in HQAR format using [Pydantic](https://docs.pydantic.dev/). | ||
|
||
|
||
## Installation | ||
|
||
Using HQAR data format does not require installation - you can easily write quantum | ||
programs in YAML or JSON. | ||
|
||
To install HQAR Python package, clone this repository and install it as usual with `pip`: | ||
|
||
```bash | ||
# Clone HQAR repo (you can use HTTP link as well) | ||
git clone git@github.com:PsiQ/hqar.git | ||
cd hqar | ||
pip install . | ||
``` | ||
|
||
## HQAR format | ||
|
||
Consider the following hierarchical dag a hypothetical quantum program: | ||
|
||
![program example](example_routine.svg) | ||
|
||
It can be succinctly written in HQAR format as: | ||
|
||
|
||
```yaml | ||
version: v1 | ||
program: | ||
name: my_algorithm | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 2 | ||
- direction: input | ||
name: in_1 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 4 | ||
children: | ||
- name: subroutine_1 | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 3 | ||
- name: subroutine_2 | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 1 | ||
- direction: output | ||
name: out_1 | ||
size: 1 | ||
- name: merge | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 1 | ||
- direction: input | ||
name: in_1 | ||
size: 1 | ||
- direction: input | ||
name: in_2 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 4 | ||
connections: | ||
- source: in_0 | ||
target: subroutine_1.in_0 | ||
- source: in_1 | ||
target: subroutine_2.in_0 | ||
- source: subroutine_1.out_0 | ||
target: merge.in_2 | ||
- source: subroutine_2.out_0 | ||
target: merge.in_0 | ||
- source: subroutine_2.out_1 | ||
target: merge.in_1 | ||
- source: merge.out_0 | ||
target: out_0 | ||
``` | ||
For full description of HQAR format, check our [docs](https://example.com). | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,60 @@ | ||
version: v1 | ||
program: | ||
name: my_algorithm | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 2 | ||
- direction: input | ||
name: in_1 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 4 | ||
children: | ||
- name: subroutine_1 | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 3 | ||
- name: subroutine_2 | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 1 | ||
- direction: output | ||
name: out_1 | ||
size: 1 | ||
- name: merge | ||
ports: | ||
- direction: input | ||
name: in_0 | ||
size: 1 | ||
- direction: input | ||
name: in_1 | ||
size: 1 | ||
- direction: input | ||
name: in_2 | ||
size: 2 | ||
- direction: output | ||
name: out_0 | ||
size: 4 | ||
connections: | ||
- source: in_0 | ||
target: subroutine_1.in_0 | ||
- source: in_1 | ||
target: subroutine_2.in_0 | ||
- source: subroutine_1.out_0 | ||
target: merge.in_2 | ||
- source: subroutine_2.out_0 | ||
target: merge.in_0 | ||
- source: subroutine_2.out_1 | ||
target: merge.in_1 | ||
- source: merge.out_0 | ||
target: out_0 |