KEMBAR78
Add new pass, linear-ctrl-form by schweitzpgi · Pull Request #853 · NVIDIA/cuda-quantum · GitHub
Skip to content

Conversation

@schweitzpgi
Copy link
Collaborator

This pass converts the "value semantics" form of the quake dialect from the "pruned control relations" form to the "linear control relations" form. The pruned form is the less constrained IR representation while the latter is overly constrained. The following examples illustrate the distinction.

This is a sequence of ctrl-x ops in pruned form:

%10 = quake.to_ctrl %0 : (!quake.wire) -> !quake.control
%11 = quake.x [%10] %1 : (!quake.control, !quake.wire) -> !quake.wire
%12 = quake.x [%10] %2 : (!quake.control, !quake.wire) -> !quake.wire
%13 = quake.x [%10] %3 : (!quake.control, !quake.wire) -> !quake.wire
%14 = quake.x [%10] %4 : (!quake.control, !quake.wire) -> !quake.wire
%15 = quake.x [%10] %5 : (!quake.control, !quake.wire) -> !quake.wire
%16 = quake.x [%10] %6 : (!quake.control, !quake.wire) -> !quake.wire
%17 = quake.x [%10] %7 : (!quake.control, !quake.wire) -> !quake.wire
%18 = quake.x [%10] %8 : (!quake.control, !quake.wire) -> !quake.wire
%19 = quake.x [%10] %9 : (!quake.control, !quake.wire) -> !quake.wire
%20 = quake.from_ctrl %10 : (!quake.control) -> !quake.wire

This is the same sequence in linear form:

%10:2 = quake.x [%0] %1 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%11:2 = quake.x [%10#0] %2 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%12:2 = quake.x [%11#0] %3 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%13:2 = quake.x [%12#0] %4 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%14:2 = quake.x [%13#0] %5 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%15:2 = quake.x [%14#0] %6 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%16:2 = quake.x [%15#0] %7 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%17:2 = quake.x [%16#0] %8 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
%18:2 = quake.x [%17#0] %9 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)

Notice that the pruned form makes it apparent that any permutation for scheduling these operations is legal and should give the same result. The linear form does not.

Reorganize the passes in the tablegen file, putting them back in alphabetical order.

@schweitzpgi schweitzpgi added the enhancement New feature or request label Nov 1, 2023
@schweitzpgi schweitzpgi marked this pull request as draft November 1, 2023 23:28
@github-actions
Copy link

github-actions bot commented Nov 2, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 2, 2023
@schweitzpgi schweitzpgi marked this pull request as ready for review November 2, 2023 23:00
@github-actions
Copy link

github-actions bot commented Nov 2, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 2, 2023
@github-actions
Copy link

github-actions bot commented Nov 3, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 3, 2023
@github-actions
Copy link

github-actions bot commented Nov 3, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 3, 2023
@github-actions
Copy link

github-actions bot commented Nov 3, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 3, 2023
@github-actions
Copy link

github-actions bot commented Nov 6, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 6, 2023
@copy-pr-bot
Copy link

copy-pr-bot bot commented Nov 13, 2023

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@schweitzpgi schweitzpgi requested a review from bmhowe23 November 13, 2023 21:29
@schweitzpgi schweitzpgi force-pushed the ch-linear.ctrl branch 2 times, most recently from 782a379 to fa1c3cd Compare November 13, 2023 21:34
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 13, 2023
Copy link
Collaborator

@bmhowe23 bmhowe23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

This pass converts the "value semantics" form of the quake dialect from
the "pruned control relations" form to the "linear control relations"
form. The pruned form is the less constrained IR representation while
the latter is overly constrained. The following examples illustrate the
distinction.

This is a sequence of ctrl-x ops in pruned form:

    %10 = quake.to_ctrl %0 : (!quake.wire) -> !quake.control
    %11 = quake.x [%10] %1 : (!quake.control, !quake.wire) -> !quake.wire
    %12 = quake.x [%10] %2 : (!quake.control, !quake.wire) -> !quake.wire
    %13 = quake.x [%10] %3 : (!quake.control, !quake.wire) -> !quake.wire
    %14 = quake.x [%10] %4 : (!quake.control, !quake.wire) -> !quake.wire
    %15 = quake.x [%10] %5 : (!quake.control, !quake.wire) -> !quake.wire
    %16 = quake.x [%10] %6 : (!quake.control, !quake.wire) -> !quake.wire
    %17 = quake.x [%10] %7 : (!quake.control, !quake.wire) -> !quake.wire
    %18 = quake.x [%10] %8 : (!quake.control, !quake.wire) -> !quake.wire
    %19 = quake.x [%10] %9 : (!quake.control, !quake.wire) -> !quake.wire
    %20 = quake.from_ctrl %10 : (!quake.control) -> !quake.wire

This is the same sequence in linear form:

    %10:2 = quake.x [%0] %1 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %11:2 = quake.x [%10#0] %2 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %12:2 = quake.x [%11#0] %3 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %13:2 = quake.x [%12#0] %4 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %14:2 = quake.x [%13#0] %5 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %15:2 = quake.x [%14#0] %6 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %16:2 = quake.x [%15#0] %7 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %17:2 = quake.x [%16#0] %8 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %18:2 = quake.x [%17#0] %9 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)

Notice that the pruned form makes it apparent that any permutation for
scheduling these operations is legal and should give the same result.
The linear form does not.

Reorganize the passes in the tablegen file, putting them back in
alphabetical order.

Add test.

Review comments.
@schweitzpgi schweitzpgi enabled auto-merge (squash) November 14, 2023 03:14
@schweitzpgi schweitzpgi merged commit fe7de22 into NVIDIA:main Nov 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2023
@schweitzpgi schweitzpgi deleted the ch-linear.ctrl branch November 14, 2023 04:06
@bettinaheim bettinaheim changed the title Add new pass, linear-ctrl-form. Add new pass, linear-ctrl-form Jan 22, 2024
@bettinaheim bettinaheim added this to the release 0.6.0 milestone Jan 22, 2024
@bettinaheim bettinaheim added release notes Changes need to be captured in the release notes and removed enhancement New feature or request labels Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release notes Changes need to be captured in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants