-
Notifications
You must be signed in to change notification settings - Fork 55
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 nqubit fogi #258
Merged
Merged
Feature nqubit fogi #258
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… with many-qubit models. This commit adds implementation surrounding a (new) ImplicitOpModel.setup_fogi method, which so far is specific to local noise models and will probably be moved there once we start working with the cloud noise models. Additional supporting functionality is also added: - adds ok_if_missing argument to ElementaryErrorgenBasis.label_indices & label_index methods. - adds the (existing) _NoErrorGeneratorInterface class as a base class of static SPAM operators. - moves a bunch of methods that should work for both implicit and explicit models from ExplicitOpModel to OpModel. We've begun testing this using LocalNoiseModel objects, and know that the FOGI analysis isn't working correctly quite yet, even though it is runnable -- a WIP!
This replaces many usages of statespace.tensor_product_block_labels(0) where the labels of the first tensor product block are assumed to be all there is to the state space. This new attribute enfores this assumption, throwing a ValueError if it isn't satisfied. This commit updates (hopefully) all the instances where .tensor_product_block_labels(0) was used and .sole_tensor_product_block_labels should be used. Incidentally, this commit also adds (temporarily) some debug statements to the FOGI tools methods that are unrelated to the added attribute.
…lbl ordering issue. Unlike the smq2Q models, a 2-qubit LocalNoiseModel by default contains 2-qubit gates in both directions, e.g., Gcnot:0:1 and Gcnot:1:0. This caused the discovery of a bug in that the sslbl ordering of Gcnot:1:0 was being preserved, causing issues and incorrectness in the computed FOGI directions -- e.g. the intrinsic qtys of Gcnot:0:1 and Gcnot:1:0 were the *same* rather than having their sslbls reversed. This commit fixes this issue by: 1) adding sorting of sslbls to GlobalElementaryErrorgenLabel, facilitating correct comparison of the labels, e.g., that H(X,Y) on 0:1 is equal to H(Y,X) on 1:0. 2) adding sslbl mapping to EmbeddedOp errorgen_coefficient_array and errorgen_coefficients methods, since the embedded op's state space should NOT be assumed to be a meaningful subset of the EmbeddedOp.state_space labels. 3) Updates first_order_gauge_action_matrix and construct_fogi_quantities (in fogitools.py) to short-circuit embedding ops based on their sslbl ordering and not just space dimension. Also adds debug statements related to ferreting out issue solved by next commit.
This bug was causing a failure within the construction of relational FOGI directions within construct_fogi_quantities, where an assertion failure precipitated a deep dive into what was going wrong with the FOGI machinery. As it turned out, the issue was that the nullspace was being computed incorrectly for complex matrices, which this commit fixes.
…embedded ops. Updates extract_std_target_mx function within setup_fogi to make use of the recent updates to EmbeddedOp that properly map sslbls between the EmbeddedOp and the op being embedded. Also updates comparisons that should have tested sslbls ordering but didn't. As of this commit, the FOGI analysis of a LocalNoiseModel seems to be working - or at least we've fixed the blatant errors now.
Plumbs forgotten (?) `copy` argument to OpModelNoise.create_errormap and uses this in cloud model SPAM creation, allowing the 1Q prep/povm to be copied appropriately when creating a n-qubit prep or POVM with independent_spam=True. Also fixes a couple typos where' independent_gates' needed to change to 'independent_spam'.
…explicit model. Implements CloudNoiseModel.setup_fogi and fixes a number of bugs & issues related to implicit-model FOGI analysis found by comparing a 2Q explicit model with essentially the same 2Q cloud noise model. Fixes included: - using the *dual* error generator where appropriate when constructing "gauge action" matrices, instead of just the conjugate of the primal elementary error generator. - fixing the assignment of elementary errorgen labels to gauge directions. Previously we were assuming the gauge-space directions were elementary errorgen directions, but actually `gauge_space.vectors` holds each gauge direction in terms of elementary directions. Leaving out this middle step would cause normalization errors and other issues. This commit adds and then comments out & tags with REMOVE numerous debug print statements in fogitools.py and the model class files. These should be removed later. Also, this commit creates separate setup_fogi implementations in each of the LocalNoiseModel and CloudNoiseModel files -- this was primarily for debugging and independent tweaking. In the near future, we should try to consolidate the setup_fogi routines, maybe even with ExplicitOpModel.setup_fogi. Finally, note that no attempt to add FOGI parameterizations to implicit models has been made yet -- this is a task for furture work.
This leads to nice (if possible) vectors for the common gauge space found between all the operations, and often results in the final FOGI vectors & directions being simpler in terms of elementary errorgens. This doesn't correct any bug per se, but it does make the results nicer. In the 2Q FOGI test between explicit and cloud noise models, this update causes the outputs to agree even after setting include_spam=True (in the previous commit the outputs matched when SPAM was not included, but including SPAM would cause the common gauge space to be a bit wacky and ultimately different, more complex, FOGI directions to be selected).
This allows easier comparison between two essentially identical models when one has a different ordering of its primitive ops. This argument lets the user specify the order directly, overriding the default.
After tweaking the implementations of the setup_fogi method in the various model classes, this commit pulls together the large amount of common code and creates a single OpModel.setup_fogi method which defers to derived class _op_decomposition methods for the very small amount of derived-model-class specific functionality.
Moves ExplicitOpModel._add_reparameterization to OpModel base class and generalizes (not much needed) so that this method works for all model types. Pushes ImplicitOpModel.errorgen_coefficients method into LocalNoiseModel and CloudNoiseModel derived classes, as the implementation needs to be different in the two cases.
… more general. Previously this method only worked when each of ComposedOp's factors had the same parameters (or, more often, only a single factor had parameters); this commit generalizes this to the case where multiple factors can have different numbers of even potentially overlapping parameters. The errorgen_coefficients of the factors are still just concatenated, however, so there's no special behavior when multiple factors have the a coefficient for the *same* elementary error generator (FUTURE work?).
…d fixes a bug). A number of updates and a bug fix so that cloud noise circuits can be constructed for a model without an idle gate, for which max_idle_weight=0. The bug that was fixed was substituting 'max_idle_weight' with 'syntheticIdleWt' when constructing the synthetic idle model (`sidle_model` in the code). This commit also imports * from cloudcircuitconstruction.py in pygsti/circuits/__init__.py so the contained routines are more accessible.
…r implicit models. This try/except block allows model.num_nongauge_params to fail and fall back to model.num_params, which will occur for implicit models. This enables computation of Hessians for implicit models, which we need for testing the Hessian spectrum of models before and after FOGI reparameterization. These tests are able to run for LocalNoiseModel and CloudNoiseModel models now, though the spectrum isn't what I expect so there's likely still some bugs in the FOGI analysis for implicit models currently.
Adds specification that a GateSetTomographyDesign or more generally any CircuitListsDesign can be initialized with a PlaquetteGridCircuitStructure instead of a list of circuit lists. (This functionality already existed but just wasn't documented.)
…ary cases. In particular when creating a 1-qubit cloud crosstalk model and performing a FOGI analysis on it, there were a couple places where bugs needed to be fixed.
This new idle mode causes a detected global idle operation, e.g., an '{idle}' gate or 'Gi' that acts on the entire state space, to be used to simulate the empty layer but *not* other layers (unlike in the 'add_global' mode). This mode has been added for LocalNoiseModel and CloudNoiseModel, and is useful for comparing to explicit models with an idle ('[]') gate.
When an idle processor spec is internally constructed, the included gate names should not contain gates that act on more qubits than are in the processor spec, otherwise a warning will be generated about unused model noise parameters. This commit adds a filter to the gate names used to construct the idle pspec, avoiding this warning.
… general enough? Within the constructed error operations of a LindbladNoise object, error generator defined errors should use the 'PP' basis by default. This basis, however, is still hardcoded and should be updated with something more flexible in the future.
Adds several commented out lines in model.py that will be used when we resume debugging the known issue that FOGI vectors need not respect the same sparsity/locality as their corresponding FOGI directions. This comes about because the FOGI directions are not necessarily orthogonal on shared subspaces (e.g. the Gx space for 2 relational quantities: one between Gx and Gy and the other between Gx and Gz). Perhaps we can perform the FOGI direction construction in a way that preserves this desired property? To be picked up later.
This fixes a "can't append lists & tuples" error in some circumstances, but may break it in others. If we need to toggle this back we should just add casts to the relevant spots.
Main update is to add independent_spam arguments (recently added) to model construction function calls in unit tests. Other change is switching a ValueError to an AssertionError.
Manually resolves a conflict in explicitmodel.py where FOGI related reparameterization functions were removed in the nqubit-fogi branch but weren't removed by the auto-merge, indicating they may have been modified in some way on develop amidst the nqubit-fogi changes. I don't think any such changes should be substantial, but if there's weirdness after this point it may be worth looking back in the prior commit at the FOGI routines in explicitmodel.py.
FOGI system tests that run FOGI-parameterized GST still seem fragile, and enabling the cloud-crosstalk one weirdly causes the crosstalk free test (which is completely independent) to fail with an Arpack error, indicating there's some bizarre state persistence going on. We should debug and understand this better in the FUTURE.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates FOGI analysis to better work with reduced, often multi-qubit, models
This update isn't completely tested or comprehensive - there's still more that needs to be done in terms of additional functionality and we need to critically test this functionality before relying on it. Still, this update takes a big step toward being able to perform FOGI analyses on more than just explicit models.
The
setup_fogi
method is now a method ofOpModel
and has been appropriately generalized to compute FOGI quantities for crosstalk-free and cloud-crosstalk models in addition to explicit models (setup_fogi
used to be a method of justExplicitOpModel
). This update is made possible by multiple focused technical updates listed here for reference:create_elementary_errorgen_nqudit_dual(...)
function for creating dual generators.fogitools.py
that fix bugs only appearing in the implicit-model case. Numerous debug statements were added to help with testing the code, which still isn't complete, and so remain but are commented out.GlobalElementaryErrorgenLabel
to sort its state-space labels, enabling comparison of these labels.max_idle_weight=0
, which was needed to construct simple models for testing and debugging the FOGI analysis operation on cloud noise models. Importantly, this update also allows cloud noise models to be created for processor specificationwithout idle gates.ComposedOp
andEmbeddedOp
error generator coefficients handling (errorgen_coefficients
and related methods), making it more robust and properly manipulate and tally the state space labels when needed.NoErrorGeneratorInterface
class for operations that don't have an error generator, so that a wider range of pyGSTi operation objects are compatible with queries by aModel
that gather all of the error generator coefficients in a that model.errorgen_coefficients
implementations to implicit models."only_global"
implicit idle mode for implicit models. This creates a model with a (potentially noisy) idle operation from an idle-gate-containing processor spec such that the noisy idle is used to simulate global-idle circuit layers but is not appended to other layers as a "background idle" operation.copy
method toModelNoise
class, which facilitates the creation of independent noise on different gates.sole_tensor_product_block_labels
attribute toStateSpace
objects. This is really just a convenience method that clarifies code, as in many places we want to (at least initially) assume a state space is just a tensor product space and not the direct sum of multiple such spaces.Note: This PR did, at one point, contain some update to CHP ops, though there were largely overwritten by overlapping updates to integrate forward simulators in pyGST. This should be fine, but may result in weird/bad behavior if the git auto merge silently fails to merge something correctly.