qiboteam / qibocal

Quantum calibration, characterization and validation module for Qibo.
https://qibo.science
Apache License 2.0
30 stars 7 forks source link

`report` a small part of a `history` of a calibration suite #979

Open igres26 opened 2 weeks ago

igres26 commented 2 weeks ago

Right now an Executor records all routines executed in its history. Then report can generate a qibocal report of everything done.

It would be useful to be able to only report small parts of this history ideally via slicing, so that if we run optimization loops we can get a snapshot of the evolution across epochs and not have a kilometric report with each an every one of the function evaluations.

It would also be interesting in some cases to not save all the data, as that would blow up storage space.

Would that be easy to implement and open to the user?

alecandido commented 2 weeks ago

Thanks @igres26 to open this.

I didn't have yet enough time to commit much to the user interface, but all of this will be pretty simple to make available with scripts.

However, though pretty much convoluted, this is already partially available from the June/July refactor which led to scripts. As you noted, the Executor is recording all the routines in a History object, and the report() function accepts a History as an input. This last piece was the main update: I'm trying to register fewer things deep inside objects, and pass simpler objects around (as input and output of functions).

So, in this case you could consider report() as a function that takes a History and returns the actual report (i.e. History -> HTML, though the HTML is being dumped to a path, so the function actually returns nothing). The History object itself is pretty simple, and mainly a wrapper around a dictionary: https://github.com/qiboteam/qibocal/blob/c4fdce8874b56f3a6cce5d8508290af220917519/src/qibocal/auto/history.py#L21

So, if you want to do something like that right now, what you can do is:

# execute your routines

history = executor.history.copy()
# remove outputs you're not interested in
del history._task["routine-1-id"]
del history._task["routine-7-id"]
del history._task["routine-42-id"]

# plot just what you want
report(path, history)

Yes, it's not elegant at all, and it should be improved. Possibly even passing to report() a list of routines' IDs to include/exclude. That's why I'm suggesting to keep this issue open. However, this is what you could try to use even right now.