Skip to content

The function random_clifford_circuit should yield deterministic results on each program run. #16138

@alexanderivrii

Description

@alexanderivrii

Environment

  • Qiskit version: 2.5 (current)
  • Python version: 3.13 (but should not matter)
  • Operating system: MacOS (but should not matter)

What is happening?

When running the python function random_clifford_circuit from qiskit/circuit/random/utils.py with the same Qiskit version and the same fixed seed, we should get deterministic results.

How can we reproduce the issue?

Run the following python program several times:

from qiskit.circuit.random.utils import random_clifford_circuit

cliff_circuit = random_clifford_circuit(num_qubits=10, num_gates=100, gates="all", seed=0)
print(cliff_circuit.count_ops())

You will see that gate counts (and hence also circuit themselves) change from one run to another.

What should happen?

We should get deterministic results.

Any suggestions?

Taking a brief look at random_clifford_circuit, the seeded numpy random generator should be fine, and the non-determinism probably comes from converting into a set on this line:

    gates_1q = list(set(_BASIS_1Q.keys()) - {"v", "w", "id", "iden", "sinv"})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersmod: quantum infoRelated to the Quantum Info module (States & Operators)

    Type

    No type

    Projects

    Status

    PR open / Contributor working on it

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions