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

gate.control() #2804

Closed
2 of 3 tasks
ajavadia opened this issue Jul 16, 2019 · 1 comment · Fixed by #2862
Closed
2 of 3 tasks

gate.control() #2804

ajavadia opened this issue Jul 16, 2019 · 1 comment · Fixed by #2862
Assignees
Labels
status: pending PR It has one or more PRs pending to solve this issue type: enhancement It's working, but needs polishing
Milestone

Comments

@ajavadia
Copy link
Member

ajavadia commented Jul 16, 2019

Enhance the Gate class with a method for controlling it.
This should return a new ControlledGate (which derives from Gate).

  • Implement ControlledGate class. Existing controlled gates such as CX and CH and CSWAP and CCX should derive from this now. (add ControlledGate class #2862)

After this implementation, the following should work:

# inst is a 2 qubit instruction
# circ is a 5 qubit circuit
circ.append(inst.q_if(), [0, 2, 1])
circ.append(inst.q_if(2), [0, 3, 1, 2])
circ.append(inst.q_if().q_if(), [0, 3, 1, 2])  # should be same as above
circ.draw()  # should clearly show controlled gates

circ.decompose()  # should decompose the controlled gates one level

Follow ups:

  • Expose in a nicer user interface.
  • Write transpiler passes that efficiently use ControlledGate.

notes:
1- control currently clashes with a property of the instruction. So let's use the q_if method for now, with the goal of eventually moving to control.
2- The decomposition should be shallow, in the sense that the controlled gate provides a definition only in terms of controlling its subcomponents. It will be the job of the unroller to take this definition recursively until the end and implement a circuit over U3 and CX.

@ajavadia ajavadia added the type: enhancement It's working, but needs polishing label Jul 16, 2019
@1ucian0 1ucian0 added this to the 0.10 milestone Aug 20, 2019
@ajavadia ajavadia added the status: pending PR It has one or more PRs pending to solve this issue label Aug 20, 2019
@ewinston
Copy link
Contributor

ewinston commented Oct 8, 2019

Moving visualization to separate issue, #3223.

@mtreinish mtreinish modified the milestones: 0.10, 0.11 Nov 7, 2019
@mergify mergify bot closed this as completed in #2862 Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending PR It has one or more PRs pending to solve this issue type: enhancement It's working, but needs polishing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants