Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Mridul Sarkar
    @mridulsar
    Oh wow, haha should have got some sleep and worked on it. That did it for me. Thanks for catching that @samarsha
    Sarah Kasier
    @crazy4pi314
    Good catch @samarsha ๐Ÿ’—
    Sarah Marshall
    @samarsha
    No problem :) It would be cool if the error message/IDE was more helpful here, there's a feature request for that: microsoft/qsharp-compiler#205
    Chris Granade
    @cgranade
    @samarsha Nice! ๐Ÿ’•
    @amirebrahimi: Apologies for missing your message! I guess my suggestion was just that an ApplyUnitaryOperation operation that takes a Complex[][] input to describe a unitary and a LittleEndian register to apply it to would be a nice parallel to the existing PrepareArbitraryState operation.
    Amir Ebrahimi
    @amirebrahimi
    Thanks for confirming, @cgranade. Sounds like something fun to work on. I'll dig around to see how hard it is to convert arbitrary unitaries to gate operations.
    Harshit Garg
    @githg22_gitlab
    Do I need to update my Q# for the codeforces main event?
    I have 2005 one rn
    Just asking in advance
    Since I saw there was a 2006 version release
    Mariia Mykhailova
    @tcNickolas_twitter
    @githg22_gitlab I'm not sure we even have 2005... :-) Codeforces tester uses 0.11.2004.2825, same as in the warmup round
    Harshit Garg
    @githg22_gitlab
    My bad. Must be 2004 then.
    Seems good then, thanks
    Chris Granade
    @cgranade
    You can always see the list of releases for any given package at nuget.org. For instance, the list of versions for the IQ# tool are up at https://www.nuget.org/packages/Microsoft.Quantum.IQSharp. As @tcNickolas_twitter notes, there is no 0.11.2005.* version, as our release for that month came in the early days of June instead.
    Amir Ebrahimi
    @amirebrahimi

    When I have two using blocks one after another, I notice some odd behavior w/ Reset() by looking at the output of DumpRegister(). Ex:

    using (q1 = Qubit()) {
                X(q1);
                Rz(PI() / 2.0, q1);
                DumpRegister((), [q1]);
                let m1 = M(q1);
                Reset(q1);
            }
    using (q1 = Qubit()) {
                ResetAll([q1]);
                DumpRegister((), [q1]);
                Reset(q1);
            }

    Output:

    # wave function for qubits with ids (least to most significant): 0
    โˆฃ0โญ:     0.000000 +  0.000000 i  ==                          [ 0.000000 ]
    โˆฃ1โญ:     0.707107 +  0.707107 i  ==     ********************* [ 1.000000 ]      /  [  0.78540 rad ]
    # wave function for qubits with ids (least to most significant): 0
    โˆฃ0โญ:     0.707107 +  0.707107 i  ==     ********************* [ 1.000000 ]      /  [  0.78540 rad ]
    โˆฃ1โญ:     0.000000 +  0.000000 i  ==                          [ 0.000000 ]

    It did reset back to |0>, but looks like the state isn't reflecting that correctly. Any idea why?

    Chris Granade
    @cgranade
    @amirebrahimi The state (1 / โˆš2 + ๐‘– / โˆš2) |0โŸฉ is identical to |0โŸฉ, up to a global phase, such that the state reported in the last call to DumpRegister((), _) shows that the register is in fact in the |0โŸฉ state following the call to the ResetAll operation.
    Chris Granade
    @cgranade
    @amirebrahimi Another way to see that is to write out the coefficient of each basis state in what's called phasor notation. For instance, 0 = ๐‘’^{๐‘– 0 ฯ€}, while (1 / โˆš2 + ๐‘– / โˆš2) = ๐‘’^{๐‘– ฯ€ / 4}, so that you can think of (1 / โˆš2 + ๐‘– / โˆš2) as being a 45ยฐ phase. If you use IQ# to call DumpMachine, then you can get the rich HTML output, which visualizes that coefficient as an arrow rotated by 45ยฐ.
    Sarah Kasier
    @crazy4pi314
    Also a heads up, @bettinaheim and I'll will be working on extending the Q# compiler today on stream in about 30min : twitch.tv/crazy4pi314
    Chris Granade
    @cgranade
    @crazy4pi314 ๐Ÿ’•
    Amir Ebrahimi
    @amirebrahimi
    Thanks, @cgranade. I suppose it is done this way in the simulator to simulate actual quantum hardware where a Reset() won't guarantee that all global phase will be removed?
    vashisth malik
    @VashisthMalik_twitter
    can i use dumpregister feature somewhere online ?
    Amir Ebrahimi
    @amirebrahimi

    What's the easiest way to create a phased operator (e.g. -XZ)? Ideally, I'd like to make it generic like ApplyPauli, but I haven't figured out the syntax yet. A function doesn't work because it seems I can only return one operation and can't apply many in sequence.

    For example:

    function FixedR(theta : Double, op : ((Double, Qubit) => Unit is Adj+Ctl)) : (Qubit => Unit is Adj+Ctl) {
            return op(theta, _);
    }

    allowed me to create a testing harness for A5 from the Q# challenge.

    Ideally, I'd like to not have to define it explicitly:
    operation negXZ (qubit : Qubit) : Unit is Adj+Ctl {
            body (...) {
                R(PauliI, PI(), qubit);
                X(qubit);
                Z(qubit);
         }
    }
    Amir Ebrahimi
    @amirebrahimi
    Another common thing I run into is needing to convert between an operation with one qubit to an operation that takes multiple qubits (e.g. where I'd essentially call op(qubits[0])). Any helper functions for that?
    Chris Granade
    @cgranade
    @VashisthMalik_twitter: The QDK samples, the katas, and code for the book that @crazy4pi314 and I wrote all can be used online through mybinder.org, so that you can use DumpRegister() and DumpMachine() to explore those samples and tutorials.
    @amirebrahimi The key thing is that global phases have no basis in physical reality, and are effectively an artifact of how we write down vectors (indeed, if you work with density operators instead of state vectors, global phases disappear entirely). From that standpoint, ๐‘‹๐‘ and โˆ’๐‘‹๐‘ are two different unitary matrices representing the exact same operation. On the other hand, using the Controlled functor can turn what were global phases into locally observable phases.
    @amirebrahimi For the other part of your question, some of library operations and functions like Bound can be used to return a single operation representing a sequence of operations without needing to wrap them in a new operation. For example, your negXZ could be written as let negXZ = BoundCA([R(PauliI, PI(), _), X, Z]);.
    Chris Granade
    @cgranade
    Similarly, ApplyToEach, ApplyToFirst, and so forth can be really useful operations for cases like op(qubits[0]);. If you want lambda support in Q#, @bettinaheim has been discussing that feature request at microsoft/qsharp-compiler#181.
    Amir Ebrahimi
    @amirebrahimi
    Much apreesh @cgranade
    Chris Granade
    @cgranade
    No worries, @amirebrahimi. Happy to help. Thanks to @crazy4pi314 and the rest of the qsharp.community team for creating and maintaining this space to discuss Q#!
    Mridul Sarkar
    @mridulsar
    Hey all, I was wondering if something like ApplyToEach can be used on a BE or LE. I could not find anything in the docs. I could be misguided in understanding that ApplyToEach cannot be applied to BE or LE registers.
    Also, how can I make ApplyToEach look pretty, ie @cgranade did so earlier
    i guess my larger question is, a data type of 'T[] (= or != ) LE/BE
    Chris Granade
    @cgranade
    @mridulsar: From the perspective of the Q# type system, a value of type LittleEndian is a single atomic value. If you have an array of little-endian registers (that is, LittleEndian[]), then ApplyToEach works great over that array. On the other hand, if you want to apply an operation to each qubit making up a single LittleEndian register, you can unwrap it with the unwrap operator (!) to get an array of type Qubit[].
    @crazy4pi314, do you recall the page reference in the book where we explain that? Also, @mridulsar, you may want to check out this part of the docs: https://docs.microsoft.com/en-us/quantum/user-guide/language/expressions#unwrap-expressions
    Mridul Sarkar
    @mridulsar
    Thank you Chris, I see the hole in my knowledge is understanding how LittleEndian is encoded and for what practical applications this can be used. I am understanding LE/BE encoding takes a singular integer by its binary values, the order of the values respective to the type of Endian encoding. I tried doing a google search for quantum BE papers but could not come up with anything nice to read. If you had suggestions on papers I could read to understand this topic I would greatly appreciate it.
    Chris Granade
    @cgranade
    @mridulsar No worries, happy to help.
    Mridul Sarkar
    @mridulsar
    So I am understanding that I can take a register of qubits initialized as some q=Qubit(N} under an apply{} and if I decide to apply LittleEndian(q) and then q! I end up where I started?
    Chris Granade
    @cgranade
    It comes down to that little-endian and big-endian are just different ways of mapping non-negative integers to strings of bits; as applied to quantum computing, that means different ways of mapping computational basis states of the form |๐‘›โŸฉ (that is, labeled by integers) to computational basis states of the form |๐‘โ‚€๐‘โ‚โ€ฆ๐‘โ‚–โ‚‹โ‚โŸฉ (that is, labeled by bit strings). The LittleEndian UDT marks that a register of qubits should be interpreted where ๐‘โ‚€ is the least-significant (little end) bit in the expansion of ๐‘›. From that perspective, a big-endian paper can be converted to a little-endian one by reversing the convention used to order qubits.
    Sarah Kasier
    @crazy4pi314
    Mridul Sarkar
    @mridulsar
    Ok that makes sense, thank you Chris. Sarah, that was an extremely helpful picture
    Chris Granade
    @cgranade
    I'm glad!
    Sarah Kasier
    @crazy4pi314
    ๐Ÿ’–
    Sagar Mishra
    @achieveordie

    Hi there! I've got another difficulty in understanding a part of the topic of Circuit-Centric-Classifiers

    Here's the excerpt from the paper that I am having difficulty understanding

    I don't even know where to begin reasoning the paragraph, can someone help me in justifying how this is the case?

    Chris Granade
    @cgranade
    @achieveordie Happy to try and help! The basic idea is that Hilbert space (in this context, the vector space of all quantum states) is unbelievably large, but that doesn't really reflect the reality that almost all states correspond to state preparation programs that are exponentially long to run.
    So if you look only at those states reachable by programs parameterized by a small set of angles, that's a very small subset of all possible states.
    the Roman Mercury
    @theRomanMercury

    Hello,

    I am measuring in bell basis . I apply H and CNOT gate.
    I measured several times and this outputs I got:

    Measured CNOT ยท H |00? and observed (Zero, Zero)
    Measured CNOT ยท H |00? and observed (Zero, Zero)
    Measured CNOT ยท H |00? and observed (Zero, Zero)
    Measured CNOT ยท H |00? and observed (One, One)
    Measured CNOT ยท H |00? and observed (Zero, Zero)
    Measured CNOT ยท H |00? and observed (One, One)
    Measured CNOT ยท H |00? and observed (One, One)
    Measured CNOT ยท H |00? and observed (Zero, Zero)

    I did not get (One , Zero ) output . If input (One,One), I think output should be (One,Zero) and if input ( Zero, One ) output should be ( Zero,One) .

    Why I do not get this outputs ?

    Sarah Kasier
    @crazy4pi314
    There are 4 different bell states you can prepare, some are matching parity (One, One)/(Zero, Zero) and some are opposite as you described. It just depends on which of the bell states you prepare
    the Roman Mercury
    @theRomanMercury
    Thnx, I will try it
    Sagar Mishra
    @achieveordie

    @cgranade Please correct me wherever I am wrong. 1) Can't we have those cases where we don't really need to map our data into a higher dimension, i.e. we can prepare our state in a euclidean space without needing to apply any tensor product to prepare them? (This assumes that the data is simple enough that we don't really require any further mapping)

    2) If the above statement is true, how is having our dataset in a limited space a bad thing? Why are we treating State Preparation step as if it is at this point that we are training our model? Isn't this analogous to zero initialization of weights in classical Machine Learning? We start at the same limited value (zero) and then learn the appropriate weights and biases.

    3) If I am completely off-track here, could you please tell me some resources to get started in this part of the subject? I think that this is certainly getting too much for me.