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

Use single gates.py file for all backends #372

Merged
merged 25 commits into from
Apr 7, 2021
Merged

Use single gates.py file for all backends #372

merged 25 commits into from
Apr 7, 2021

Conversation

stavros11
Copy link
Member

This simplifies our code base by removing the cgates.py file and using a single file to implement gates for all different backends. To do so, I moved the functions that apply gates (state_vector_call and density_matrix_call) to the backends. As discussed in #363 I also removed the prepare and reprepare methods from gates as they are not needed anymore.

I tested the multi-GPU performance of this branch and it is the same as master so there is no fix required for that regard. The memory and performance for very deep circuits is also the same with what reported in #363.

@codecov
Copy link

codecov bot commented Apr 1, 2021

Codecov Report

Merging #372 (429f2fd) into tfmem (4041aa5) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             tfmem      #372    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           78        77     -1     
  Lines        12724     12426   -298     
==========================================
- Hits         12724     12426   -298     
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/backends/einsum.py 100.00% <ø> (ø)
src/qibo/tensorflow/distutils.py 100.00% <ø> (ø)
src/qibo/tests/test_density_matrix.py 100.00% <ø> (ø)
src/qibo/tests/test_variational.py 100.00% <ø> (ø)
src/qibo/tests_new/test_core_gates.py 100.00% <ø> (ø)
src/qibo/tests_new/test_measurement_gate.py 100.00% <ø> (ø)
src/qibo/abstractions/abstract_gates.py 100.00% <100.00%> (ø)
src/qibo/abstractions/gates.py 100.00% <100.00%> (ø)
src/qibo/backends/__init__.py 100.00% <100.00%> (ø)
src/qibo/backends/abstract.py 100.00% <100.00%> (ø)
... and 17 more

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 4041aa5...429f2fd. Read the comment docs.

def __init__(self):
super().__init__()
self.gates = tuple()
# create inversion gates to rest to the original state vector
Copy link
Member

Choose a reason for hiding this comment

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

rest -> restore/reset?

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.

@stavros11 thanks for this cleanup, the code is much simpler to follow.

@scarrazza scarrazza merged commit 002c172 into tfmem Apr 7, 2021
@delete-merged-branch delete-merged-branch bot deleted the gatebackends branch April 7, 2021 10:09
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.

2 participants