Build your first quantum circuit with Q’s simple drag-and-drop interface, write your circuit as a text diagram, or code it directly using Q’s flexible API. For advanced users, drop Q into your Jupyter Notebook and use it to drive real quantum hardware.
For the love of learning
From the beginning, Q has been my personal passion project; a means of teaching myself what quantum computing is and how it works. That I taught myself some basics of quantum computing isn’t entirely notable—college students a fraction of my age can do that in a single semester. But I do take pride in having achieved a feat of strength; having laid each brick of Q on nights and weekends while working a day job and also being a parent. Not only did I learn the math, I coded the library and website, designed the interfaces, crafted the concept primers, documented the API, and so on. Q is a testament to how much I enjoy learning, creating, and sharing with others.
Sharing that desire to learn with the world has lead me to new friends and exciting collaborations. The Amazon Braket team granted me early access to an alpha version of their API. With that API in hand, I was able to add new features for injecting Q’s drag-and-drop interface into an Amazon Braket Jupyter Notebook, have Q’s interface output Braket commands in Python on the fly, and ultimately drive real quantum hardware through Amazon’s Cloud. I’ve also been fortunate to meet folks from Strangeworks, the Unitary Fund, and, of course, IBM—who recently partnered with Parsons School of Design on a quantum-inspired art exhibition in New York.
Yale quantum artwork
The most exciting collaboration to emerge from my interest in quantum computing has been my one-year artist residency at Yale University’s Quantum Institute (YQI). I still cannot fully comprehend how I was allowed into the building; able to ask naive questions of the world-renowned faculty, students, and researchers who would without fail, patiently attempt to translate their answers into concepts I could digest. Over the course of the 2022–2023 academic year, I would travel from New York to New Haven, meet with YQI folks, tour their labs, and use our conversations as inspiration for visual interventions—such as a cover for the latest YQI annual report, or a typeface inspired by the planning sessions for our outdoor exhibition with the International Festival of Arts & Ideas.
Our grand finale took the form of an outdoor installation on the New Haven Green in June of 2023, titled “Beneath the Green, the Quantum.” Our small forest of light beacons reacted to the movement of Green visitors traversing the space and utilized Yale’s latest research in quantum error correction (QEC)—a technology that is imperative in this current era of “noisy”, error-prone quantum computers. (Visit the “Beneath the Green” project entry here to learn more and to find a list of collaborators for this piece.)
Get started with Q.js
Whether you’re new to quantum computing, or an expert looking to kick the tires on a mobile-friendly drag-and-drop interface, it’s easy to dive into Q.
Learn as you go
Perhaps you’ve heard the term “quantum bit”—or “qubit” for short. But what is a qubit? Q’s website bakes basic concept primers right into the API documentation. For example, see the Qubit documentation page to learn how qubits are really just a pair of numbers that have a special relationship to each other. You don’t need a PhD degree to start having fun with quantum circuits.
What does composing a quantum circuit look like? This screen capture demonstrates the creation of a Bell state using Q’s drag-and-drop interface. First we drop a Hadamard gate onto our circuit composer. (Its exact location doesn’t really matter as it’s trivial to subsequently drag it elsewhere.) In this recording I happened to drop our “H” tile onto Moment 3, Register 2 of our circuit.
Next we’re going to construct a “controlled gate”—a quantum logic gate that spans multiple registers (and thus requires multiple tiles). Specifically, we’re creating a “Controlled Not” gate by combining an “Identity cursor” (an abstraction invented specifically for the Q editor) with a Pauli X gate. We drag an Identity cursor (the blank dot) onto our circuit and place it on the same register as our Hadamard gate, but one moment further into the future (ie. one cell to the right of it). We then drag a Pauli X gate (the “X” tile) onto our board and place it on the same moment as our Identity cursor, but one register below. Now we select both the Identity cursor and Pauli X gates (you can do this by tapping on each on individually, or by tapping on the label for the Moment that contains both of them), then tap the “C” button to create the controlled gate. You’ll see that the Identity cursor and Pauli X gate are now connected together.
Finally, we select the entire circuit content and drag it to Moment 1, Register 1. (If so inclined, we could then trim the circuit board for tidiness such that it only spans 2 moments and 2 registers.) We now have our complete Bell State right at the starting corner of our board. Starting over is easy enough: Select the entire circuit content again and simply drag it off the board to remove it.
Code as you like
Now we can construct the same circuit as above using three separate circuit authoring styles to demonstrate Q’s flexibility. For each of the three examples we’ll create a circuit that uses 2 qubit registers for 2 moments of time. We’ll place a Hadamard gate at moment 1 on register 1. Then we’ll place a Controlled-Not gate at moment 2, with its control component on register 1 and its target component on register 2. This will mirror the final state of our drag-and-drop circuit above.
1. Text as input
Q’s text-as-input feature directly converts your text into a functioning quantum circuit. Just type your operations out as if creating a text-only circuit diagram (using “I” for identity gates in the spots where no operations occur) and enclose your text block in backticks (instead of quotation marks). Note that parentheses are not required to invoke the function call when using backticks.
Folks coming to Q from Python-based quantum suites may find this syntax more familiar. Here the Q function expects the number of qubit registers to use, followed by the number of moments to use. Afterward, each single-letter quantum gate label is also a function name. For these functions the first argument is a moment index and the second is a qubit register index or array of qubit register indices.
Q( 2, 2 )
.h( 1, 1 )
.x( 2, [ 1, 2 ])
3. Verbose for clarity
Under the hood, Q is making more verbose declarations. You can also make direct declarations like so. (And what are those dollar signs about?)
new Q.Circuit( 2, 2 )
.set$( Q.Gate.HADAMARD, 1, 1 )
.set$( Q.Gate.PAULI_X, 2, [ 1, 2 ])
Mix code with clicks
A good graphic user interface is never about “dumbing something down.” It’s about making tasks easier and more efficient for us and our strange primate mammal brains that have evolved with spacial awareness and sensitivity to visual patterns. See the section in the above video that begins at 4:02 and ends at 6:12 for a demonstration of Q’s interface fluidity between circuit composer, console, and back again.
Clear, legible output
Whether you use Q’s drag-and-drop circuit editor interface, text syntax, Python-inspired syntax, or prefer to type out every set$ command yourself, Q makes inspecting and evaluating your circuits easy. Let’s add two commands which could directly follow any of the three examples above. Hey—deciding what to name a circuit can sometimes be difficult, so we’ll let Q choose a random name for us. Then we’ll generate an outcome probabilities report. Just add the following two lines to any of the above examples:
.setName$( Q.getRandomName$ )
And that combination will yield something like the following:
Beginning evaluation for “Red Albatross”
r1 |0⟩─┤ H ├┤ X#0 │
r2 |0⟩───○──┤ X#1 │
██████████░░░░░░░░░░ 50% Eval step 1 of 2
████████████████████ 100% Eval step 2 of 2
Evaluation completed for “Red Albatross”
with these results:
1 |00⟩ ██████████░░░░░░░░░░ 50% chance
2 |01⟩ ░░░░░░░░░░░░░░░░░░░░ 0% chance
3 |10⟩ ░░░░░░░░░░░░░░░░░░░░ 0% chance
4 |11⟩ ██████████░░░░░░░░░░ 50% chance
Free and open-source
It’s been four years and counting since Q’s first public code commit. When the pandemic hit, there was a lot of talk about healthy quarantiners now having time to pursue their passion projects; something about Newton upending physics—or at least people making sourdough starters. But if you had already been a remote worker like myself, and had children that were suddenly schooling from home during those work hours… Day life became dodging meetings to cook kid lunches and later manufacture some kind of school recess in our tiny strip of Brooklyn side yard. Night life became making up for what productivity had been lost during the day. Passion projects? Q hit a pandemic-sized brick wall right around its first birthday.
In these situations the best solution is to turn your hobby into your day job. (Funding!) I certainly got close. As an AWS employee my proximity to the Amazon Braket team enabled me to be in direct contact with various product leaders as well as Amazon’s Director of Quantum Technologies—who was very enthusiastic about (and repeatedly insisted on) integrating Q’s interface into Braket. And yet AWS can’t help but get in its own way; some internal rules against “certain teams providing labor for other teams” prevented me from officially working with Braket. I’d have to actually join the Braket team. (Which sounded just fine to me.)
My second quantum brick wall was constructed from Amazon’s absolute inability to think creatively or laterally. I advocated for myself as a potential Chief Experience Officer for Braket, but the very idea of such a role was incomputable to the business and engineering folks who didn’t understand why headcount that could be used for another physicist, engineer, or sales person would ever be allocated to someone concerned with … “experience.” In the next life, perhaps.
Who knows what the future holds. But to me, it looks like the end of the road for Q.