pasqal-io / qadence

Digital-analog quantum programming interface
https://pasqal-io.github.io/qadence/latest/
Apache License 2.0
72 stars 21 forks source link

[Refac] Fix saving/loading models with device #477

Closed inafergra closed 4 months ago

inafergra commented 5 months ago

Fixes #475 following up on the work done by @dominikandreasseitz in this unfinished PR. The unfinished PR also included some refactoring of the TrainConfig class (not related to this bug) which was causing conflicts with main that were messy to solve, thus this new PR. As discussed, it would be better to add the TrainConfig refactoring in a separate PR.

inafergra commented 4 months ago

thanks @inafergra ,

1. can we add a test which loads both legacy (without a device) and current checkpoints (with device) and asserts that they are successfully loaded?

2. i remember @awennersteen proposed on the previous PR to handle both cases and log a error/debug in case the user uses legacy checkpoints. the most important thing is that this implementation handles both.
   thanks!

Thanks for the comments Dominik. I added tests checking that both QNNs and QuantumModels can be loaded with the legacy ckpts names. The function get_latest_checkpoint_name() can find both legacy and device ckpts.

gvelikova commented 4 months ago

Hey @inafergra have you tested how this modification with the device works with GPUs?

inafergra commented 4 months ago

Hey @inafergra have you tested how this modification with the device works with GPUs?

Hey @gvelikova, yes I tested it in my local (single) gpu and it works fine

dominikandreasseitz commented 4 months ago

hey @inafergra , @Roland-djee will take over the review here!

inafergra commented 4 months ago

@awennersteen if you don't have any more comments this should be ready to merge now

inafergra commented 4 months ago

Merging this now as discussed with @gvelikova, any additional changes can be included in a future PR solving #484 which also involves checkpointing.