Conversation
matanvax2
left a comment
There was a problem hiding this comment.
Looks nice!
I posted a few minor comments
| // this qubit implements the marking oracle used inside amplitude amplification iterations. | ||
|
|
||
|
|
||
| // Defining the QStruct, containing the quantum variables a and b |
There was a problem hiding this comment.
This is Qmod/native, so the keyword is qstruct, not QStruct.
I use the following -
// Encapsulate the quantum variables a and b in a quantum struct
| A_BITS: int = 2; | ||
| B_BITS: int = 2; | ||
|
|
||
| PROBLEM_QUBITS: int = A_BITS + B_BITS; // 4 qubits: a[2] || b[2] |
There was a problem hiding this comment.
This is redundant, the information is already in the definition of OracleVars.
There was a problem hiding this comment.
right, fixed
| allocate(problem_vars); | ||
| allocate(indicator); | ||
| est_var: qbit[]; | ||
| problem_vars: qbit[PROBLEM_QUBITS]; |
There was a problem hiding this comment.
Why declare it of type qubit array and not OracleVars? It makes more sense to use this abstraction, and it doesn't require a separate declaration of the sizes.
There was a problem hiding this comment.
right!, fixed
| @@ -1,23 +1,58 @@ | |||
| // Quantum Counting via Quantum Phase Estimation (QPE) | |||
There was a problem hiding this comment.
Same comments from above apply here.
| @@ -1,3 +1,7 @@ | |||
| // Add Bell states | |||
| } | ||
| } | ||
|
|
||
| TARGET_SIZE: int = 4; // Size of the target quantum variable |
There was a problem hiding this comment.
I don't think this is worth factoring out as it carries no additional meaning. IMO it's enough to use the declaration -
psi: qbit[4];
| allocate(1, expectation_value); | ||
| allocate(4, psi); | ||
| psi: qbit[]; // | ||
| allocate(1, expectation_value); // Ancilla qubit used for the Hadamard test |
There was a problem hiding this comment.
The '1' is redundant here. It's a single qubit variable.
| allocate(4, psi); | ||
| psi: qbit[]; // | ||
| allocate(1, expectation_value); // Ancilla qubit used for the Hadamard test | ||
| allocate(TARGET_SIZE, psi); // Initializes the target state |
There was a problem hiding this comment.
Here the size is redundant, assuming that it is used to declare the variable (there is no size polymorphism in this code)
|
|
||
|
|
||
| // Performs the Hadamard test utilizing the within-applied function implementing | ||
| // V^dagger U V, where V is the Hadamard gate and U is the controlled_qft function. |
There was a problem hiding this comment.
I think it's conventional to talk schematically using the sequence U V U-dagger, is it on purpose that this is different?
There was a problem hiding this comment.
I followed the notebook, that's where the difference comes. I exchanged the U and V but left the dagger on the left operator since that is what is written in the within_apply documentation. In addition changed the ^ to -, this difference comes from a latex convention.
279412a to
5d2f641
Compare
|
🔥 Incredible, @roie-d-classiq! You've merged your 17th PR! 🎯🎊 Your ongoing commitment to classiq-library is truly remarkable. You're a driving force in our community! 🚀 We are grateful for your dedication! 💫 |
PR Description
Some notes
Please make sure that the notebook runs successfully with the latest Classiq version.
Please make sure that you placed the files in an appropriate folder
.ipynband.qmodto be unique across this repository..qmod,.synthesis_options.json,.metadata.jsonIf applicable, please include link to the paper on which the notebook is based, in the notebook itself.
Please use
rebaseon your branch (no merge commits)Please link this PR to the relevant issue
Please make sure to run
pre-commitwhen commiting changesgitin the terminal, make sure to installpre-commitvia runningpip install pre-commitfollowed bypre-commit installpre-commitdocumentationpre-commit.pre-commitmay minorly alter some files. Make sure togit addthe changes done bypre-commit