I am trying to analyze the impact of a single $T$ gate within a quantum circuit that primarily consists of Clifford gates. My goal is to understand the $T$ gate's role in $T$-design and Anti-concentration of the circuit. I am using Qiskit to create the circuit and attempt to generate the density matrix.

rho= DensityMatrix.from_instruction(qc)

I need the density matrix for up to 30 qubits to confidently observe the effect. However, when I try to get the density matrix, I encounter an error.

ValueError: maximum supported dimension for an ndarray is 32, found 40 

ValueError: too many subscripts in einsum

for system size 20 and 16 qubits respectively.

I would greatly appreciate it if anyone knew any way to get the density matrix of a circuit for a larger qubit system.(it could be any library as well other than qiskit)

  • $\begingroup$ Hi and welcome to Quantum Computing SE. You can enclose code snippet with three grave accents ``` to help distinguishing code from plain text. This greatly increase the legibility of your question. $\endgroup$
    – AG47
    Apr 12 at 16:13
  • $\begingroup$ What is Anti-concentration of the circuit? $\endgroup$
    – FDGod
    Apr 13 at 4:24

1 Answer 1


Maybe you can use approximate or Simplified Models

Stabilizer Rank Methods: For circuits that predominantly contain Clifford gates and a small number of T gates, you can use techniques based on the stabilizer rank to approximate the output state. This method leverages the fact that Clifford+T states can be decomposed into a sum of stabilizer states, although the efficiency of this method depends on the number of T gates.

Tensor Network Simulations: Tensor network techniques can be effective for simulating certain quantum circuits more efficiently than direct state vector simulation. Libraries like ITensor or TenPy might help in handling larger systems by exploiting specific tensor decompositions.

For example try Clifford+T estimator https://github.com/or1426/Clifford-T-estimator

Clifford+T estimator estimates a single probability of an n qubit quantum circuit consisting of Clifford gates, arbitrary single-qubit diagonal gates gates and a w qubit computational basis measurement.

This is an implementation of the algorithms reported in https://arxiv.org/abs/2101.12223


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.