Skip to content

Commit

Permalink
Add good-enough initial README
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jałowiecki committed Mar 22, 2024
1 parent e9ca12e commit 420de9b
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 2 deletions.
101 changes: 99 additions & 2 deletions README.md
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).
107 changes: 107 additions & 0 deletions example_routine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions example_routine.yaml
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

0 comments on commit 420de9b

Please sign in to comment.