-
Notifications
You must be signed in to change notification settings - Fork 127
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
Experiment serialization #1392
Comments
The user usage is to be able to work as following:
An option for interface would be to load experiment from the experiment ID: exp = BaseExperiment.load(exp_id) then for the user to have experiment data that is connected to the experiment object, he can use: exp_data = ExperimentData.load(exp) The reason to break the creation of the experiment and the experiment data is for the case where a user would want to create an experiment with the same configuration and analysis option but doesn't need the data. Alternatively, the user can load experiment data without experiment object using experiment ID: exp_data = ExperimentData.load(exp_id) For the expected usage of loading both experiment data and the experiment object, we could make use of a utility function: exp, exp_data = load_experiment(exp_id) This will require that there will be a place to store experiment ID in the |
Thanks for the interface patterns @ItamarGoldman. I agree it's good to have the option to load either the experiment or experiment data or both, since these operations could be slow for large experiments. Since there's precedent for As for |
Good point, I tend to agree with keeping the function taking |
After some tests I have some insights. ret = config.cls(*config.args, **config.kwargs) In addition, I think we should match the @classmethod
def load(
cls,
experiment_id: str,
service: Optional[IBMExperimentService] = None,
provider: Optional[Provider] = None,
) -> "BaseExperiment":
# Add validity check here
if service is None:
if provider is None:
raise ExperimentDataError(
"Loading an experiment requires a valid Qiskit provider or experiment service."
)
service = cls.get_service_from_provider(provider)
# getting experiment config and analysis config from db
experiment_config, analysis_config = service.load_experiment_config(exp_id)
# reconstructing the experiment (here we can support custom experiment)
reconstructed_experiment = cls.from_config(experiment_config)
# creating analysis class (here we can support custom experiment)
reconstructed_experiment.analysis = reconstructed_experiment.analysis.from_config(analysis_config)
# returning experiment obj
return reconstructed_experiment To load experiment and experiment data at the same time we can overload the function: @classmethod
def load(
cls,
experiment_id: str,
service: Optional[IBMExperimentService] = None,
provider: Optional[Provider] = None,
return_exp_data,
) -> "BaseExperiment":
# Using previous implementation to reconstruct experiment
reconstructed_experiment = cls.load(exp_id, service, costume_experiment_class)
# getting experiment data
reconstructed_experiment_data = ExperimentData.load(exp_id, service)
return reconstructed_experiment, reconstructed_experiment_data Another thing I thought of is to load experiment with custom experiment and analysis. In this case the user will provide us the classes and we will use them to load What do you think? |
Some points from external discussion:
|
Another idea that was mentioned is that the load function will load the transpiled circuits of the experiment. for it, we will need to take the following thing into consideration:
|
This idea is in @coruscating's original list above:
In the most recent discussion we said this support is not required in the initial implementation. I think this use case should be supported, but I don't think it should be the default behavior. I see it as a more advanced use case because there is more that can go wrong. The old circuits might not be valid after an update to the backend or when trying to run on a different backend or if the experiment class has been updated since the previous run. Also, downloading the circuits could be slower than regenerating them, like you mention. |
@wshanks discussed in the meeting today that we should support the use case of not running the analysis when running an experiment and then saving experiment config in a dummy |
In the meeting, I was thinking that |
Suggested feature
A frequently requested feature is the ability to reconstruct an entire experiment using syntax similar to ExperimentData, i.e.
BaseExperiment.load(id)
andBaseExperiment.save()
.PRs
from_config()
to reconstruct the experiment container in the same environmentOpen questions
The text was updated successfully, but these errors were encountered: