Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

BasicGates kata: Improve test harness #147

Merged
merged 3 commits into from
Jul 16, 2019

Conversation

tcNickolas
Copy link
Member

As was pointed out in #146, task solutions which add extra global phase can be confusing for the learner. This change modifies the test harnesses for part I to check that the solutions do exactly the transformation required and to fail if the solution adds a global phase.

As was pointed out in #146, task solutions which add extra global phase can be confusing for the learner. This change modifies the test harnesses for part I to check that the solutions do exactly the transformation required and to fail if the solution adds a global phase.
@cgranade
Copy link
Contributor

I'm not sure I entirely agree on this point? One of the strengths of Q# thus far has been its commitment to operationalism, in that that only differences which are physically observable are then observable in Q#. Taking that philosophy, two feasible solutions which differ by a global phase are identical solutions.

Checking the action of each solution under the Controlled functor then adds an additional constraint not currently specified in the task description (namely that the task solution is controllable and applies the prescribed basis transformation when controlled), such that I would think we'd need to at least modify the description accordingly.

@tcNickolas
Copy link
Member Author

The ability to ignore the global phase depending on the situation is a deep philosophical concept, which is beyond the scope of this kata. On the other hand, quietly and habitually ignoring the global phase 1) is very confusing for a beginner who reads the solution for the task and tries to figure out why the transformation done by the solution differs from what the task was asking for, as indicated in #146, and 2) can cause very interesting troubleshooting sessions like #94.

I plan to create a tutorial addressing specifically the nuances of working with the phase; however, in this kata (which for most solvers is the very first attempt to try out quantum computing gates) it is better to check that the transformation that passes the tests is exactly the same as the transformation required.

I will add some language addressing the +Ctl part. It's not a heavy burden, given that at this point people only use intrinsic gates, so it is very hard to come up with something that would not be automatically controllable; on the other hand, if the kata starts with a requirement to write your code in a way that allows to generate adjoint and controlled variants automatically, it has to explain what these are - and this will get very scary very fast.

Copy link
Contributor

@alan-geller alan-geller left a comment

Choose a reason for hiding this comment

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

I'm a strong proponent of operationalism, but I understand the issue for beginners as well. What might be a reasonable compromise would be to put a note in the Tests.qs file explaining that the tests are done in a rather non-obvious way (using the Controlled specialization instead of the plain operation) in order to make sure that the (physically irrelevant) global phase is correct. You could even point out that you have to use the Controlled specialization because that makes the absolute phase of the base operation visible by making it relative to the identity -- although that might be more text than would comfortably fit.

@tcNickolas tcNickolas merged commit e6ebcb6 into master Jul 16, 2019
@tcNickolas tcNickolas deleted the mariia/improve-basicgates-harness branch July 16, 2019 06:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants