1
$\begingroup$

Is it possible to change the simulator used by the Classic QDK with Python simulation ? It's reported that Classic QDK supports several simulators (sparse, full-state...). Which one is used when called from Python environment, and is it possible to change it?

I have a simulation which doesn't run because of large number of qubits instantiated (from 25 up to 61). The simulation with C# .NET runs perfectly. But when I use a Python host program, the simulation is simply blocked at qubit instantiation.

So I suppose that C# .NET host uses sparse simulator, while Python uses full-state.

$\endgroup$

1 Answer 1

1
$\begingroup$

There are no default simulators chosen either in .NET or in Python, you always specify them explicitly.

In C#, you use different classes for different simulators: QuantumSimulator for full state simulator, SparseSimulator for sparse simulator.

In Python, you switch the command you use to run Q# operation to use different simulators: .simulate() uses full state simulator, and .simulate_sparse() uses sparse simulator.

$\endgroup$
4
  • $\begingroup$ Thanks ! I didn't realize that in Python the method was the key to change simulator. I couldn't find some doc about that. $\endgroup$
    – Arnaud
    Commented Feb 24 at 16:41
  • $\begingroup$ This used to be documented at learn.microsoft.com/en-us/azure/quantum/sparse-simulator, but now the documentation switched to Modern QDK, so it talks about the sparse simulator in the Modern QDK. I had to look up the exact syntax in Q# Pocket Guide myself :-) $\endgroup$ Commented Feb 24 at 17:45
  • $\begingroup$ (If this answer solved your problem, feel free to accept it using the green checkmark - this will prevent the Community bot from bumping it to the top of the list half a year from now) $\endgroup$ Commented Feb 24 at 17:46
  • $\begingroup$ Yes, it clearly answer the question. Thanks ! The doc is not completely transfered. And so many things have changed between classic and modern QDK... $\endgroup$
    – Arnaud
    Commented Feb 26 at 18:36

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.