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

Add qibojit backend #427

Merged
merged 139 commits into from
Jul 9, 2021
Merged

Add qibojit backend #427

merged 139 commits into from
Jul 9, 2021

Conversation

stavros11
Copy link
Member

Adds new backend that loads custom operators from the qibojit library. The new backend is not tested in CI until the qibojit library is released.

@codecov
Copy link

codecov bot commented Jun 10, 2021

Codecov Report

Merging #427 (978340d) into master (3541e4b) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #427   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           83        83           
  Lines        11827     11866   +39     
=========================================
+ Hits         11827     11866   +39     
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/tests/conftest.py 100.00% <ø> (ø)
src/qibo/__init__.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%> (ø)
src/qibo/backends/numpy.py 100.00% <100.00%> (ø)
src/qibo/backends/tensorflow.py 100.00% <100.00%> (ø)
src/qibo/config.py 100.00% <100.00%> (ø)
src/qibo/core/callbacks.py 100.00% <100.00%> (ø)
src/qibo/core/circuit.py 100.00% <100.00%> (ø)
... and 43 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 3541e4b...978340d. Read the comment docs.

def _result_tensor(self, result):
n = len(result)
result = sum(2 ** (n - i - 1) * r for i, r in enumerate(result))
return self.cast(result, dtype="DTYPEINT")
Copy link
Member

Choose a reason for hiding this comment

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

Does this operation is strictly necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think yes, because the custom operators for collapse expect the result to be integer (in decimal form) while the other backends use the array form which represents the same number in binary. Note that this is a new addition here, we already do exactly the same conversion inside core.gates.M (see here in master). I just moved the conversion at the backend level in this PR because it is slightly different for qibojit and qibotf so it is easier to implement this way.

There may be a way to avoid this conversion by using decimal as the default representation for result and convert to binary when using the numpy/tensorflow backends.

src/qibo/core/circuit.py Outdated Show resolved Hide resolved
@scarrazza scarrazza marked this pull request as ready for review July 9, 2021 07:00
@scarrazza scarrazza merged commit 47ad4ad into master Jul 9, 2021
@scarrazza scarrazza deleted the qibojit branch July 10, 2021 17:01
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