Closed ChienKaiMa closed 10 months ago
It should be quite easy to add presets for a few common 3-qubits gates - I can do this. But do you also require an arbitrary number of controls? The only complication then is one would want to apply these as a D=2 MPO, to keep the complexity as low as possible.
Regarding openqasm
, it would be great to support this. I don't have the need or time to implement it myself, but would be very happy to see a PR! Even if it is just for minimal subset of the specification.
I do have a crazy benchmark that contains 32-qubit multi-controlled gates, but I think adding a few common 3-qubits gates is helpful enough. It is also appreciated if 4-qubit and 5-qubit multi-controlled-not gates are added as it increases a considerable amount of quantum circuits that I can simulate.
As of basic support for OpenQASM
, I think I can give it a try when I am less busy. Hope I can implement it before January:)
I think if one adds 4 and 5... then one might as well implement arbitrary controls! I do have the core bit of code that produces a low rank TN decomposition of an arbitrary n-controlled gate, its just a matter of choosing an interface / which gates to add as presets etc. I suppose just multi controlled NOTs would do for starters?
Multi-controlled NOTs decomposition would help a lot!
Sorry to jump in, but is the only thing necessary for openQASM support is a wrapper to parse the instructions into quimb operations? New to quimb, and need an interface with openQASM so this is something I'm happy to work on, but not sure if there was something else needed other than translation (ie. are there operations in openQASM 2 that are not supported in quimb? My guess would be no?)
Hi @AtomDRP, yes I think the only road block is basically writing a parser for the files. In terms of unsupported operations, I'm not totally sure but I believe there are few things like:
NotImplementedError
for initially. Can I ask what is the format of QASM files that the parser currently supports? I've tried finding this info in the docs but have had no luck. Maybe an example would help?
What is called qasm
is really a basic format, sometimes also called .qsim
files. It is now badly named since openqasm has become an established standard. The format is really just a text file with each line like so:
{GATE_ROUND} GATE_LABEL *GATE_PARAMS *QUBITS
with the gate_round being optional. Example circuits can be found for example here - https://github.com/sboixo/GRCS.
I've now added a openqasm 2.0 parser and various 3 qubit gates - https://github.com/jcmgray/quimb/releases/tag/v1.6.0.
Multi-controlled gate support has been added now too:
circ.apply_gate('SWAP', qubits=(4, 2), controls=(3, 1, 5))
let me know if you get round to trying it and it works / (doesn't work!).
I want to simulate Grover's algorithm with QuiMB, and the circuits contain multi-controlled Toffoli gates, which I didn't find a simple implementation in QuiMB. Though there may be a way to apply custom gates or perform circuit decomposition, I prefer using the
parse_qasm_file
function and simulate the circuits directly. By the way, theqasm
format that QuiMB supports is not the commonly used OpenQASM but the format of the random quantum circuits, which is often inconvenient when simulating different quantum algorithms.