-
Notifications
You must be signed in to change notification settings - Fork 6
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
AngleOp::adiv
is ambiguous
#605
Comments
I agree we should remove for this reason. The "law" Also, adiv should return an option type for the case where the divisor is 0. I am not creating an issue for this on the assumption that the op will be removed. |
Possibly too picky but...
Not if you're a spin-1/2 fermion, a mobius strip, or a (2+1)D manifold with holes! Ok, silly examples for this, but there's a more pressing one. The R gate (a.k.a. phased x) is defined as:
In this case, There are possibly some more useful examples, but this is the first one that springs to mind.
I think windings could be taken into account through a fixed point angle that doesn't have the 'point' before the MSB, but somewhere in the middle. For example, if we have 64 bits of angle, the first byte could be an integer component:
This leaves us with up to 255 'windings' (that may be considered moot or not, depending on the scenario) and still allows the angle component to be represented to one part in 72 quadrillion. A finer balance may be struck, e.g. 16 bits of winding and 40 bits of angle. However, one might argue that the intent of a division depends on the situation - and in this case we might want a 'pure' angle and a 'wound' (?) angle type, each with a well defined division. Would that be too confusing for users? |
Yes, in pytket we consider angle parameters to be defined mod 2π for some ops and mod 4π for others. The difference this makes is at most a global phase. But in all cases where it is 4π (such as your R example), it could (arguably should) equally have been defined in terms of a mod-2π angle (by halving/doubling the parameters in the definition). Alternatively there could be separate types (mod-2π angles and mod-4π angles) but I think that's overkill. I think in the rare cases where it really matters, winding number and angle can be stored as separate variables (integer, angle) in the user's program, and we don't need a core type for this. |
This particular one could easily be rewritten as a = angle(-0.25 * t)
q2 = rz(q2, a)
q1, q2 = cx(q1, q2)
q2 = rz(q2, -a)
return cx(q1, q2) |
Agree Storing the windings basically means, angles are no longer identified modulo 2pi. At that point it's a different choice of precision (/when does truncation happen), etc. Not saying whether it might be better or worse than float / nondyadic rational, but it's in the same space, so one should compare those different "number types" just in terms of when truncation happens, etc. |
Closes #610 Closes #608 Closes #605 BREAKING CHANGE: "tket2.angle" extension replaced with "tket2.rotation" extension with rotation type and simplified set of operations. --------- Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com> Co-authored-by: Douglas Wilson <douglas.wilson@quantinuum.com>
Angles are equivalence classes mod 2π; but division by an integer (in contrast to multiplication by an integer) is not invariant under that equivalence: e.g. 0 ≡ 2π but 0/2 ≢ (2π)/2.
I would rather like to get rid of this operation for this reason, but if we do keep it we should specify the semantics, probably by coercing the initial argument to be in [0, 2π) or [-π, π). (Note that if we chose [0, 2π) then dividing e.g. the angle -π/2 by 2 would give us 3π/4, which may be unexpected.)
The text was updated successfully, but these errors were encountered: