Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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!



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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: