microsoft / qsharp

Azure Quantum Development Kit, including the Q# programming language, resource estimator, and Quantum Katas
https://microsoft.github.io/qsharp/
MIT License
464 stars 93 forks source link

ApplyQFT operation name is misleading #1812

Open tcNickolas opened 4 months ago

tcNickolas commented 4 months ago

To follow up https://github.com/microsoft/qsharp/pull/1810 and the internal discussion on this: using ApplyQFT name for an operation that applies only a part of QFT is misleading and can lead to long and unpleasant debugging sessions. I would suggest renaming it to something like ApplyQFTRotations, which is a more accurate name, since it accurately describes that only the rotations part of the QFT is applied, and to introduce a new operation ApplyQFT that actually applies a complete QFT.

For example, I'm working on the second part of QFT kata, and every task in it includes applying either QFT or Adjoint QFT. We don't have dependencies between kata cells, and we don't have a single operation to apply QFT, so I have to include instructions regarding this in every task. I will run into the same issue when working on the QPE kata, programming assignments that include QFT and QPE, and so on.

DmitryVasilevsky commented 3 months ago

I just want to mention a couple of arguments in favor of having a function that doesn't include swaps after QFT rotations.

  1. Sometimes additional swaps are not necessary, and the results can be harvested without applying swaps. Sometimes using Reversed() on the register is sufficient without applying actual swaps. Both approaches use fewer quantum gates than the actual SwapReverseRegister().
  2. Wikipedia article doesn't include SWAPs in the pictured QFT circuit.

When we started modernizing QDK we wanted to include only minimal functionality. That said, nothing prevents us from having both functions now.