diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..3cdbcac --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 \ No newline at end of file diff --git a/abrax/compiler.py b/abrax/compiler.py index 87ca24a..00bf62c 100644 --- a/abrax/compiler.py +++ b/abrax/compiler.py @@ -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() diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index cf7d71b..b4bffb3 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -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, } ), ], } ); diff --git a/docs/src/content/docs/guides/example.md b/docs/src/content/docs/guides/example.md deleted file mode 100644 index ebd0f3b..0000000 --- a/docs/src/content/docs/guides/example.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Example Guide -description: A guide in my new Starlight docs site. ---- - -Guides lead a user through a specific task they want to accomplish, often with a sequence of steps. -Writing a good guide requires thinking about what your users are trying to do. - -## Further reading - -- Read [about how-to guides](https://diataxis.fr/how-to-guides/) in the Diátaxis framework diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 117179d..27d44fa 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -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 - - - - Edit `src/content/docs/index.mdx` to see this page change. - - - Add Markdown or MDX files to `src/content/docs` to create new pages. - - - Edit your `sidebar` and other config in `astro.config.mjs`. - - - Learn more in [the Starlight Docs](https://starlight.astro.build/). - - +
+
+

Interop between Quantum Circuits in different languages

+

Abraxas is a peudo Intermediate Representation (IR) that allows for the simple interop between quantum circuits in different frameworks with low overhead

+
+
+ Abraxas Logo +
+
diff --git a/docs/src/content/docs/prime.mdx b/docs/src/content/docs/prime.mdx new file mode 100644 index 0000000..da31a95 --- /dev/null +++ b/docs/src/content/docs/prime.mdx @@ -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. + + + + +```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 + + + + +```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 + \ No newline at end of file diff --git a/docs/src/content/docs/reference/example.md b/docs/src/content/docs/reference/example.md deleted file mode 100644 index 0224f09..0000000 --- a/docs/src/content/docs/reference/example.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Example Reference -description: A reference page in my new Starlight docs site. ---- - -Reference pages are ideal for outlining how things work in terse and clear terms. -Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what you're documenting. - -## Further reading - -- Read [about reference](https://diataxis.fr/reference/) in the Diátaxis framework diff --git a/docs/src/content/docs/uses.md b/docs/src/content/docs/uses.md new file mode 100644 index 0000000..948b4b3 --- /dev/null +++ b/docs/src/content/docs/uses.md @@ -0,0 +1,8 @@ +--- +title: Common Uses +description: Common uses of abraxas +sidebar: + order: 5 +--- + +Hi \ No newline at end of file diff --git a/docs/src/content/docs/welcome.md b/docs/src/content/docs/welcome.md new file mode 100644 index 0000000..291b46e --- /dev/null +++ b/docs/src/content/docs/welcome.md @@ -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 \ No newline at end of file diff --git a/docs/tsconfig.json b/docs/tsconfig.json deleted file mode 100644 index 3fd7ae6..0000000 --- a/docs/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strictest" -} \ No newline at end of file