Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples grover #389

Merged
merged 29 commits into from
Apr 26, 2021
Merged

Examples grover #389

merged 29 commits into from
Apr 26, 2021

Conversation

AdrianPerezSalinas
Copy link
Contributor

Merging over grovermodel

@scarrazza scarrazza changed the base branch from master to grovermodel April 19, 2021 14:18
@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #389 (2f9f151) into grovermodel (6681af2) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##           grovermodel      #389   +/-   ##
=============================================
  Coverage       100.00%   100.00%           
=============================================
  Files               79        80    +1     
  Lines            12689     12731   +42     
=============================================
+ Hits             12689     12731   +42     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/qibo/core/gates.py 100.00% <ø> (ø)
...qibo/tests_new/test_tensorflow_custom_operators.py 100.00% <ø> (ø)
src/qibo/__init__.py 100.00% <100.00%> (ø)
src/qibo/optimizers.py 100.00% <100.00%> (ø)
src/qibo/tests_new/test_prints.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6681af2...2f9f151. Read the comment docs.

@scarrazza
Copy link
Member

@AdrianPerezSalinas thanks for this. I have noticed that the sphinx documentation is not rendering properly, could you please have a look?

@@ -0,0 +1,123 @@
# A General Grover Model

This examples provide information to run a general Grover model accesible as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These / or better "The examples presented here..."


- oracle (`qibo.core.circuit.Circuit`): quantum circuit that flips
the sign using a Grover ancilla initialized with -X-H-. Grover ancilla
expected to be last qubit of oracle circuit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the last?

The found bitstring not included.
- iterative (bool): force the use of the iterative Grover

We provide three different examples to run Grover with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with:

In this first example we show how to use a standard Grover search where the
search space is an equally weighted superposition of quantum states and the oracle
is simply defined through a layer of Hadamard gates. This example makes no use of
ancilla qubits, so the syntaxis simplifies greatly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the syntax, or the command lines / function calls?


### Example 3: Ancillas for superposition and oracle, setting size of search space

In this third example we create a Grover model with two components
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

components:

@@ -0,0 +1,21 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

solution, iterations = grover()

print('The solution is', solution)
print('Number of iterations needed:', iterations)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line.

Copy link
Member

@scarrazza scarrazza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this implementation, I have included some comments above, in general however would be great if you could convert the file to PEP8 convetion and include these files in test_examples.py.

scarrazza and others added 3 commits April 21, 2021 12:13
@AdrianPerezSalinas
Copy link
Contributor Author

Hi @scarrazza ,

I think everything is fixed now, please let me know if there is anything wrong


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--qubits", default=5, type=int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdrianPerezSalinas this example is not working for me, it crashes at line 20.
Could you please rename qubits in nqubits in order to match the syntax of other examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the problem come from this mismatch? I have tested it and it works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the test_examples.py file run? I cannot see it clearly and I think here is where the problem lies

@@ -0,0 +1,123 @@
# A General Grover Model

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a reference link to the code, as we do in all tutorials.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@scarrazza scarrazza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me suggest to move the examples to:

  • example1.py
  • example2.py
  • example3.py

@scarrazza scarrazza merged commit a7da4d1 into grovermodel Apr 26, 2021
@delete-merged-branch delete-merged-branch bot deleted the examples_grover branch April 26, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants