NVIDIA / NVIDIA/cuda-quantum

Specify control state

Open
#2,232 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Required prerequisites
  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.
Describe the feature

This is how to perform controlled operations:

import cudaq

@cudaq.kernel
def x_kernel(qubit: cudaq.qubit):
    x(qubit)

@cudaq.kernel
def kernel():
    
    controls = cudaq.qvector(2)
    target = cudaq.qubit()
    
    # Default: apply the x_kernel if controls are |1> 
    cudaq.control(x_kernel, controls, target) 
    
results = cudaq.sample(kernel)
print(cudaq.draw(kernel))

Currently, when the controls = 11 the target is applied.

What if I want to specify the control state for which the target is applied?

I may want to apply the target when the controls = 01 or controls = 00

See here for similar feature in qiskit.

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 from the cudaq.control(x_kernel, controls, target) entry point shown in the issue and compare the requested behavior with Qiskit's ctrl_state reference. Define how control states such as 11, 01, and 00 should be specified, preserving the current default behavior. Done means controlled operations apply the target for the selected state and the behavior is covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
quantum-computing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.