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

densitymx_slow does not work #438

Closed
aristaeus opened this issue May 14, 2024 · 5 comments
Closed

densitymx_slow does not work #438

aristaeus opened this issue May 14, 2024 · 5 comments
Assignees
Labels
bug A bug or regression
Milestone

Comments

@aristaeus
Copy link

Describe the bug
The densitymx_slow implementation does not work. At pygsti/evotypes/densitymx_slow/opreps.py:177,

class OpRepStandard(OpRepDenseSuperop):
    def __init__(self, name, basis, state_space):
        ...
        super(OpRepStandard, self).__init__(superop, state_space)

The issue is that OpRepDenseSuperof.__init__ doesn't have that signature;

class OpRepDenseSuperop(OpRep):
    def __init__(self, mx, basis, state_space):
        ...

To Reproduce
Steps to reproduce the behavior:

  1. Install pygsti without cython
  2. Try and run a circuit
  3. :(

Expected behavior
Ideally we would get the fast cython implementation working. However, while setting up a new user it would be nice for the slow fallback to work so we can get something out.

@aristaeus aristaeus added the bug A bug or regression label May 14, 2024
@KangHaiYue
Copy link

I had the same issue. This is the error message I got when trying to create a model:

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\models\modelconstruction.py:1847, in create_cloud_crosstalk_model(processor_spec, custom_gates, depolarization_strengths, stochastic_error_probs, lindblad_error_coeffs, depolarization_parameterization, stochastic_parameterization, lindblad_parameterization, evotype, simulator, independent_gates, independent_spam, errcomp_type, implicit_idle_mode, basis, verbosity)
1713 """
1714 Create a n-qudit "cloud-crosstalk" model.
1715
(...)
1840 CloudNoiseModel
1841 """
1843 modelnoise = _build_modelnoise_from_args(depolarization_strengths, stochastic_error_probs, lindblad_error_coeffs,
1844 depolarization_parameterization, stochastic_parameterization,
1845 lindblad_parameterization, allow_nonlocal=True)
-> 1847 return _create_cloud_crosstalk_model(processor_spec, modelnoise, custom_gates, evotype,
1848 simulator, independent_gates, independent_spam, errcomp_type,
1849 implicit_idle_mode, basis, verbosity)

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\models\modelconstruction.py:1876, in _create_cloud_crosstalk_model(processor_spec, modelnoise, custom_gates, evotype, simulator, independent_gates, independent_spam, errcomp_type, implicit_idle_mode, basis, verbosity)
1873 printer = _VerbosityPrinter.create_printer(verbosity)
1875 #Create static ideal gates without any noise (we use modelnoise further down)
-> 1876 gatedict = _setup_local_gates(processor_spec, evotype, None, custom_gates,
1877 ideal_gate_type=('static standard', 'static clifford', 'static unitary'),
1878 basis=basis)
1879 stencils = _collections.OrderedDict()
1881 # (Note: global idle is now processed with other processorspec gates)
1882
1883 # SPAM

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\models\modelconstruction.py:1475, in _setup_local_gates(processor_spec, evotype, modelnoise, custom_gates, ideal_gate_type, basis)
1473 ideal_gate = ideal_gates.get(name, None)
1474 if ideal_gate is None:
-> 1475 ideal_gate = _op.create_from_unitary_mx(U, ideal_gate_type, basis, stdname, evotype, state_space=None)
1476 ideal_gates[name] = ideal_gate
1477 noiseop = modelnoise.create_errormap(key, evotype, ideal_gate.state_space, target_labels=None)

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\modelmembers\operations_init_.py:59, in create_from_unitary_mx(unitary_mx, op_type, basis, stdname, evotype, state_space)
57 try:
58 if typ == 'static standard' and stdname is not None:
---> 59 op = StaticStandardOp(stdname, basis, evotype, state_space)
60 elif typ == 'static clifford':
61 op = StaticCliffordOp(U, None, basis, evotype, state_space)

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\modelmembers\operations\staticstdop.py:58, in StaticStandardOp.init(self, name, basis, evotype, state_space)
55 basis = _Basis.cast(basis, state_space.dim) # basis for Hilbert-Schmidt (superop) space
57 evotype = _Evotype.cast(evotype)
---> 58 rep = evotype.create_standard_rep(name, basis, state_space)
59 _LinearOperator.init(self, rep, evotype)

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\evotypes\evotype.py:136, in Evotype.create_standard_rep(self, standard_name, super_basis, state_space)
135 def create_standard_rep(self, standard_name, super_basis, state_space):
--> 136 return self.module.OpRepStandard(standard_name, super_basis, state_space)

File c:\Users\k0426\anaconda3\envs\working_env_new\Lib\site-packages\pygsti\evotypes\densitymx_slow\opreps.py:177, in OpRepStandard.init(self, name, basis, state_space)
174 state_space = _StateSpace.cast(state_space)
175 assert(superop.shape[0] == state_space.dim)
--> 177 super(OpRepStandard, self).init(superop, state_space)

TypeError: OpRepDenseSuperop.init() missing 1 required positional argument: 'state_space'

@sserita
Copy link
Contributor

sserita commented May 14, 2024

Thanks for reporting this and for identifying a hole in our testing! This should be a quick fix, I'll have something on develop for you in the next day or so hopefully. We'll also add some tests in an environment without Cython to ensure we catch things like this in the future.

@sserita sserita self-assigned this May 14, 2024
@sserita sserita modified the milestones: 0.9.13, 0.9.12.3 May 14, 2024
@sserita
Copy link
Contributor

sserita commented May 14, 2024

I believe this is a one-line fix. It will be merged into develop shortly, and we are planning a hotfix release soon, but if you want to try the change locally and let me know if you run into other issues, you are certainly welcome to.

We go from:

super(OpRepStandard, self).__init__(superop, state_space)

to:

super(OpRepStandard, self).__init__(superop, basis, state_space)

@aristaeus
Copy link
Author

Thanks! I suspected this was the change required, but I'm not familiar enough with the code to be confident.

@sserita sserita added the fixed-but-not-in-release-yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label May 20, 2024
@sserita
Copy link
Contributor

sserita commented May 20, 2024

Closing as this was merged into develop with #439. The fixed-but-not-in-release tag will remain until the 0.9.12.3 release, which will include this fix.

@sserita sserita closed this as completed May 20, 2024
@sserita sserita removed the fixed-but-not-in-release-yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug or regression
Projects
None yet
Development

No branches or pull requests

3 participants