Do not pickle cached values from cached_method calls. Arguments to multiprocessing workers are passed as pickles so the results of cached methods (and of hash(cirq.H)) would be computed on the worker side.
Similar to #3777 and #5738
Cirq version
You can get the cirq version by printing cirq.__version__. From the command line:
1.5.0.dev at 8d09a3220962c4e5eeed30ea33b9d120619b585f
Description of the issue
For some gates, e.g., cirq.H, the
hash(gate)
value is stored with cached_method decorator which breaks dictionary lookup if such gate is passed to multiprocessing worker. This seems to be the root cause for dictionary lookup problem in https://github.com/quantumlib/Cirq/issues/6667#issuecomment-2233834127.How to reproduce the issue
Output
Proposed solution
Do not pickle cached values from cached_method calls. Arguments to multiprocessing workers are passed as pickles so the results of cached methods (and of
hash(cirq.H)
) would be computed on the worker side.Similar to #3777 and #5738
Cirq version You can get the cirq version by printing
cirq.__version__
. From the command line:1.5.0.dev at 8d09a3220962c4e5eeed30ea33b9d120619b585f