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

Clarify whether defcals can be defined using aliases #472

Open
amilsted opened this issue May 10, 2023 · 4 comments
Open

Clarify whether defcals can be defined using aliases #472

amilsted opened this issue May 10, 2023 · 4 comments
Labels
clarify specification Change text of spec, not (mainly) semantics of spec

Comments

@amilsted
Copy link

What is the expected enhancement?

It isn't clear to me whether the following is supported:

let q0 = $0;

defcal X90 q0 {   // equivalent to `defcal X90 $0 { ... }` ?
    ...
}

It seems like a natural and useful thing to support, as naming physical qubits (rather than referring to them only by integer) can clarify code e.g. in cases where there is more than one type of qubit on a device.

I could not tell from the spec whether this is allowed, so perhaps this should be clarified?

@amilsted amilsted added the enhancement default GH label label May 10, 2023
jwoehr added a commit to jwoehr/openqasm that referenced this issue May 10, 2023
@jwoehr
Copy link
Collaborator

jwoehr commented May 10, 2023

Physical Qubits
While program qubits can be named, hardware qubits are referenced only by the syntax $[NUM]

I take "only" to mean "only" but I can see how the discussion of Aliasing can lead to ambiguity.

Aliasing
The let keyword allows quantum bits and registers to be referred to by another name as long as the alias is in scope.

I have opened Pull Request #473 to address this.

@amilsted
Copy link
Author

amilsted commented May 11, 2023

Gonna reference #471, which also makes the case for more flexible references to hardware qubits. @PhilReinhold I think that issue should probably be reopened.

@blakejohnson
Copy link
Contributor

I would say that the q0 referenced in the definition:

defcal X90 q0 { }

is not the same q0 as in the surrounding scope. This is also true of how variables in def statements can shadow variables in their enclosing scope. e.g.

int a = 1;
def foo(int a) -> int {
   // in this scope 'a' references whatever was passed in, not the value of 'a' in the enclosing scope.

@amilsted
Copy link
Author

Ah, I hadn't realized that defcal X90 q0 { ... } is already valid and defines a generic defcal.

Perhaps we can reopen #471 and consider more flexible physical-qubit names like $q0 instead?

jwoehr added a commit that referenced this issue Aug 2, 2023
Clarify Issue #472 - Physical Qubits cannot be Aliased
@jlapeyre jlapeyre added clarify specification Change text of spec, not (mainly) semantics of spec and removed enhancement default GH label labels Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarify specification Change text of spec, not (mainly) semantics of spec
Projects
None yet
Development

No branches or pull requests

4 participants