Skip to content

Commit

Permalink
init docs
Browse files Browse the repository at this point in the history
  • Loading branch information
plutoniumm committed Feb 29, 2024
1 parent 9c5a1cf commit 0ef7375
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 66 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy to GitHub Pages

on:
push:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4
- name: Install, build, and upload your site
uses: withastro/action@v2

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
14 changes: 14 additions & 0 deletions abrax/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ def compile_pennylane(qfunc) -> str:
tape = qfunc.qtape
num_qubits = len(tape.wires.tolist())
matrix = [[] for _ in range(num_qubits)]

ops2 = tape.operations
# everytime there is a Tofolli, remove it and add 2 CNOTs a,b | b,c
for i in range(len(ops2)):
if ops2[i].name == 'Toffoli':
a, b, c = ops2[i].wires.tolist()
tape.operations[i] = tape.operations[i]._replace(
name='CNOT', wires=[a, b]
)
tape.operations.insert(
i + 1, tape.operations[i]._replace(name='CNOT', wires=[b, c])
)


for i in tape.operations:
gate = i.name
qubits = i.wires.tolist()
Expand Down
29 changes: 15 additions & 14 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

const sidebar = [
{
label: 'Guides',
items: [
{ label: 'Welcome', link: '/welcome' },
{ label: 'toPrime', link: '/prime' },
],
},
];


// https://astro.build/config
export default defineConfig( {
site: 'https://plutoniumm.github.io',
base: import.meta.env.DEV ? '/' : '/abraxas/',
integrations: [
starlight( {
title: 'My Docs',
title: 'Abraxas',
social: {
github: 'https://github.com/plutoniumm/abraxas',
},
sidebar: [
{
label: 'Guides',
items: [
// Each item here is one entry in the navigation menu.
{ label: 'Example Guide', link: '/guides/example/' },
],
},
{
label: 'Reference',
autogenerate: { directory: 'reference' },
},
],
sidebar,
} ),
],
} );
11 changes: 0 additions & 11 deletions docs/src/content/docs/guides/example.md

This file was deleted.

43 changes: 16 additions & 27 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
---
title: Welcome to Starlight
description: Get started building your docs site with Starlight.
title: Welcome to Abraxas
description: An IR for Quantum Circuits
template: splash
hero:
tagline: Congrats on setting up a new Starlight project!
image:
file: ../../assets/houston.webp
tagline: Interop between Quantum Circuits in different languages with low overhead
actions:
- text: Example Guide
link: /guides/example/
- text: Read Docs
link: /welcome
icon: right-arrow
variant: primary
- text: Read the Starlight docs
link: https://starlight.astro.build
- text: Contribute to Abraxas
link: https://github.com/plutoniumm/abraxas
icon: external
---

import { Card, CardGrid } from '@astrojs/starlight/components';

## Next steps

<CardGrid stagger>
<Card title="Update content" icon="pencil">
Edit `src/content/docs/index.mdx` to see this page change.
</Card>
<Card title="Add new content" icon="add-document">
Add Markdown or MDX files to `src/content/docs` to create new pages.
</Card>
<Card title="Configure your site" icon="setting">
Edit your `sidebar` and other config in `astro.config.mjs`.
</Card>
<Card title="Read the docs" icon="open-book">
Learn more in [the Starlight Docs](https://starlight.astro.build/).
</Card>
</CardGrid>
<div style="display: flex">
<div style="flex: 1; margin-right: 20px">
<h3>Interop between Quantum Circuits in different languages</h3>
<p>Abraxas is a peudo <a href="https://en.wikipedia.org/wiki/Intermediate_representation">Intermediate Representation (IR)</a> that allows for the simple interop between quantum circuits in different frameworks with low overhead</p>
</div>
<div style="flex: 1; margin-left: 20px">
<img src="/favicon.svg" alt="Abraxas Logo" width="150px" height="150px"/>
</div>
</div>
74 changes: 74 additions & 0 deletions docs/src/content/docs/prime.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: toPrime
description: Convert a quantum circuit to prime string
sidebar:
order: 2
badge: New
---

import { Aside } from '@astrojs/starlight/components';

## Convert toPrime String
The Prime String is the intermediate representation of the quantum circuit. So before doing anything cross language, you need to convert the circuit to prime string.

> Make sure to decompose it since only the base gates are supported!
### Qiskit
Let's say we have a standard circuit `EfficientSU2` from Qiskit. We can convert it to prime string using `toPrime` function.

<Aside type="tip">
Make sure to run `.decompose` to make sure that the circuit is in basic gates.

```py
qc = qc.decompose()
```
</Aside>


```python
from qiskit.circuit.library import EfficientSU2
from abrax import toPrime

qc = EfficientSU2(3, reps=1).decompose()
string = toPrime(qc)

# IS THE SAME AS
# -0 ry(θ[0]) rz(θ[3]) cx(1) ry(θ[6])
# -1 ry(θ[1]) rz(θ[4]) cx(2) ry(θ[7])
# -2 ry(θ[2]) rz(θ[5]) ry(θ[8]) rz(θ[11])
```

### PennyLane
<Aside type="caution" title="Watch out!">
Unfortunatelly, PennyLane does not let us inspect a circuit without parameters, therefore pennylane cannot be used fully for variational circuits. Only static circuits can be converted to prime string
</Aside>

<Aside type="tip">
Make sure to run `compile()` to make sure that the circuit is in basic gates.

```py
qfunc = qml.compile(qfunc)
```
</Aside>

```python
import pennylane as qml
dev = qml.device('default.qubit', wires=2)

@qml.qnode(dev)
def circuit(weights, f=None):
qml.QAOAEmbedding(features=f, weights=weights, wires=range(2))
return qml.expval(qml.PauliZ(0))

features = [1., 2.]
layer1 = [0.1, -0.3, 1.5]
layer2 = [3.1, 0.2, -2.8]
weights = [layer1, layer2]

print(circuit(weights, f=features))
```

### CudaQuantum
<Aside type="danger">
CudaQuantum is not yet supported
</Aside>
11 changes: 0 additions & 11 deletions docs/src/content/docs/reference/example.md

This file was deleted.

8 changes: 8 additions & 0 deletions docs/src/content/docs/uses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Common Uses
description: Common uses of abraxas
sidebar:
order: 5
---

Hi
15 changes: 15 additions & 0 deletions docs/src/content/docs/welcome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Get Started
description: A starter guide for abraxas
sidebar:
order: 1
---

Abraxas is itself zero-dependency, but you will need to install the dependencies for the specific tasks you want to run. For example, if you want to use the `qiskit` with abraxas you will need qiskit too!

```sh
pip install abrax
```

## Caveats
We usually intend to keep things simple and easy to use, and therefore only simple gates and functions will be supported. If you need to use a more complex gate, you will need to decompose it first OR do the circuit conversion manually
3 changes: 0 additions & 3 deletions docs/tsconfig.json

This file was deleted.

0 comments on commit 0ef7375

Please sign in to comment.