Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the powering modifier of OpenQASM 3.0 #27

Open
2 tasks
burgholzer opened this issue Dec 16, 2021 · 0 comments
Open
2 tasks

Support for the powering modifier of OpenQASM 3.0 #27

burgholzer opened this issue Dec 16, 2021 · 0 comments
Labels
Core Anything related to the Core library and IR enhancement New feature or request good first issue Good for newcomers

Comments

@burgholzer
Copy link
Member

burgholzer commented Dec 16, 2021

The new OpenQASM standard introduces gate modifiers in order to more efficiently describe quantum circuits. Any modifier mod can be applied to a gate g via mod @ g. For more details, see Section 4.2 in https://arxiv.org/pdf/2104.14722.pdf or the Live Specification.

The powering modifier pow(r) can be used to represent the r-th power of any gate g via pow(r) @ g, where r can either be an integer or a floating point number.

The case where r is a floating point number needs to be handled by computing the principal logarithm of the unitary that represents g. This might be tricky in general.

The case where r is an integer can be naively solved by repeatedly applying g. If r <0, pow(r) @ g can be translated to inv @ pow(-r) @ g. Several simplification might be possible here, e.g., the powers of phase gates can easily be computed by appropriately scaling the respective parameter. In its simplest form pow(2) @ s = z.

At the very least, support for the case where r is an integer shall be provided which provides much greater flexibility for describing circuits in a standardized way.

Tasks

@burgholzer burgholzer added enhancement New feature or request good first issue Good for newcomers labels Dec 16, 2021
burgholzer pushed a commit that referenced this issue Jun 2, 2023
Bumps [extern/googletest](https://github.com/google/googletest) from `bea621c` to `7735334`.
- [Release notes](https://github.com/google/googletest/releases)
- [Commits](google/googletest@bea621c...7735334)

---
updated-dependencies:
- dependency-name: extern/googletest
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@burgholzer burgholzer added the Core Anything related to the Core library and IR label Jun 15, 2023
@burgholzer burgholzer added this to the OpenQASM 3.0 Support milestone Jun 15, 2023
burgholzer added a commit that referenced this issue Dec 13, 2023
This PR replaces the existing OpenQASM 2.0 parser with a new OpenQASM
3.0 parser.

The new parser now builds a syntax tree, where type checking, constant
evaluation, and translation to the Quantum circuit.

The parser can handle the following new features:

### New Syntax

New syntax for declaring bits, qubit, measure operations. The old syntax
(`creg`, `qreg`) is still supported.

```qasm
qubit[8] q;
bit[8] c;

c[0] = measure q[0];
measure q[1] -> c[1];

if (c[0] == 1) {
  x q[0];
}
```

### Gate modifiers

Gate modifiers (`inv`, `ctrl`, and `negctrl`) are now supported. This
replaces the `c` prefix.
See the OpenQASM 3.0 specification for more information:
https://openqasm.com/language/gates.html#quantum-gate-modifiers

```qasm
ctrl @ x q[0], q[1]; // Equivalent to cx q
ctrl(2) @ x q[0], q[1], q[2]; // Equivalent to ccx q;
```

### Classical constant values

The parser now supports classical computation with constant values. This
can be used to e.g. define the number of quantum registers.

```qasm
const uint N = 4;
qubit[N * 2];
x qubit[N * 2 - 1];
```

Additionally, all features of the previous parser are still supported.


The big features from OpenQASM 3.0 still missing are:

- classical computational features such as loops, functions, etc. (see
#33)
- types such as bools, floats, angles, complex types, etc. (see #30,
#32)
- `pow` modifier (#27)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Lukas Burgholzer <burgholzer@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Anything related to the Core library and IR enhancement New feature or request good first issue Good for newcomers
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

1 participant