question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

defgate: No validation whether the matrix is unitary

See original GitHub issue

Hi,

This is not a feature request, I’m just trying to wrap my head around the infrastructure - if this is not the right place to ask, please let me know where I can ask learning questions as a total newbie to quantum computing and the Rigetti stack.

I was wondering what is the reason behind that I can create a quantum gate based on a non-unitary matrix? Is this something I’d have to be careful about in the future as well, or Forest is planned to have a feature to validate against non-unitary operators? Also, it’s one thing that it can run on the QVM - but how would this operate on a real quantum processor?

>>> import pyquil.quil as pq 
>>> import numpy as np
>>> import pyquil.forest as forest
>>> qvm = forest.Connection()
>>> non_unitary_mx =np.array(([1.0, 2.0], [3.0, 4.0]))
>>> bad_prog = pq.Program().defgate("NON-UNITARY-BAD-GATE", non_unitary_mx)
>>> bad_prog.inst(("NON-UNITARY-BAD-GATE",0))
<pyquil.quil.Program object at 0x1096e92d0>
>>> bad_prog.inst(("NON-UNITARY-BAD-GATE",1))
<pyquil.quil.Program object at 0x1096e92d0>
>>> print bad_prog
DEFGATE NON-UNITARY-BAD-GATE:
    1.0, 2.0
    3.0, 4.0

NON-UNITARY-BAD-GATE 0
NON-UNITARY-BAD-GATE 1

>>> print qvm.wavefunction(bad_prog)
(array([ 1.+0.j,  3.+0.j,  3.+0.j,  9.+0.j]), [])

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stylewarningcommented, Mar 6, 2017

I thought I might note what the Quil spec says about this.

The gate is declared using the DEFGATE directive followed by comma-separated lists of matrix entries indented by exactly four spaces. Matrices that are not unitary (up to noise or precision) have undefined [7] execution semantics.

[7] Software processing Quil is encouraged to warn or error on such matrices.

Accordingly, an implementer of Quil can define how he or she pleases what happens when someone defines a non-unitary gate.

0reactions
willzengcommented, Mar 6, 2017

Closed by #21

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a Unitary Matrix and How to Prove that a ... - YouTube
In this video I will define a unitary matrix and teach you how to prove that a matrix is unitary. To do this...
Read more >
Unitary Matrices - TAMU Math
A matrix U ∈ Mn is said to be unitary if U*U = I. [If U ∈ Mn(R) and UT U = I,...
Read more >
Unitary matrix - Wikipedia
In linear algebra, a complex square matrix U is unitary if its conjugate transpose U* is also its inverse, that is, if.
Read more >
Unitary matrix - StatLect
A unitary matrix is a complex square matrix whose columns (and rows) are orthonormal. It has the remarkable property that its inverse is...
Read more >
How do I test if a matrix is unitary? - MATLAB Answers
My current test for a unitary matrix is shown in the code, I'd also like to know if U = e^(iH) [i is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found