"print": False, "opaque": False, "n_args": 3, "n_bits": 1, "args": ["theta", "phi", "lambda"], "bits": ["q"], # gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; } "body": node.GateBody([ node.UniversalUnitary([ node.ExpressionList([ node.Id("theta", 0, ""), node.Id("phi", 0, ""), node.Id("lambda", 0, "") ]), node.Id("q", 0, "") ]) ]) } # 2-parameter 1-pulse single qubit gate QuantumCircuit.definitions["u2"] = { "print": False, "opaque": False, "n_args":
# these circuits, so we may need to modify the algorithm. # It can happen that a swap in a deeper layer can be removed by permuting # qubits in the layout. We don't do this. # It can happen that initial swaps can be removed or partly simplified # because the initial state is zero. We don't do this. cx_data = { "opaque": False, "n_args": 0, "n_bits": 2, "args": [], "bits": ["c", "t"], # gate cx c,t { CX c,t; } "body": node.GateBody([ node.Cnot([ node.Id("c", 0, ""), node.Id("t", 0, "") ]) ]) } swap_data = { "opaque": False, "n_args": 0, "n_bits": 2, "args": [], "bits": ["a", "b"], # gate swap a,b { cx a,b; cx b,a; cx a,b; } "body": node.GateBody([ node.CustomUnitary([ node.Id("cx", 0, ""),
QuantumCircuit.definitions["rzz"] = { "print": True, "opaque": False, "n_args": 1, "n_bits": 2, "args": ["theta"], "bits": ["a", "b"], # gate rzz(theta) a, b { cx a, b; u1(theta) b; cx a, b; } "body": node.GateBody([ node.CustomUnitary([ node.Id("cx", 0, ""), node.PrimaryList([node.Id("a", 0, ""), node.Id("b", 0, "")]) ]), node.CustomUnitary([ node.Id("u1", 0, ""), node.ExpressionList([node.Id("theta", 0, "")]), node.PrimaryList([node.Id("b", 0, "")]) ]), node.CustomUnitary([ node.Id("cx", 0, ""), node.PrimaryList([node.Id("a", 0, ""), node.Id("b", 0, "")]) ]) ]) }
# measurement of the same qubit. Near-term experiments cannot implement # these circuits, so we may need to modify the algorithm. # It can happen that a swap in a deeper layer can be removed by permuting # qubits in the layout. We don't do this. # It can happen that initial swaps can be removed or partly simplified # because the initial state is zero. We don't do this. cx_data = { "opaque": False, "n_args": 0, "n_bits": 2, "args": [], "bits": ["c", "t"], # gate cx c,t { CX c,t; } "body": node.GateBody([node.Cnot([node.Id("c", 0, ""), node.Id("t", 0, "")])]) } swap_data = { "opaque": False, "n_args": 0, "n_bits": 2, "args": [], "bits": ["a", "b"], # gate swap a,b { cx a,b; cx b,a; cx a,b; } "body": node.GateBody([
QuantumCircuit.header = QuantumCircuit.header + "\n" \ + "include \"qelib1.inc\";" # 3-parameter 2-pulse single qubit gate QuantumCircuit.definitions["u3"] = { "print": False, "opaque": False, "n_args": 3, "n_bits": 1, "args": ["theta", "phi", "lambda"], "bits": ["q"], # gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; } "body": node.GateBody([ node.UniversalUnitary([ node.ExpressionList([ node.Id("theta", 0, ""), node.Id("phi", 0, ""), node.Id("lambda", 0, "") ]), node.Id("q", 0, "") ]) ]) } # 2-parameter 1-pulse single qubit gate QuantumCircuit.definitions["u2"] = { "print": False, "opaque": False, "n_args": 2, "n_bits": 1, "args": ["phi", "lambda"],