PhasedClassicalSimState#
qualtran.simulation.classical_sim.PhasedClassicalSimState
View source on GitHub
|
A mutable class for classically simulating composite bloqs with phase tracking.
Inherits From: ClassicalSimState
qualtran.simulation.classical_sim.PhasedClassicalSimState(
signature: 'Signature',
binst_graph: nx.DiGraph,
vals: Mapping[str, Union[sympy.Symbol, ClassicalValT]],
*,
phase: complex = 1.0,
random_handler: '_ClassicalValHandler'
)
The convenience function do_phased_classical_simulation will simulate a bloq. Use this
class directly for more fine-grained control.
This simulation scheme supports a class of circuits containing only:
classical operations corresponding to permutation matrices in the computational basis
phase-like operations corresponding to diagonal matrices in the computational basis.
Args
signatureThe signature of the composite bloq.
binst_graphThe directed-graph form of the composite bloq. Consider constructing this class with the
.from_cbloqconstructor method to correctly generate the binst graph.valsA mapping of input register name to classical value to serve as inputs to the procedure.
phaseThe initial phase. It must be a valid phase: a complex number with unit modulus.
Attributes
soq_assignAn assignment of soquets to classical values.
last_binstA record of the last bloq instance we processed during simulation.
phaseThe current phase of the simulation state.
random_handlerThe classical random number handler to use for use in measurement-based outcomes (e.g. MBUC).
Methods#
from_cbloq
@classmethodfrom_cbloq( cbloq: 'CompositeBloq', vals: Mapping[str, Union[sympy.Symbol, ClassicalValT]], rng: Optional['np.random.Generator'] = None, fixed_random_vals: Optional[Dict[int, Any]] = None ) -> 'PhasedClassicalSimState'
Initiate a classical simulation from a CompositeBloq.
Args
cbloqThe composite bloq
valsA mapping of input register name to classical value to serve as inputs to the procedure.
rngA random number generator to use for classical random values, such a np.random.
fixed_random_valsA dictionary of bloq instances to values to perform fixed calculation for classical values.
Returns
View source on GitHub