## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
vashisth malik
I know the difference between Identity and X gate and there adjoint are they themselves. But i did not understand coding part like this part "operation Solve (unitary : (Qubit => Unit is Adj+Ctl)) : Int " is in this part we are calling qubit to unitary ? Any resource to understand this will be helpful?
@VashisthMalik_twitter: The type of an operation that takes an input of type 'T and that returns an output of type 'U is written as 'T => 'U; thus, unitary : (Qubit = > Unit is Adj + Ctl) indicates that unitary takes a Qubit input and returns Unit. The is Adj + Ctl tells you that unitary is adjointable and controllable (very important for some of the contest problems!). In this case, we can read the signature of Solve as telling us that it takes an adjointable and controllable single-qubit operation, and returns an Int.
Stream's now live, by the way, if you want to learn more about the internals of the Q# compiler! ðŸ’•
vashisth malik
on which i perform functor like Adjoint Unitary (?) . what is the name of qubit ? is it qubit itself?
vashisth malik
is it qs?
@VashisthMalik_twitter: Applying the Adjoint functor to an adjointable operation doesn't change the type of that operation. For example, Microsoft.Quantum.Intrinsic.X has type Qubit => Unit is Adj + Ctl, such that Adjoint X also has type Qubit => Unit is Adj + Ctl. In the example from the contest problem, Adjoint unitary is an operation with type (Qubit => Unit is Adj + Ctl). By contrast, for a controllable operation op, Controlled op does modify the type to add the new control register. For more detail, you can checkout my book with @crazy4pi314 at bit.ly/qsharp-book, or the Microsoft Quantum docs at https://docs.microsoft.com/quantum/user-guide/using-qsharp/operations-functions#controlled-and-adjoint-operations.
Amir Ebrahimi
@amirebrahimi
Hi there - I assume most people here are working on the Q# Challenge. When I try to run https://github.com/microsoft/MLADS2020-QuantumClassification/blob/master/QuantumClassification/ExploringQuantumClassificationLibrary.ipynb locally I get the following errors from jupyter notebook:
IQSharpError: The Q# kernel raised the following errors:
C:/Users/AmirEbrahimi/dev/qc/CodeForces2020/Warmup/notebook/Backend.qs(6,10): error QS6104: No namespace with the name "Microsoft.Quantum.Intrinsic" exists.
C:/Users/AmirEbrahimi/dev/qc/CodeForces2020/Warmup/notebook/Backend.qs(9,10): error QS6104: No namespace with the name "Microsoft.Quantum.MachineLearning" exists.
C:/Users/AmirEbrahimi/dev/qc/CodeForces2020/Warmup/notebook/Backend.qs(19,38): error QS6005: No type with the name "ControlledRotation" exists in any of the open namespaces.
C:/Users/AmirEbrahimi/dev/qc/CodeForces2020/Warmup/notebook/Backend.qs(12,54): error QS6005: No type with the name "SamplingSchedule" exists in any of the open namespaces.
C:/Users/AmirEbrahimi/dev/qc/CodeForces2020/Warmup/notebook/Backend.qs(33,23): error QS5022: No identifier with the name "Mapped" exists.
...
It looks like when qsharp.reload happens and it finds a .qs file in the directory that it somehow doesn't have the full qsharp environment ?
Mariia Mykhailova
@amirebrahimi Check that the IQ# version you have installed is the same as the version used by the tutorial, and either install older IQ# or update the tutorial to newer version (if you do that, make sure you update both the Jupyter notebook and the csproj file).
Harshit Garg
@githg22_gitlab
How do you people use prettier w/ Q#?
Considering there isn't a formatter yet
Gopal Ramesh Dahale
@Gopal-Dahale
I am not able to think about how to start with problem A5 (Z vs -Z). Can anyone give me a starting Hint? Global phase makes all my measurements same.
Harshit Garg
@githg22_gitlab
Well, it didn't work out w/ just one qubit for me
And you can't differentiate b/w them with simple |0> and |1>
Think some clever superposition
Harshit Garg
@githg22_gitlab
People who completed the machine learning tasks,
How did you decide upon which design to use?
How do I generally decide in what way to design a circuit
Mariia Mykhailova
@Gopal-Dahale Does the "official" hint from the contest help you? "Z and -Z gates differ by a global phase they introduce, so you cannot distinguish them by applying them to a single qubit. Take advantage of the fact that the given unitary has controlled variant defined."
Mariia Mykhailova
@githg22_gitlab In this particular case your data is encoded in just 1 qubit, so you have a choice of Rx, Ry and Rz gates :-) In general that's the same kind of challenge that classical machine learning faces - you need to figure out the feature engineering and the model structure before you can train it
Amir Ebrahimi
@amirebrahimi

@amirebrahimi I think it's the same issue as discussed at https://quantumcomputing.stackexchange.com/questions/12466/qsharp-reload-throws-error-in-python and in comments at https://codeforces.com/blog/entry/77614

This fixed it for me. Thank you @tcNickolas_twitter!

vashisth malik
hey there i need some help in increment problem. every term in this Question is new to me. can you please explain the Question?
Amir Ebrahimi
@amirebrahimi
@VashisthMalik_twitter - can you share a bit more about what you don't understand?

Re: D1 - I'm trying to modify the ClassifierStructure() to simply add an additional controlled rotation:
ControlledRotation((1, new Int[0]), PauliY, 1)
but get the following error:
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. ---> Microsoft.Quantum.MachineLearning.EstimateGradient on D:\a\1\s\submodules\QuantumLibraries\MachineLearning\src\GradientEstimation.qs:line 78 at Microsoft.Quantum.MachineLearning._RunSingleTrainingStep on D:\a\1\s\submodules\QuantumLibraries\MachineLearning\src\Training.qs:line 148 at Microsoft.Quantum.MachineLearning._RunSingleTrainingEpoch on D:\a\1\s\submodules\QuantumLibraries\MachineLearning\src\Training.qs:line 229 at Microsoft.Quantum.MachineLearning._TrainSequentialClassifierAtModel on D:\a\1\s\submodules\QuantumLibraries\MachineLearning\src\Training.qs:line 388 at Microsoft.Quantum.MachineLearning.TrainSequentialClassifierAtModel on D:\a\1\s\submodules\QuantumLibraries\MachineLearning\src\Training.qs:line 322 at Microsoft.Quantum.MachineLearning.TrainSequentialClassifier on D:\a\1\s\submodules\QuantumLibraries\MachineLearning\src\Training.qs:line 98 at Microsoft.Quantum.Kata.QuantumClassification.TrainLinearlySeparableModel on C:\Users\AmirEbrahimi\dev\qc\CodeForces2020\Warmup\notebook\Backend.qs:line 0

I've dug through the source on GitHub a bit and it seems it is failing at estimating the number of qubits needed. Any ideas of how to resolve this? I would think simply by adding that ControlledRotation with another qubit referenced that it would expand the number of qubits.

vashisth malik
@amirebrahimi What i understand from the Question is that we have a register of little Endian and than i have to increment it with X gate and its Controlled variant? But i donot know how put operation on little endian what will be the syntax?
Amir Ebrahimi
@amirebrahimi

So, this isn't immediately apparent, but you need to use the unwrap '!' operator to get at the qubits:
https://docs.microsoft.com/en-us/quantum/user-guide/language/expressions#unwrap-expressions

e.g. - register![0]

As far as the rest, you need to consider how adders work and the equivalent on a quantum computer (that is also reversible).

Harshit Garg
@githg22_gitlab

@githg22_gitlab In this particular case your data is encoded in just 1 qubit, so you have a choice of Rx, Ry and Rz gates :-) In general that's the same kind of challenge that classical machine learning faces - you need to figure out the feature engineering and the model structure before you can train it

But I'm getting a very high value of Miss rate (0.4)

Using LocalRotationsLayer(1, PauliX)
And indeed with PauliY and PauliZ
Mariia Mykhailova
@amirebrahimi The number of qubits required is not defined by the indices of qubits used in the model, it's defined by the encoding used in the model. In this case the model uses only 1 qubit, so you can't reference qubit with index 1, only 0
Amir Ebrahimi
@amirebrahimi
@githg22_gitlab - what's the difference between LocalRotationsLayer and ControlledRotations?
@tcNickolas_twitter - how come the halfmoon example has more than 1 qubit interactions?
Mariia Mykhailova
@githg22_gitlab The miss rate depends not only on the model structure but also on the parameters. It is possible to have 100% miss rate with correct model and incorrect parameters :-) As a hint, you need one Ry gate
@amirebrahimi HalfMoons uses a different encoding scheme - I wrote about it at https://codeforces.com/blog/entry/77614?#comment-641653
Harshit Garg
@githg22_gitlab

@githg22_gitlab - what's the difference between LocalRotationsLayer and ControlledRotations?

It applies the uncontrolled rotations, so far as I have understood

Amir Ebrahimi
@amirebrahimi
Thank you both.
@amirebrahimi: This is actually a broader community for Q# developers and users, but it's really cool to see everyone from the contest! If you're interested in the Q# community, I'd encourage checking out what the Q# community has done at https://qsharp.community. There's some neat blog posts, GitHub projects, and so forth hosted there.
@githg22_gitlab: There's indeed not a formatter for Q# yet, but that could be a great feature request at https://github.com/microsoft/qsharp-compiler/, or if you'd like to contribute one yourself, you may be interested in checking out some other compiler extensions such as the one @crazy4pi314 and @bettinaheim were working on in their stream yesterday at https://www.twitch.tv/videos/649894848 and in @crazy4pi314's fork at https://github.com/crazy4pi314/qsharp-compiler.
Harshit Garg
@githg22_gitlab

@githg22_gitlab: There's indeed not a formatter for Q# yet, but that could be a great feature request at https://github.com/microsoft/qsharp-compiler/, or if you'd like to contribute one yourself, you may be interested in checking out some other compiler extensions such as the one @crazy4pi314 and @bettinaheim were working on in their stream yesterday at https://www.twitch.tv/videos/649894848 and in @crazy4pi314's fork at https://github.com/crazy4pi314/qsharp-compiler.

I'll check them out thanks

Amir Ebrahimi
@amirebrahimi
Well, that was a lot of fun :) I see you came out right above me @githg22_gitlab. It's quite hilarious to me how much of the time I spent was just about getting the dev environment set up, learning how the Q# QML approach is architected, and figuring out how to reduce the training time iterations.

@amirebrahimi: This is actually a broader community for Q# developers and users, but it's really cool to see everyone from the contest! If you're interested in the Q# community, I'd encourage checking out what the Q# community has done at https://qsharp.community. There's some neat blog posts, GitHub projects, and so forth hosted there.

Thanks, @cgranade - I remember hearing about this community a while back I think from an interview you had either on QCN or meQuanics. Good to finally jump into Q# and give it a try. It's an interesting model and very different from the rest. In some ways I feel more restricted though.

Harshit Garg
@githg22_gitlab

Well, that was a lot of fun :) I see you came out right above me @githg22_gitlab. It's quite hilarious to me how much of the time I spent was just about getting the dev environment set up, learning how the Q# QML approach is architected, and figuring out how to reduce the training time iterations.

Haha. I agree with a lot of time spent over setting up the environment.

@amirebrahimi: No worries, happy to help, and glad you're having fun jumping into Q#! If I may ask to try and understand, what do you mean by more restricted?
@githg22_gitlab: No worries, happy to help!
Sarah Kasier
@crazy4pi314

Welcome everyone, its really exciting to see so many new faces here! Hopefully the warm-ups have been going well ðŸ˜„

@githg22_gitlab I have been wanting to work on a Q# linter/code formatter for a while, that would be a great project if you wanted to collaborate with the community here! (also my code would look so much nicer :P )

Sarah Kasier
@crazy4pi314
And to build on what @cgranade mentioned, the qsharp.community group is a great place for sharing and building your Q# code and knowledge! We are always looking for posts on any Q# related projects you are working on, projects for folks to collaborate building and that the community can help maintain as the language evolves. Some great examples of posts can be found on the blog and we have a growing collection of projects too! I am working on a project with some other community members where we are creating a new library to implement memory for a quantum computer (sometimes called qRAM).
Amir Ebrahimi
@amirebrahimi

@cgranade - It's nuanced for me and perhaps just temporary by the current level of documentation or feature set: not being able to construct a gate from a unitary directly, not being able to easily construct a kronecker product of pauli matrices without having to create a new operation, not being able to print the circuit easily (or having the concept of a circuit), etc. I think having used Cirq a little bit and mostly having used Qiskit it's me adjusting to the difference.

Now on the + side: I love being able to use Visual Studio (keybindings for commenting selected blocks would go a long way though!). I love having the easy connection to work with C#. I love the representation of data structures in QDK.

Thanks, @crazy4pi314 / @cgranade - Also, happily picked up a copy of your book during ISCA 2020 w/ the promo.
Sarah Kasier
@crazy4pi314
I can address maybe a little bit of this:
• Re: the kronecker product you don't have to do this in Q#. If you want to apply say XYXZ to a register of 4 qubits you can use the ApplyPauli operation. One of the design goals of Q# is to get the user to be thinking about the algorithms at a higher level and not needing to construct matrices.
And yeah I use visual studio code and having intelesense there is hella nice