Codebook: Let's Be Rational

Ask here about the “Let’s Be Rational” Codebook topic from the “Quantum Phase Estimation” module.

Hi!
It looks like code exercises with many wires (> 6) took too long to complete.
With wires = 9 it took ages Evaluating a task. Is there any way to speed up a process?

Hi @to.helen.babenko , welcome to the Forum!

It takes only a few seconds for me. The delay might be due to the code you’re running (especially if you have nested for loops).

Hint:

I used np.argsort together with the fractional_binary_to_decimal function for P.3.1

I hope this helps you!

Sorry, I need to clarify an isssue. An issue is with device initialization, with an amount of number here: dev = qml.device("default.qubit", wires=9), even if I use only 3 estimation wires.
Am I understand correctly, that even if I use a nested for loops (I use two argmax), performance should be still OK, if only 3 estimation wires are used? I don’t get how unused wires also impact performance.

Hi @to.helen.babenko ,

It’s actually the contrary. I used a device with 10 qubits and 3 estimation wires. This ran in a couple of seconds. So if you’re having slowdowns it’s because of the code you’re using in the solution.

I would recommend that you test with a simpler code.

Something else you could try is resetting the code to the original template and seeing if this takes too long to run. If the “reset” version of the code takes too long then there may be a separate issue and we can investigate. Let me know how this test goes for you.

Important note: the “reset code” button will delete any modifications you have made to this specific codercise. Please make sure to save your code somewhere else if you wish to keep it, since it cannot be recovered once you hit “reset code”.