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

Update Magicl bindings for Magicl NG #238

Merged
merged 5 commits into from
Feb 28, 2020
Merged

Conversation

colescott
Copy link
Member

This is to update all magicl bindings to work with quil-lang/magicl#63.

Benchmarks need to be done prior to merging to make sure there is not a significant performance hit.

@colescott colescott added the / ! \ DO NOT MERGE / ! \ Do not merge! label Feb 3, 2020
@colescott colescott requested a review from a team as a code owner February 3, 2020 22:15
@colescott colescott self-assigned this Feb 3, 2020
Copy link
Contributor

@appleby appleby left a comment

Choose a reason for hiding this comment

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

Looking good! Nice to see some examples of the new-and-improved magicl in the wild. Seems like a nice usability & ergonomics improvement.

(reduce #'+ (magicl:matrix-diagonal
(density-matrix (magicl:from-array prepared-state
(list rows cols)
:type '(complex double-float))))
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as the compiler doesn't complain, maybe the :type here should be qvm:cflonum instead? ditto elsewhere below.

@@ -249,7 +249,7 @@ The function will just return NIL, and modify the contents of RESULT."
(:method ((gate quil:simple-gate))
(make-instance 'quil:simple-gate
:name (concatenate 'string (quil:gate-name gate) "*")
:matrix (magicl:conjugate-entrywise (quil:gate-matrix gate))))
:matrix (magicl:map! #'conjugate (quil:gate-matrix gate))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the ! indicate mutation? I don't know if it matters here, but the old conjugate-entrywise did not mutate the input.

Copy link
Contributor

Choose a reason for hiding this comment

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

@colescott what about this one? ok to map!?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

No we very much shall not mutate. You're destroying the environment aka the original gate binding matrix.

@colescott colescott added enhancement New feature or request and removed / ! \ DO NOT MERGE / ! \ Do not merge! labels Feb 27, 2020
@notmgsk
Copy link
Member

notmgsk commented Feb 28, 2020

@stylewarning smash the merge button

@@ -249,7 +249,7 @@ The function will just return NIL, and modify the contents of RESULT."
(:method ((gate quil:simple-gate))
(make-instance 'quil:simple-gate
:name (concatenate 'string (quil:gate-name gate) "*")
:matrix (magicl:conjugate-entrywise (quil:gate-matrix gate))))
:matrix (magicl:map! #'conjugate (quil:gate-matrix gate))))
Copy link
Member

Choose a reason for hiding this comment

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

No we very much shall not mutate. You're destroying the environment aka the original gate binding matrix.

@@ -259,5 +259,5 @@ The function will just return NIL, and modify the contents of RESULT."
:name (concatenate 'string (quil:gate-name gate) "*")
:dimension (quil:gate-dimension gate)
:matrix-function #'(lambda (&rest parameters)
(magicl:conjugate-entrywise
(apply #'quil:gate-matrix gate parameters))))))
(magicl:map! #'conjugate
Copy link
Member

Choose a reason for hiding this comment

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

no bueno

@stylewarning
Copy link
Member

@colescott if u dont stop mutating im going to force us all to write HASKELL instead

@colescott
Copy link
Member Author

@colescott if u dont stop mutating im going to force us all to write HASKELL instead

Promise?

@stylewarning stylewarning merged commit 300a017 into master Feb 28, 2020
@stylewarning stylewarning deleted the feature/magicl-ng branch February 28, 2020 21:11
@notmgsk notmgsk mentioned this pull request Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants