News for hackers. Stuff that matters.
Re:IBM Wants Everyone to Try a Quantum Computer by Strilanc on Wednesday May 04, 2016 @11:44AM (#11629131)
I have my own shameless plug to add.

Another drag-and-drop quantum circuit simulator that runs in your browser is "Quirk" [0].

Quirk is faster than Davy's simulator thanks to webgl. It calculates varying operations on up to 16 qubits in real time as you drag gates around. It also lets you drop inline state displays into the circuit. Plus you can link to circuits, though the links can be a bit long so you may want to do so indirectly [1].

That being said, Quirk lacks the ability to compile circuits into a gate. Also it doesn't have a QFT gate (yet). I'm working on it. [2].

0: http://algorithmicassertions.com/quirk

1: https://t.co/qi12H3aVU1 (6-qubit grover circuit with displays, near the getting-laggy limit in terms of op-count)

2: https://github.com/Strilanc/Quirk

Re:IBM Wants Everyone to Try a Quantum Computer by wybiral on Wednesday May 04, 2016 @11:52AM (#11629195)
That looks good. Yeah, mine wasn't really focused on performance so much as ease of use (being able to compile and reuse circuits).

One thing I never got around to that IBM did was measurement operators. They break my simple compilation strategy but would definitely make it more useful.

Re:IBM Wants Everyone to Try a Quantum Computer by Strilanc on Wednesday May 04, 2016 @11:57AM (#11629233)
Oh! Didn't realize you would see this. Gives me the opportunity to say thanks for the simulator. I found it really useful for learning. So useful for sanity checks.

(Speaking of measurement. Quirk allows measurement... but it cheats. It refuses to let you hit measured qubits with operations that would superpose them again w.r.t. the computational basis. So the deferred measurement principle [1] applies, and there's no need to use density matrices and square the simulation cost.)

1: https://en.wikipedia.org/wiki/Deferred_Measurement_Principle

Re:IBM Wants Everyone to Try a Quantum Computer by wybiral on Wednesday May 04, 2016 @12:56PM (#11629680)
Ha! I feel obligated to click when I see "Try a Quantum Computer" in a title.

That's an interesting strategy. I'm going to have to dig deeper when I get a chance. You said you're also using WebGL for a performance?

PS: Those continuous gates are especially cool!

Re:IBM Wants Everyone to Try a Quantum Computer by Strilanc on Wednesday May 04, 2016 @01:37PM (#11630046)
Yeah, using the GPU makes a huge difference. It's also incredibly finicky because the hardware and browser support varies so much.

Basically I represent an n-qubit superposition as a 2^(n/2) x 2^(n/2) texture with each pixel being an amplitude (with red=real, blue=imaginary components). Then I use fragment shaders to operate on all the pixels in parallel when applying a gate.

For example, here's the GLSL in the main method of the "UniversalNot" gate's shader [1]:

    vec2 xy = gl_FragCoord.xy - vec2(0.5, 0.5);
    float state = xy.y * outputWidth + xy.x;
    float hasBit = mod(floor(state / bit), 2.0);
    float partnerState = state + bit * (1.0 - 2.0 * hasBit);
    vec2 uv = uvFor(state);
    vec2 partnerUv = uvFor(partnerState);
    float control = texture2D(controlTexture, uv).x;
    vec2 val = vec4(texture2D(inputTexture, uv)).xy;
    vec2 partnerVal = vec4(texture2D(inputTexture, partnerUv)).xy;
    vec2 outUncontrolled = vec2(partnerVal.x, -partnerVal.y) * (1.0 - 2.0*hasBit);
    vec2 outVal = (1.0 - control) * val + control * outUncontrolled;
    gl_FragColor = vec4(outVal.x, outVal.y, 0.0, 0.0);
(The UniversalNot gate isn't possible in reality, but it's easy to implement in the simulator. So I have it implemented, but hidden away. You have to manually tweak the URL to contain a "__unstable__UniversalNot" gate to use it. But then you can use it for FTL communication shenanigans. [2])

1: https://github.com/Strilanc/Quirk/blob/master/src/circuit/Ga...

2: http://bit.ly/1roNMCE

Re:IBM Wants Everyone to Try a Quantum Computer by ivan_ah on Wednesday May 04, 2016 @12:03PM (#11629280)
Wow, this is awesome! The Block-sphere "spy probe" is an amazing way to show what's going on with each qubit[1]. I wish I had this when I was teaching the intro to QM course!

Suggestion: add some sort of menu for import/export and links to examples. I thought there was a limit to how long a URL hash can be, but it seems even very long ones will work.

[1] Of course, the local description doesn't really work for the Bell state (|00>+|11>): http://bit.ly/1rUFaos but still cool...

Re:IBM Wants Everyone to Try a Quantum Computer by Strilanc on Wednesday May 04, 2016 @12:11PM (#11629356)
Thanks.

The other issue with the links is that the braces keep getting cut off by sites (as happened for your link, need to include that last } for it to work). But having the URL be the save mechanism is just so darn appealing to me.

I generally work around each qubit in an EPR pair appearing to be maximally mixed by conditioning the displays. Add a control to the other wire in the same column as the display, and you'll see the conditional state. Also there's the 2-qubit density matrix display.