-
Notifications
You must be signed in to change notification settings - Fork 1
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
[feature] Shots backend #130
Conversation
… Added `GeneralState.update_gates()` method.
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 moved get_operator_expectation_value
and get_circuit_overlap
here because they did not match with the intended use of pytket Backend
class: there's an intended way to support expectation values in there, but through a BackendResult
, not this.
Additionally, these functions are based on the tensor_network_convert
approach that I intend to eventually deprecate once GeneralState
is full-featured, so it makes sense they are in the same file that will eventually be moved to a deprecated
submodule.
|
||
# TODO: this should be optionally parallelised with MPI | ||
# (both wrt Pauli strings and contraction itself). | ||
def get_operator_expectation_value( |
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.
Unfortunately, this git diff completely butchers what actually happened with get_operator_expectation_value
: it was moved (verbatim, except for removals of self
argument) to the tensor_network_convert.py
file. See https://github.com/CQCL/pytket-cutensornet/pull/130/files#r1653061092 for details on why.
|
||
def get_circuit_overlap( |
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.
Unfortunately, this git diff completely butchers what actually happened with get_circuit_overlap
: it was moved (verbatim, except for removals of self
argument) to the tensor_network_convert.py
file. See https://github.com/CQCL/pytket-cutensornet/pull/130/files#r1653061092 for details on why.
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.
The diff in this file is unfortunately quite confusing. The changes where quite simple, but they are somehow intertwinned in the diff, so I suggest to compare the files to each other separately. Here's a brief of the changes:
- Changed the name of
CuTensorNetBackend
toCuTensorNetStateBackend
, since it is meant to support state vector output only. - Added a new
CuTensorNetShotsBackend
that satisfies the requirements of Support multi-shot exact simulation backends usingSampler
from cuTensorNet #121. - Created a
_CuTensorNetBaseBackend
that the other two backends are based on, where all of the common code lives. - Some chore tasks: provided details of
BackendInfo
, removed the gateset requirements and replaced them with a custom predicate that checks for commands with.get_unitary()
implemented, removed the use ofauto_rebase_pass
since it is no longer needed. - Moved some functions to another file, see https://github.com/CQCL/pytket-cutensornet/pull/130/files#r1653061092.
The approach of using a base class _CuTensorNetBaseBackend
is inspired on AerBackend from pytket-qiskit, same with the creation of specialised backends for statevector output and shots output.
I've been using a tutorial for backend creation. It's a bit out of date in places, but mostly fine.
tests/test_cutensornet_backend.py
Outdated
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.
The tests added for CuTensorNetShotsBackend
are very basic because these just need to check that the backend wrapper works. More involved tests for the shot extraction logic were already added in #129 in test_general_state.py
.
Description
CuTensorNetBackend
intoCuTensorNetStateBackend
which now uses the newGeneralState
.CuTensorNetShotsBackend
for shot-based simulation.Related issues
Completes #121.
Checklist