Skip to content

Sampling from circuit does not give proper bitstring #206

@VolodyaCO

Description

@VolodyaCO

Issue Description

I am trying to sample from a 14 qubit circuit and I am getting a weird bitstring Array([0.5, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan], dtype=float32).

How to Reproduce

>>> import pickle
>>> import jax
>>> with open("faulty_circuit.pickle", "rb") as f:
...   circuit = pickle.load(f)
... 
Please first ``pip install -U qiskit`` to enable related functionality in translation module
An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.
>>> bitstrings_and_probs = circuit.sample(batch=2000, random_generator=jax.random.PRNGKey(3723))
>>> bitstrings_and_probs[1264][0]
Array([0.5, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
       nan], dtype=float32)

You can download faulty_circuit.pickle here (sorry for the very unsafe way of sharing this object, I am using custom gates and I don't want to paste the whole code here because it's quite bulky).

Error Output

There is no error, but clearly the outcome is wrong.

Environment Context

>>> tc.about()
OS info: Linux-5.19.0-46-generic-x86_64-with-glibc2.27
Python version: 3.11.7
Numpy version: 1.26.3
Scipy version: 1.12.0
Pandas version: 2.2.0
TensorNetwork version: 0.4.6
Cotengra is not installed
TensorFlow is not installed
Jax version: 0.4.23
Jax installation doesn't support GPU
JaxLib version: 0.4.23
PyTorch version: 2.1.2+cu121
PyTorch GPU support: True
PyTorch GPUs: [<torch.cuda.device object at 0x7f45847782d0>, <torch.cuda.device object at 0x7f4584778690>, <torch.cuda.device object at 0x7f4584778390>, <torch.cuda.device object at 0x7f45847794d0>, <torch.cuda.device object at 0x7f458477bd90>, <torch.cuda.device object at 0x7f4584779910>, <torch.cuda.device object at 0x7f458477bd50>, <torch.cuda.device object at 0x7f45ac112f10>]
Pytorch cuda version: 12.1
Cupy is not installed
Qiskit is not installed
Cirq version: 1.2.0
TensorCircuit version 0.11.0
>>> tc.__version__
'0.11.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions