refactored notebook for Hamiltonian Simulation#77
Conversation
| def circuit(self, t_duration: int, steps:int=1, order=None): | ||
| dt = t_duration/steps | ||
| c = self.h.circuit(dt) | ||
| nqubits = c.nqubits | ||
| c_recompiled_into_CNOT = Circuit(nqubits=nqubits) | ||
|
|
||
| for gate in c.queue: | ||
| if len(gate.qubits) > 1: #if gate is two qubit | ||
| gate_decomposition = two_qubit_decomposition(*gate.qubits, gate.matrix()) | ||
| for gate_elem in gate_decomposition: | ||
| c_recompiled_into_CNOT.add(gate_elem) | ||
| else: | ||
| c_recompiled_into_CNOT.add(gate) | ||
|
|
||
| multi_layer = Circuit(nqubits=nqubits) | ||
| for _ in range(steps): | ||
| multi_layer += c_recompiled_into_CNOT | ||
|
|
||
| return multi_layer No newline at end of file |
There was a problem hiding this comment.
At this point given that this is a generic method that can be applied to any oracle, wouldn't it better to apply it directly to EvolutionOracle? Or am I missing something?
There was a problem hiding this comment.
Hmm, good point. Would you have time to put it into EvolutionOracle? Is it just copy paste of the entire SymbolicHamiltonian_EvolutionOracle and merge circuit or is there some dataclass subtlety to keep in mind?
There was a problem hiding this comment.
I should be able to do it today, there should be no issues with dataclass.
There was a problem hiding this comment.
Thanks, for now I'm learning the formalism by looking at your implementations :)
There was a problem hiding this comment.
In any case it would be better to have complete contributions. I think that as we already discussed the core devs are not supposed to refactor contributions.
|
@marekgluza I've concluded the refactor. From the notebook everything seems to be fine. |
|
Feel free to pull and test |
|
This has stalled because for a simple model Sam was running it and we ran into 2 qubit unitary decompositions that were not real in the magic basis qiboteam/qibo#1501 |
|
@Edoardo-Pedicillo @andrea-pasquale : proposed solution - add dependancy on |
Implementing #69 thanks @jykhoo1987 for input