Skip to content

Conversation

@nkanazawa1989
Copy link
Collaborator

Summary

This is a part of PR #380. Update of composite experiment is dropped for review.

Details and comments

Copy link
Contributor

@eliarbel eliarbel left a comment

Choose a reason for hiding this comment

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

Looks very good!

Copy link
Collaborator

@chriseclectic chriseclectic left a comment

Choose a reason for hiding this comment

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

One question I have with this approach is adding these hooks in it becomes less clear which method can have side effects on the Experiment objects themselves, and what should happen in cases where you run circuits but perform analysis later (eg if loading saved data to analyze), or run multiple types to generate different datasets.

Previously circuits, run and run_analysis typically shouldn't have had any side effects on the instance so could be called repeatedly without issue. It looks like adding these callbacks changes this so it should perhaps be made clear what is going on now, and if they are intended to have side effects or not.

"""
return circuits

def run_transpile(self, backend: Backend, **options) -> List[QuantumCircuit]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is a good name for this method. This isn't just doing run transpile, this is doing full circuit generation and the pre and post transpile actions along with transpilation. This is why I suggested calling it circuits in your original PR. Maybe run_circuits is better since it can potentially have side effects now with the pre and post actions, while the original circuits one didn't.

Copy link
Collaborator Author

@nkanazawa1989 nkanazawa1989 Oct 5, 2021

Choose a reason for hiding this comment

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

I see your point. I don't think they do have side effect, because users don't directly submit output of circuits method to the backend. I assume this is mainly used to check what is executed (I'm fine with making it protected). I feel circuits and run_circuits are confusing, so the options would be

  1. Turning current circuits into a protected method and replacing circuits method with run_transpile. This means one cannot check logical circuits. The output of circuits will be transpiled and usually they look very complicated.

  2. Assigning completely different name to run_transpile. Something like compile_experiment or prepare_execution?

How do these options sound?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 3b6b372. Basically run_transpile functionality is integrated into circuits method and the original circuits method is now renamed to _circuits. New circuits method has an option run_transpile defaults to False, so by default, it returns logical circuits as before.

"""
pass

def run_analysis(self, experiment_data: ExperimentData, **options) -> ExperimentData:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this method should be the one that calls _post_analysis_action, not the Analysis.run method. Since if this may have side effects on this class this should be clear form this class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that is what I originally implemented and people suggested me to exclude the post action from this method. However, this requires composite experiment run method to have boilerplate code because they need to call post analysis of each nested experiment. I think we can merge #407 first and revert the change based on #407.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I noticed above induces side effect in this situation 0c8b915

What happens if we call add_analysis_callback from run_analysis? Or should we just call post analysis without adding it to the experiment data callbacks?

@chriseclectic chriseclectic added the on hold On hold until something else is done. label Oct 18, 2021
@eliarbel
Copy link
Contributor

Closes #151

@yaelbh
Copy link
Collaborator

yaelbh commented Nov 28, 2021

It's quite difficult to follow the discussion here. Where do things stand?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold On hold until something else is done.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants