Skip to content
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 kraus api #255

Merged
merged 14 commits into from
Aug 12, 2022
Merged

Feature kraus api #255

merged 14 commits into from
Aug 12, 2022

Conversation

enielse
Copy link
Collaborator

@enielse enielse commented Aug 10, 2022

Adds Kraus operator interface to some operations

Creates the KrausOperatorInterface class which defines an interface for getting, setting, and counting the Kraus operators of a superoperator. A number of pyGSTi's operation classes, namely StochasticNoiseOp and those derived from DenseUnitaryOperator or DenseOperator (e.g. FullArbitraryOp, FullTPOp, StaticArbitraryOp, and DepolarizeOp) implement this interface, though some only partially. For example, only some operators can set their Kraus operators.

To achieve this, an number of under-the-hood changes have been made as a part of this PR:

  • POVM representation objects have been introduced, allowing POVMs to act independently or differently from a set of effects. This is useful within the CHP evotype, for example, so that a separate forward simulator is no longer needed (the CHPForwardSimulator class is now removed).
  • adds acton_random and adjoint_acton_random methods to operation representation classes, so that they can be used by the updated WeakForwardSimulator class to simulate circuit probabilities via sampling.
  • updates the WeakForwardSimulator class to be more standalone, calling the new acton_random interface of representations and utilizing a POVM representation when available.
  • improves standard gate name processing, largely through the new unitary_to_standard_gatename function.
  • Adds a basis argument to many of the operation classes. This argument is needed to convert to/from Kraus representation, but can be set to None if this functionality is not required.
  • Adds OpRepDenseUnitary, OpRepKraus, OpRepRandomUnitary, and OpRepStochastic classes to "densitymx" and "statevec" evotypes (and their "_slow" versions) where needed.

Erik Nielsen added 14 commits April 13, 2022 11:40
Adds kraussop.py that contains interface (base) class.  Adds implementation
of this interface in DenseOperator and DenseUnitaryOperator, which required
adding a 'basis' argument to DenseOperator.__init__.  This update cascaded to
updating several of the DenseOperator subclasses, such as FullArbitraryOp.
'None' is allowed to be specified as the basis, but if so the Kraus op functionality
is unavailable.
…ses.

The big update in this commit is the addition of new OpRepKraus
and OpRepRandomUnitary classes the the densitymx and densitymx_slow
evotypes, and OpRepRandomUnitary to the chp evotype.  The existing
OpRepStochastic class (only in these 3 evotypes) is updated to inherit
from OpRepRandomUnitary and has an updated signature, propagating to
updates in StochasticNoiseOp.
… correct now.

Fixes normalization bugs and adds explanatory comments in DenseOperator.kraus_operations
so that correct Kraus operations are produced.  Previously they were correct up to
normalization.
…raus updates.

Implements KrausOperatorInterface within StochasticNoiseOp by calling
.to_dense() on the unitary_reps within a OpRepRandomUnitary representation.
When this isn't implemented (e.g. CHP evotype) than an error will be raised.
This commit includes other minor updates/fixes to op reps and operator classes.
Implements a default outcome-for-shot method in WeakForwardSimulator
(though this is inefficient when the "shot" actually can compute a
probability distribution rather than a single outcome) that can be
used by the now-augmented 'statevec_slow' evotype.  The statevec_slow
evotype has been augmented with acton_random methods and new
OpRepRandomUnitary and OpRepStochastic classes to allow it to
work with WeakForwardSimulator even with models containing StochasticNoiseOp
operations.
…n. Minor bug fixes.

This allows, in particular, the CHP evotype and forward simulator to be run
on an ExplicitOpModel created from create_explicit_model that has depolarizing
noise (set by the depolarization_strengths arg).  The CHP evotype only supports
standard gates thus far (though it could be expanded to arbitrary Clifford gates)
and so needed the standard name of a gate to be computed correctly during model
construction even when the gate name didn't match a standard name (e.g. the '{idle}'
gate created by an explicit model).

This commit also fixes several other minor bugs introduced in recent commits
related to the new random unitary operator representation objects.
This update makes several related changes that in the end allow the
CHP evotype to be used with WeakForwardSimulator, MapForwardSimulator,
and SimpleMapForwardSimulator forward simulators (the latter two only
work when the circuit is made up of noiseless Clifford ops).

- addition of POVM representation objects.  Evolution types can now
  be asked to generate computational and composed (and in the future
  more?) POVM representations.  The only evotype that currently does
  this is 'chp', but the functionality may prove useful to future
  evotypes.

- ComposedPOVM and CompuationalBasisPOVM attempt to construct POVM
  representations BUT allow the creation call to fail (as it does
  for all but the 'chp' evotype currently) and then set their ._rep
  attribute to None.  Unlike other modelmember types, a POVM *is*
  allowed to have its ._rep == None provided it contains or can
  produce effect objects with valid representations.

- WeakForwardSimulator, MapForwardSimulator, and SimpleMapForwardSimulator
  are updated to prefer to use a POVM's representation to compute
  outcome samples or probabilities, and in the case the ._rep == None
  fall back to computing with effect vectors as before.  This allows the
  chp evotype to interface with these forward sims via its POVM reps
  rather than unnaturally through POVM effect objects & reps.

- the chp evotype contains a new povmreps.py file that holds POVM
  representation classes.  The POVM reps perform the actual running
  of the CHP executable (previously in CHPForwardSimulator) when
  outcome samples or probabilities are requested by a (generic)
  forward simulator.

This update is also meant to provide (& test) a new, hopefully more
natural and efficient paradigm for introducing new third party
circuit simulators to pyGSTi: by adding just a new evotype rather than
an evotype and a new forward simulator.  We'll see how this holds up.
…otype.

Basically translates the Kraus-map and weak-forwardsim supporting functionality
in 'statevec_slow' into 'statevec'.  This is pretty straightforward but does require
calling a Python method from within C code, which is the first example of this in
the codebase.
@enielse enielse merged commit 76e24ac into develop Aug 12, 2022
@enielse enielse deleted the feature-kraus-api branch August 12, 2022 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant