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

Callback gates #31

Open
alecandido opened this issue Jun 14, 2024 · 2 comments
Open

Callback gates #31

alecandido opened this issue Jun 14, 2024 · 2 comments

Comments

@alecandido
Copy link
Member

These gates are more do not represent any unitary, but they are metadata, localized in a specific position in the circuit. Still, this information is consumed during execution, so it's required for the qibo-core representation.

In Qibo, callbacks are all registered in a built-in module
https://github.com/qiboteam/qibo/blob/master/src/qibo/callbacks.py
and they are already not extendable by the user.

We will leverage this to establish the qibo-core representation.
In particular, an integer will represent the type of the call-back, and the application will always need to get a handle on the present state (because callbacks are always used to compute some property of it, preventing the need of manually splitting the circuit in chunks to inspect the result)

A problem to be solved is how to store the callback parameters.
The available callbacks are:

  • entanglement entropy
    • two booleans will be required (for compute_spectrum and check_hermitian)
    • a single float (possibly an integer?) is needed for the base
    • a sequence of integers will be needed to specify the partition (possibly empty)
  • state
    • copy is just a boolean, but as we analyzed with @stavros11 the copy=False option is unuseful, so we can get rid of it
  • norm
    • no parameters
  • overlap
    • a whole state is needed to compute the overlap (possibly a lot of floats)
  • energy
    • an entire Hamiltonian has to be stored (not even representable as floats, unless executed)
  • gap
    • the mode could be just an int (string not needed, can be replaced by the integer 1)
    • we need a boolean for the check_degenerate

So, not all parameters will be floats, and some of them definitely require complex structures (like the Hamiltonian), so they are not suitable to be stored among the general variational circuit parameters.
I see no problem in implementing for state and norm callbacks, but the others will require at least a dedicated callback_parameters attribute (or something similar).

@stavros11
Copy link
Member

  • gap

    • the mode could be just an int (string not needed, can be replaced by the integer 1)
    • we need a boolean for the check_degenerate

I believe that Gap is only meant to be used when executing AdiabaticEvolution models, not Circuits, so most likely we will not need to worry about it in qibo-core at all.

The rest seems right. Just to understand, is the way the current CallbackGate will be added something like:

circuit.add(Callback, callback=Overlap, callback_parameters=[other_state])

?

@alecandido
Copy link
Member Author

At this point, I was even thinking about something like:

circuit.callback(Overlap, vec![other_state])

Also consider that Rust does not have named or default parameters, so they would have to be added also to all the other circuit.add() calls (or wrapping them as options, and always passing None in the others).

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

No branches or pull requests

2 participants