Describe the issue
When running a quantum circuit using Simulator().run() with repetitions=0, Cirq's sampling fallback path in SimulatesSamples.run_sweep_iter returns a hardcoded empty measurement array shape of (0, 1, 1).
This layout ignores the structural context of the circuit entirely. If a circuit contains multi-qubit measurement operations or repeated instances of the same measurement key, the returned placeholder dimension fails to match the actual layout criteria (repetitions, measurement_instances, measured_qubits), leading to incorrect downstream shape dimensions.
Explain how to reproduce the bug or problem
Execute the following minimal sample script:
import cirq
q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit(
cirq.measure(q0, q1, key="m"),
cirq.measure(q0, q1, key="m"),
)
result = cirq.Simulator().run(circuit, repetitions=0)
print("Returned shape:", result.records["m"].shape)
# Expected: (0, 2, 2)
# Actual: (0, 1, 1)
Click to view failing assertion example log
AssertionError: Pattern dimension mismatch.
Expected shape layout: (0, 2, 2)
Received placeholder array layout: (0, 1, 1)
Tell us the version of Cirq where this happens
# Paste the output of your version command here (e.g., 1.4.0.dev or similar)
Describe the issue
When running a quantum circuit using
Simulator().run()withrepetitions=0, Cirq's sampling fallback path inSimulatesSamples.run_sweep_iterreturns a hardcoded empty measurement array shape of(0, 1, 1).This layout ignores the structural context of the circuit entirely. If a circuit contains multi-qubit measurement operations or repeated instances of the same measurement key, the returned placeholder dimension fails to match the actual layout criteria
(repetitions, measurement_instances, measured_qubits), leading to incorrect downstream shape dimensions.Explain how to reproduce the bug or problem
Execute the following minimal sample script:
Click to view failing assertion example log
Tell us the version of Cirq where this happens
# Paste the output of your version command here (e.g., 1.4.0.dev or similar)