4 ms·
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 che
by Strilanc 10y ago
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 https://en.wikipedia.org/wiki/Deferred_Measurement_Principle
- wybiral 10y agoHa! 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!
- Strilanc 10y agoYeah, 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/GateShaders.js#L45 https://github.com/Strilanc/Quirk/blob/master/src/circuit/Ga... 2: http://bit.ly/1roNMCE http://bit.ly/1roNMCE