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

Opaque Pointer workstream definition #42

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions workstreams/Opaque_Pointers_Workstream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Workstream: Opaque Pointer Support

Check warning on line 1 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

Unknown word (Workstream)

Check warning on line 1 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (Workstream)

## Motivation & Benefits

Support for typed pointers in LLVM is being removed. More information about the
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved
motivation for this change can be found in LLVM forums. For example, the LLVM
documentation on [opaque pointers](https://llvm.org/docs/OpaquePointers.html) as
well as [this
presentation](https://llvm.org/devmtg/2022-04-03/slides/keynote.Opaque.Pointers.Are.Coming.pdf)
give a brief overview.

The QIR specification currently makes use of typed pointers to represent qubit

Check warning on line 12 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (qubit)

Check warning on line 12 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

Unknown word (qubit)
values and result values. While in LLVM 15, support for these types can still be
enabled, an update to LLVM 16 requires us to change this representation.
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved

The goal of this workstream is hence to update the QIR specification to support

Check warning on line 16 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (workstream)

Check warning on line 16 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

Unknown word (workstream)
newer versions of LLVM, and to document what LLVM versions can be used to
support each version of the QIR specification.

## Requirements

Generally, LLVM maintains very good [backwards
compatibility](https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility);
according to the LLVM 18 docs, it is possible to load even bitcode generate by

Check warning on line 24 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (bitcode)
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved
an LLVM version as early as 3.0. However, it is not possible in general to
generate bitcode that can be loaded with an older version of LLVM than the one

Check warning on line 26 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (bitcode)
used to emit it. This means that while *QIR consumers*, i.e. backend providers,
can update to the latest LLVM version without sacrificing support for prior QIR
versions, whereas *QIR producers*, i.e. language frontends, cannot use LLVM

Check warning on line 29 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (frontends)
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved
versions that are newer than the one required by the versions of the QIR
specification they support. This can pose challenges for maintaining a
state-of-the art frontend.
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved

As part of this workstream, we hence specifically propose to update the required

Check warning on line 34 in workstreams/Opaque_Pointers_Workstream.md

View workflow job for this annotation

GitHub Actions / Check spelling, linting and links

word (workstream)
LLVM version for the next version of the QIR specification to LLVM 16.
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved

## Dependencies & Related Projects

There are no related projects within the QIR Alliance at this time. However,
there are a number of threads in the LLVM community by projects with similar
needs. In particular, the considerations discussed in [this
thread](https://discourse.llvm.org/t/rfc-better-support-for-typed-pointers-in-an-opaque-pointer-world/63339)
and the follow up
[here](https://discourse.llvm.org/t/rfc-adding-opaque-types-to-llvm-ir/65326)
also apply to the QIR ecosystem.

See also the section on [Open Questions](#open-questions) regarding possible
alternatives to consider.

A related topic to consider when discussing options for this workstream is
whether the new representation would also allow to support qudits in the future.

## Deliverable(s) & Expected Outcome

The expected outcome of the workstream is a pull request to update the 0.1
version of the QIR specification with the necessary changes to be able to emit
the full QIR and all its profile using LLVM 16.
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved

## Future Work (Out of Scope)

Migration plan for shared components?
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved

## Working Group & Getting Involved

Members: <br/>
Chair:

If you would like to contribute to the workstream, please contact \<insert
contact\>.

## Schedule

Launch date: <br/>
Estimated end date: <br/>
Meeting schedule and/or channel(s) of communication:

## Status & Discussions

The work and status is tracked in the form of a GitHub issue \<insert link\>.
<br/>
We encourage comments, inputs, and discussions on that issue.

The GitHub issue is labeled as `Approved` after approval by the steering
committee.

## Open Questions

As part of the workstream, we could re-examine the use of address spaces to
distinguish memory on the QPU itself (i.e. qubits) from memory located on an
adjacent classical processor. See also [this
thread](https://discourse.llvm.org/t/casting-between-address-spaces-and-address-space-semantics/10920/16)
that contains a discussion about the nature and use of different address spaces.

There may be options to consider for representing quantum specific data types,
and merely migrating from typed to opaque pointers may not be the best option.
E.g. the working group should consider if it is desirable at all to work with
pointers, especially since the QIR specification prohibits dereferencing of
resources that are located on the QPU.
Loading