-
Notifications
You must be signed in to change notification settings - Fork 62
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
Accepting circuits as initial states #817
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## measurebasis #817 +/- ##
==============================================
Coverage 100.00% 100.00%
==============================================
Files 97 97
Lines 12930 12953 +23
==============================================
+ Hits 12930 12953 +23
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
initial state for circuit with density_matrix {circuit.density_matrix}.""", | ||
) | ||
else: | ||
return self.execute_circuit(initial_state + circuit, None, nshots) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please update the documentation with this sum operation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the docstring. Thanks for pointing this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this, looks good.
I was thinking that if you delegate the check if initial state is circuit in Circuit.execute
we would not have to update both the numpy and qibolab backends. However, passing a circuit initial state would not work if one tries to use backend.execute_circuit(...)
directly and this would create an assymetry. I think your solution is better.
@@ -331,6 +331,16 @@ def thermal_error_density_matrix(self, gate, state, nqubits): | |||
def execute_circuit( | |||
self, circuit, initial_state=None, nshots=None, return_array=False | |||
): | |||
if isinstance(initial_state, type(circuit)): | |||
if not initial_state.density_matrix == circuit.density_matrix: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at Circuit.__init__
another attribute that initial_state
and circuit
may be different is accelerators
. I find it highly unlikely that someone will try to use this feature with multigpu, but maybe for consistency we could add the same check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. I've just added a check also for accelerators
.
This PR implements the following point:
from #720 and PR #799.
I will open a PR in qibolab to support this feature.
Checklist: