5

I'm new to Q# and I was curious on how one would find the number of Q# simulatable qubits for a specific machine. I know Microsoft has an approximation of 16GB ~ 30 qubits but I wanted a better estimation for my own machines.

I wrote this quick program that runs a loop which allocates a register of increasing size. When I get a std::bad_alloc error I then have an estimate. I'm guessing there is a better way either through a tool or some pre-written code.

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
jman
  • 443
  • 2
  • 8

2 Answers2

2

The simple rule is:

Doubling the memory gives you one additional qubit.

So if Microsoft says that

16GB -> 30 qubits

then

 8GB -> 29 qubits
 4GB -> 28 qubits
 2GB -> 27 qubits
 ...
32GB -> 31 qubits
64GB -> 32 qubits

and so further.

This scaling, as well as the number quoted by Microsoft, can be understood from an argument as the one in the linked answer, using that

  1. each complex number equals 2 real numbers with double precision (8 bytes each), so 16 bytes are needed per comples number,

  2. to describe $N$ qubits, $2^N$ numbers are needed,

  3. and 1GB=$1024^3$ bytes

which together yields $16\cdot 2^N = x \, \mathrm{GB} = x\cdot 1024^3$ with $x$ the memory required in GB, which results in $$ N = \log_2(x\,\times 1024^3/16) = \log_2(x)+26\ . $$ For $x=16$ (i.e. 16GB of memory), $\log_2(16)=4$, and this yields exactly $$ N=30 \ \mathrm{qubits}\ , $$ which is the number quoted by Microsoft.

Norbert Schuch
  • 6,521
  • 16
  • 27
-1

A simple formula for the number of qubits you can simulate in almost all programs is given by this very well received answer.

After re-arranging the formula given there into a form that's much more relevant to your specific question, and changing 48 to 32 since Q# is written in C++, not python, we have:

$$ N_{\rm{qubits}} = \log_2\left( \frac{\rm{RAM}}{32} \right) $$

When $\rm{RAM} = 32\rm{GB} = 32\times 1024^3$, this formula gives 30, meaning you an simulate 30 qubits.

If you plug the amount of RAM you have, into that formula, it will give a good estimate of how many qubits you can simulate without using a more sophisticated simulator.