Json serialize `cirq.ion.ion_gates.MSGate`
See original GitHub issueReplace the existing class: https://github.com/quantumlib/Cirq/blob/ec9fc4506da394ce103c4cccc02d4993b91449ac/cirq-core/cirq/ion/ion_gates.py#L27
with
class MSGate(ops.XXPowGate):
"""The Mølmer–Sørensen gate, a native two-qubit operation in ion traps.
A rotation around the XX axis in the two-qubit bloch sphere.
The gate implements the following unitary:
exp(-i t XX) = [ cos(t) 0 0 -isin(t)]
[ 0 cos(t) -isin(t) 0 ]
[ 0 -isin(t) cos(t) 0 ]
[-isin(t) 0 0 cos(t) ]
"""
def __init__(self, *, rads: float): # Forces keyword args.
ops.XXPowGate.__init__(self, exponent=rads * 2 / np.pi, global_shift=-0.5)
self.rads = rads
def _with_exponent(self: 'MSGate', exponent: value.TParamVal) -> 'MSGate':
return type(self)(rads=exponent * np.pi / 2)
def _circuit_diagram_info_(
self, args: 'cirq.CircuitDiagramInfoArgs'
) -> Union[str, 'protocols.CircuitDiagramInfo']:
angle_str = self._format_exponent_as_angle(args, order=4)
symbol = f'MS({angle_str})'
return protocols.CircuitDiagramInfo(wire_symbols=(symbol, symbol))
def __str__(self) -> str:
if self._exponent == 1:
return 'MS(π/2)'
return f'MS({self._exponent!r}π/2)'
def __repr__(self) -> str:
if self._exponent == 1:
return 'cirq.ms(np.pi/2)'
return f'cirq.ms({self._exponent!r}*np.pi/2)'
def _json_dict_(self) -> Dict[str, Any]:
return cirq.protocols.obj_to_dict_helper(self, ["rads"])
@classmethod
def _from_json_dict_(cls, rads: float, **kwargs: Any) -> Any:
return cls(rads=rads)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
cirq_ionq.ionq_native_gates.MSGate | Cirq | Google Quantum AI
A cirq.Gate representing self controlled by the given control values and qubits. This is a cirq.ControlledGate in the base implementation, ...
Read more >Module: cirq_ionq | Cirq - Google Quantum AI
serializer module: Support for serializing gates supported by IonQ's API. ... (MS) gate is a two qubit gate native to trapped ions.
Read more >Module: cirq_ionq.ionq_native_gates | Cirq | Google Quantum AI
Native gates for IonQ hardware. ... class MSGate : The Mølmer–Sørensen (MS) gate is a two qubit gate native to trapped ions.
Read more >cirq_ionq.ionq_devices.IonQAPIDevice | Cirq
A device that uses the QIS gates exposed by the IonQ API.
Read more >Module: cirq_ionq.serializer | Cirq - Google Quantum AI
... the serialized portions of a cirq.Circuit . class Serializer : Takes gates supported by IonQ's API and converts them to IonQ json...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Feel free to take on any of these: https://github.com/quantumlib/Cirq/labels/good first issue
Oh man, I just forked the repo. You beat me to it. 🤣