-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Custom instruction assembly and circuit append #2173
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chriseclectic
requested review from
1ucian0,
ajavadia,
atilag,
delapuente,
diego-plan9,
ewinston,
jaygambetta,
kdk,
mtreinish,
nonhermitian and
taalexander
as code owners
April 22, 2019 18:12
chriseclectic
changed the title
Add UnitaryGate, Snapshot instr, and allow third party extensions with assemble_circuits
[WIP] Add UnitaryGate, Snapshot instr, and allow third party extensions with assemble_circuits
Apr 24, 2019
chriseclectic
force-pushed
the
circuits-assemble
branch
3 times, most recently
from
April 26, 2019 15:09
7ae3680
to
f7c6771
Compare
chriseclectic
changed the title
[WIP] Add UnitaryGate, Snapshot instr, and allow third party extensions with assemble_circuits
Custom instruction assembly and circuit append
Apr 26, 2019
* add to_instruction to Pauli * add to_instruction to Operator * add to_instruction to QuantumChannel
chriseclectic
force-pushed
the
circuits-assemble
branch
from
April 26, 2019 21:05
f7c6771
to
de365f0
Compare
ajavadia
reviewed
Apr 27, 2019
# If input is a BaseOperator subclass this attempts to convert | ||
# the object to an Operator so that we can extract the underlying | ||
# numpy matrix from `Operator.data`. | ||
data = data.to_operator().data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like data.
ajavadia
approved these changes
Apr 27, 2019
lia-approves
pushed a commit
to edasgupta/qiskit-terra
that referenced
this pull request
Jul 30, 2019
* add assemble method to instruction * add optional label to Gate * add UnitaryGate instruction * add `to_instruction` to circuit.append * add to_instruction to Pauli * add to_instruction to Operator * add to_instruction to QuantumChannel * update Snapshot instruction * allow other snapshots with circuit.snapshot * add optional label to aer gate classes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds
assemble
method to circuitInstruction
that is used byassemble_circuits
for constructing theQasmQobjInstruction
. This can be overloaded by customInstructions
to define their own serialization.Adds optional
label
property toGate
objects, this can be used by Aer to define different noise models on the same gate types with different labels. Standard gate definitions are unchanged however, so this label can only be use from an opaque gate def egGate("id", 1, label="id_cx")
.Adds
UnitaryGate
circuit extension and removesUnitary
fromquantum_info.operators
.Updates
Snapshot
circuit extension to support general snapshot types. The monkey patchcircuit.snapshot
still only supports statevector though (and because of this the snapshot_type kwarg was removed from this circuit method).Checks for
to_instruction
method when appending an object inQuantumCircuit.append
. This can be used to allow objects to define their own conversion to an Instruction.Defines
to_instruction
methods for operator objects:Operator.to_instruction
appends aUnitaryGate
Pauli.to_instruction
appends a Pauli gate sequence (IdGate, XGate, YGate,ZGate) for the PauliQuantumChannel.to_instruction
appends aUnitaryGate
if the channel is a unitary channel, otherwise it appends an Opaque "kraus" instruction which can be directly simulator by Qiskit Aer.removes loading of monkey patch function names from qiskit circuit extensions. Monkey patching is still done so these methods are still added to
QuantumCircuit
andCompositeGate
, but the functions don't need to be in the top level namespace (I think?)Partially closes #2162: special cases for non-standard instructions are still required for dag_to_circuit and circuit_to_dag converisons.
Details and comments