Open rileyjmurray opened 5 months ago
Just updating with some discussion on an internal thread. This issue is due to an underlying problem with the dense interface code for states and effect model members, and will be fixed as a side effect for revamping/deprecating that interface.
Update. For some reason this bug is getting triggered on my branch for PyTorch-backed forward simulation:
The bug is now also triggered in a continuous integration build:
https://github.com/sandialabs/pyGSTi/actions/runs/9191386508/job/25277676157#step:8:725
Describe the bug A call to the unimplemented function
ComplementPOVMEffect.to_vector()
can be triggered as a side effect of inspecting variable values.I'll concede that pyGSTi probably doesn't make promises about when it's safe to inspect certain variable values. That said, this behavior was very surprising to me during debugging, so I want to document it here even if we don't prioritize changing it. See below for more information.
To Reproduce
SimpleMapForwardSimulator
class as the forward simulator.Slightly tweak the following code, to express the list comprehension that defines
ereps
with a for loop: https://github.com/sandialabs/pyGSTi/blob/7411a00ec81e67f50932b705e46426fc2d4701d8/pygsti/forwardsims/mapforwardsim.py#L64-L66 I.e., replace the line that definesereps
witherep = effect._rep
.Resume execution after hitting the breakpoint set at step 3. After stepping over this line a few times (three times, IIRC), you'll get something like the following printed to console:
Additional context
The error message says to run
TPPOVM.to_vector()
instead. I'll note thatTPPOVM
doesn't provide its own implementation ofto_vector
(at time of writing), but it inherits a seemingly-suitable implementation fromBasePOVM
.I think my main priority here is understanding why this happens. There has to be something going on where accessing a field of
effect
is setting its parentmodel.dirty
field to True. I'd like to know where this is happening and why it needs to happen.It might be a valid fix to just have
ComplementPOVMEffect.to_vector()
return a numpy ndarray of shape(0,)
. That would work harmoniously with the implementation ofComplementPOVMEffect.from_vector
.