Open brunorijsman opened 1 year ago
In the issue report I said that I would generate a pull request for this in the near future.
I think I was able to add support for CROTZ to NetQASM on a feature branch off of a fork of the QuTech netqasm repo.
This required also adding CROTZ support to SquidASM, which I also did on a feature branch off of a fork of QuTech squidasm repo.
However, at that point, I found out that NetSquid does not appear to have implemented the CROTZ gate:
Error encountered while running the experiment
{'exception': 'TimeoutExpired', 'message': 'Call to simulator timed out after 60 seconds.', 'trace': 'Exception in thread Thread-1:
Traceback (most recent call last):
File "/Users/brunorijsman/git-personal/netqasm/netqasm/backend/executor.py", line 449, in _execute_commands
yield from output
File "/Users/brunorijsman/git-personal/squidasm/squidasm/nqasm/executor/base.py", line 251, in _execute_command
yield from super()._execute_command(subroutine_id, command)
File "/Users/brunorijsman/git-personal/netqasm/netqasm/backend/executor.py", line 508, in _execute_command
output = yield from output
File "/Users/brunorijsman/git-personal/netqasm/netqasm/backend/executor.py", line 94, in new_method
output = yield from output
File "/Users/brunorijsman/git-personal/netqasm/netqasm/backend/executor.py", line 802, in _handle_controlled_qubit_rotation
yield from output
File "/Users/brunorijsman/git-personal/squidasm/squidasm/nqasm/executor/base.py", line 135, in _do_controlled_qubit_rotation
yield from self._execute_qdevice_instruction(
File "/Users/brunorijsman/git-personal/squidasm/squidasm/nqasm/executor/base.py", line 165, in _execute_qdevice_instruction
self.qdevice.execute_instruction(
File "netsquid/components/qprocessor.pyx", line 1061, in netsquid.components.qprocessor.QuantumProcessor.execute_instruction
netsquid.components.qprocessor.MissingInstructionError: Missing physical instruction for Instruction: crotz_gate
Unfortunately, the source code for NetSquid is not publicly available, so I am stuck at this point. Unless someone with access to NetSquid source code helps out by adding CROTZ support I won't be able to make any further progress.
Looked some more into NetSquid. Although CROTZ (with a user-chosen rotation angle) is not available as a primitive operation in netsquid.qubits.operators
I can probably create my own by using netsquid.qubits.operators.Operator.ctrl
in combination with netsquid.qubits.operators.create_rotation_op
.
After looking into NetSquid some more, it looks like the problem is something else than what I thought. NetSquid does in fact have a INSTR_CROT_Z
instruction. The problem is that squidasm
has not added this INSTR_CROT_Z
instruction as a physical instruction to the quantum processor that it is using by calling QProcessor.add_physical_instruction(PhysicalInstruction(INSTR_CNOT_Z, ...))
. So, it looks like we can fix this (i.e. add support for CROTZ to QDE-ADK) by patching squidasm
without needing access to the netsquid
source code after all.
Yes, that was it, I just needed to register the physical instruction:
# Repo squidasm, file sim/network/network.py
class QDevice(QuantumProcessor):
# Default instructions. Durations are arbitrary
_default_phys_instructions: List[PhysicalInstruction] = [
PhysicalInstruction(ns_instructions.INSTR_INIT, duration=1e5),
PhysicalInstruction(ns_instructions.INSTR_X, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_Y, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_Z, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_H, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_K, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_S, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_T, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_ROT_X, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_ROT_Y, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_ROT_Z, duration=1e3),
PhysicalInstruction(ns_instructions.INSTR_CNOT, duration=5e5),
PhysicalInstruction(ns_instructions.INSTR_CROT_Z, duration=5e5), # <<< ADD THIS
PhysicalInstruction(ns_instructions.INSTR_CZ, duration=5e5),
]
That allows me to use controlled-Z-rotation gates in QNE-ADK applications (at least for the vanilla/generic quantum processor, although perhaps not for the NV quantum processor).
This is what I needed to implement QFT for the Quantum Internet Hackathon 2022.
If anyone is interested, I can submit a pull requests for the necessary changes in squidasm and netqasm. If not interested, feel free to close this ticket with no further action. Either way, I have the necessary changes in a local fork and I am unblocked for the hackathon.
Add support for a controlled-phase gate (= controlled-Z-rotation gate) with a rotation angle chosen by the caller.
NetQASM current supports:
Single-qubit Z-rotation operations with fixed angles, namely operator Z (fixed rotation angle pi), operator S (fixed rotation angle pi/2), and operator T (fixed rotation angle pi/4).
A single-qubit Z-rotation operation with a rotation angle chosen by the caller, namely operator ROT_Z.
A two-qubit controlled-Z-rotation operation with a fixed angle, namely operator CPHASE (fixed rotation angle pi).
What is missing is a two-qubit controlled-Z-rotation operation with a rotation angle chosen by the caller. Perhaps this could be called CROT_Z.
This new CROT_Z operation is needed to implement the Quantum Fourier Transformation (QFT).
I plan to generate a pull request for this in the near future.