NVIDIA / NVIDIA/cuda-quantum

Add more tests for control vs. broadcast

Open
#913 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue stale-notified
Dominant language
C++
Stars
1.1k
Forks
456
Avg merge
1d 22h
Merged PRs (30d)
165

Description

I think we should add more tests to see how the compiler is behaving with a wide variety of combinations. Some that I could think of (likely not comprehensive):

__qpu__ void example() {
  cudaq::qreg q(4);
  cudaq::qreg w(2);
  cudaq::qubit t;
  
  x(q[0], q[1], q[2]); // Broadcast
  x(q); // Broadcast
  x(q, t, w); // Broadcast?
  x<cudaq::ctrl>(q); // Error? Or controls: q[0], q[1], q[2], target: q[3]?
  x<cudaq::ctrl>(q, t); // controls: q[0], q[1], q[2], q[3] target: t
  x<cudaq::ctrl>(t, q); // Error?

  swap(w); // Ok
  swap(q[0], q[1]); // Ok
  swap(q[0], q[1], q[2]); // Error
  swap(q); // Error ? Broadcast (swap(q[0], q[1]) swap(q[2],q[3])?
  swap<cudaq::ctrl>(w); // Error?
  swap<cudaq::ctrl>(q[0], q[1], q[2]); // Error? Or control: q[0], targets: q[1], q[2]
  swap<cudaq::ctrl>(q, w); // controls: q, targets: w[0], w[1]
  swap<cudaq::ctrl>(w, q); // Error?
}

Originally posted by @boschmitt in https://github.com/NVIDIA/cuda-quantum/pull/898#pullrequestreview-1727528562

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C++ compiler behavior represented by the control and broadcast examples in this issue, checking each combination. Decide the expected outcomes for the question-mark cases before adding tests. Done means the listed combinations are covered and the tests distinguish supported behavior from compilation errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.