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

Add overload to handle the case when the user writes: #32

Merged
merged 3 commits into from
Apr 1, 2023

Conversation

schweitzpgi
Copy link
Collaborator

@schweitzpgi schweitzpgi commented Mar 28, 2023

  cudaq::control(Kernel{}, {ctrl1, ctrl2}, args...);

Get vector<reference_wrapper> through the bridge.

Add simple test.

@amccaskey
Copy link
Collaborator

Will you check that the following makes it through the bridge with this PR:

struct givens {
  void operator()(double lambda, cudaq::qubit &q, cudaq::qubit &r) __qpu__ {
    ry(M_PI_2, q);
    ry(M_PI_2, r);
    z<cudaq::ctrl>(q, r);
    ry(lambda, q);
    ry(-lambda, r);
    z<cudaq::ctrl>(q, r);
    ry(-M_PI_2, q);
    ry(-M_PI_2, r);
  }
};

__qpu__ void qnppx(double theta, cudaq::qubit &q, cudaq::qubit &r,
                   cudaq::qubit &s, cudaq::qubit &t) {
  x<cudaq::ctrl>(r, q);
  x<cudaq::ctrl>(s, t);
  cudaq::control(givens{}, {q, t}, theta, r, s);
  x<cudaq::ctrl>(r, q);
  x<cudaq::ctrl>(s, t);
}

@schweitzpgi
Copy link
Collaborator Author

schweitzpgi commented Mar 29, 2023

Will you check that the following makes it through the bridge with this PR:

struct givens {
  void operator()(double lambda, cudaq::qubit &q, cudaq::qubit &r) __qpu__ {
    ry(M_PI_2, q);
    ry(M_PI_2, r);
    z<cudaq::ctrl>(q, r);
    ry(lambda, q);
    ry(-lambda, r);
    z<cudaq::ctrl>(q, r);
    ry(-M_PI_2, q);
    ry(-M_PI_2, r);
  }
};

__qpu__ void qnppx(double theta, cudaq::qubit &q, cudaq::qubit &r,
                   cudaq::qubit &s, cudaq::qubit &t) {
  x<cudaq::ctrl>(r, q);
  x<cudaq::ctrl>(s, t);
  cudaq::control(givens{}, {q, t}, theta, r, s);
  x<cudaq::ctrl>(r, q);
  x<cudaq::ctrl>(s, t);
}

Thanks for the test. I'm getting a failure on this code. Investigating. Update: added fix.

@amccaskey
Copy link
Collaborator

Thanks for the bug fix, the code snippet works for me now.

Copy link
Collaborator

@amccaskey amccaskey left a comment

Choose a reason for hiding this comment

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

Approved pending CI

  cudaq::control(Kernel{}, {ctrl1, ctrl2}, args...);

Get vector<reference_wrapper<qubit>> through the bridge.

Add simple test.
@schweitzpgi schweitzpgi merged commit b082ebb into NVIDIA:main Apr 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2023
@schweitzpgi schweitzpgi deleted the ch-multiple.controls branch April 1, 2023 01:20
@bettinaheim bettinaheim added the release notes Changes need to be captured in the release notes label Apr 11, 2023
@bettinaheim
Copy link
Collaborator

Rel notes: see also #35.

@bettinaheim bettinaheim added the bug fix To be listed under Bug Fixes in the release notes label Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix To be listed under Bug Fixes in the release notes 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