Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored notebook for Hamiltonian Simulation #77

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marekgluza
Copy link
Contributor

Implementing #69 thanks @jykhoo1987 for input

Comment on lines 273 to 291
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be able to do it today, there should be no issues with dataclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, for now I'm learning the formalism by looking at your implementations :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@andrea-pasquale
Copy link
Collaborator

@marekgluza I've concluded the refactor. From the notebook everything seems to be fine.

@andrea-pasquale
Copy link
Collaborator

Feel free to pull and test

@marekgluza
Copy link
Contributor Author

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

@marekgluza
Copy link
Contributor Author

@Edoardo-Pedicillo @andrea-pasquale : proposed solution - add dependancy on cirq or qiskit until https://github.com/qiboteam/qibo/issues/1501fixed?

@marekgluza marekgluza mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants