Damus
Nandan profile picture
Nandan
@nandan

Physics → software → quantum. Curious about how information becomes knowledge. Exploring where quantum computing meets machine intelligence.

Relays (13)
  • wss://brb.io – read & write
  • wss://relay.plebstr.com – read & write
  • wss://relay.damus.io – read & write
  • wss://nos.lol – read & write
  • wss://relay.snort.social – read & write
  • wss://nostr.orangepill.dev – read & write
  • wss://eden.nostr.land – read & write
  • wss://relay.current.fyi – read & write
  • wss://nostr.wine – read & write
  • wss://r.kojira.io – read & write
  • wss://nostr.land – read & write
  • wss://relay-jp.nostr.wirednet.jp – read & write
  • ws://numbrel.tail1c12b.ts.net:4848 – read & write

Recent Notes

Nandan profile picture
Here is a perfectly good q program: a counter, a loop, an accumulator, and it prints 15. It will still be correct next year, in production. That is the problem. Every reflex you bring from Python or Java has somewhere to land in q, the answers come out right, and nothing ever nudges you toward the one-word version, sum. Article 4 of my array-thinking series is about why a language that lets you stay comfortable cannot teach you a paradigm shift.

Last week's article took q's as-of join apart. This one is about a quieter gap. J does not forbid loops either. What differs is what writing one costs you: you leave J's ordinary notation for five lines of visibly foreign machinery, where the array version is two characters. That feeling of having wandered off is the whole case for a short detour through J before q.

The detour sends three habits back with you, and two of them break on the way home. One breaks loudly: a mean written J's way, with no data in it, does not parse in q at all, so it can never ship. One breaks silently: a 3-period moving average of six numbers gives four results in J, complete windows only, and six in q, which ramps up through partial windows at the start. Both are right, both are called the same thing, and reading q's first value as a full window puts you two positions early with no error.

Also in the article: whether the shift actually takes, using my earlier eval of KX's q plugin, and why J rather than APL or BQN. Written for people who have never read q or J; every snippet is copied from a lesson that runs in CI.

Article 4 of 5: https://nandan.me/writing/unlearn-the-loop/
Repo: https://github.com/nandanito/array-thinking-to-q

#kdb #programming #ArrayProgramming

Nandan profile picture
pandas, Polars, DuckDB and ClickHouse all have an as-of join, so having one isn't what makes q interesting. Article 3 of my array-thinking series is about what the join looks like when the language and its storage were built around it.

In q, aj comes apart into two primitives: group finds each symbol's rows once, for the whole quote table, and bin finds the latest quote time at or before each trade. The awkward cases (a tie, a trade before the first quote, a symbol with no quotes) are all settled by those primitives and one indexing rule, with no special-case code. The price is that bin assumes the quotes are sorted and never checks. q can stamp a column with a flag that records the grouping; nothing records the time order inside each symbol, and that is the half that decides correctness. Drop the flag and you get the same table. Drop the sort and, on the lesson's data, you get a different one, silently.

Written for people who have never read q; every snippet runs in CI. J serves as the control, and the article reports the bug a reviewer found in a lesson that was already verified green. No timings, by choice.

Article 3 of 5: https://nandan.me/writing/the-as-of-join/
Repo: https://github.com/nandanito/array-thinking-to-q

#kdb #programming #TimeSeries

Nandan profile picture
Array languages ask one thing of an experienced programmer: stop writing the loop.

I've been working through that shift and turning it into a short, fully executable curriculum: a brief laboratory in J, then q/kdb+ from KX as the destination. Every example runs under make verify, and the q suite runs nightly in CI.

The more useful finding: every serious defect so far passed a green build, because what was wrong was a claim, not code. Verification covers code; claims need their own discipline.

Article 1 of 6: https://nandan.me/writing/array-thinking-all-the-way-to-q/
Repo: https://github.com/nandanito/array-thinking-to-q

#ArrayProgramming #kdb #programming

Nandan profile picture
A screenshot of a circuit is not a circuit.

It's a claim that a circuit existed, in a state you can't check, from code you may not have.

A diagram rendered from source at a known commit is a different object. Same picture, completely different epistemic status — you can clone the source, re-render it, and get the same picture, or find out that you don't.

Most quantum papers publish the screenshot. Almost none publish the thing that would let you re-derive it.
Nandan profile picture
Quantum computing is not one field. Here are five circuits from five different corners of it — and you can read what each one does from its shape.

Algorithms — Grover's search. Two Hadamards spread amplitude over every state, an oracle marks the answer, a diffusion step turns that mark into amplitude you can actually measure.
https://qubithub.co/qubithub/grover-search?utm_source=nostr&utm_medium=social&utm_campaign=sprint23

Chemistry — VQE on H₂, the Peruzzo formulation. A tiny parameterised ansatz whose angles get tuned by a classical optimiser until the energy stops going down. Two qubits. The circuit that started variational quantum computing.
https://qubithub.co/qubithub/vqe-h2-peruzzo?utm_source=nostr&utm_medium=social&utm_campaign=sprint23

Optimization — MaxCut. Split a graph's nodes into two groups so you cut as many edges as possible. Four qubits, one per node. The same QAOA machinery that keeps showing up in logistics and portfolio problems.
https://qubithub.co/qubithub/maxcut?utm_source=nostr&utm_medium=social&utm_campaign=sprint23

Error correction — the three-qubit bit-flip code. Spread one logical qubit
across three physical ones so a single flip becomes detectable instead of fatal. The repetition in the diagram is the redundancy.
https://qubithub.co/qubithub/bit-flip-code?utm_source=nostr&utm_medium=social&utm_campaign=sprint23

Machine learning — a quantum kernel. Encode two data points, run the circuit, and the overlap you measure is a similarity score you can hand to a classical SVM.
https://qubithub.co/qubithub/quantum-kernel?utm_source=nostr&utm_medium=social&utm_campaign=sprint23

Five domains, one platform. 50+ public circuits, free to browse — no account needed. Every diagram on those pages is generated from the source, not drawn by hand.
Nandan profile picture
Every quantum tutorial draws its circuit in ASCII wires and dashes. Two qubits, a Hadamard, a controlled-NOT — it reads fine, and it's how most of us first learned to see a circuit.

q_0: ──H──■──
q_1: ─────X──

Now condition a gate on a mid-circuit measurement. Add a barrier. Add fifteen more qubits.

The classical register plumbing is what gives out first — the wires stop lining up with the thing they're describing, and you end up reading the code to understand the picture that was supposed to explain the code.

The notation we teach quantum with is the first thing that breaks when circuits get real.
Nandan profile picture
Post-quantum signatures are a structural question for Nostr specifically. Identities here are secp256k1 keypairs, and every pubkey is permanently public by design — so the security of every identity on this network rests on the discrete logarithm problem staying hard. That is precisely the assumption Shor's algorithm removes, given a large enough quantum computer. Not this year's problem. Still a real one on a long enough horizon.

SLH-DSA is one of the conservative answers. It's the hash-based signature scheme NIST standardised as FIPS 205, and its security reduces to SHA-2 and SHAKE — no lattices, no elliptic curves, no number-theoretic assumption at all. If the hash functions hold, the signatures hold.

You pay for that in size: 7,856 bytes per signature against Schnorr's 64. The public key is 32 bytes, though — the smallest of any NIST post-quantum signature standard.

I've published slh-dsa-zig v0.1.1: a pure-Zig implementation, all twelve parameter sets, validated against the NIST ACVP test vectors, constant-time verified in CI.

It is experimental and has not been audited. Passing known-answer tests proves an implementation computes what the standard says. It proves nothing about an attacker with a timer or a power probe.

Writeup: https://nandan.me/writing/the-post-quantum-gap-in-zig/
Code: https://github.com/nandanito/slh-dsa-zig
Nandan profile picture
QubitHub beta is ready for first builders. Create a quantum circuit, push it over git, fork existing ones, execute on Qiskit / Cirq / PennyLane native simulators in the browser.

qubithub.co

#QuantumComputing
Nandan profile picture
I've been learning quantum computing on the side for a few months. The thing that kept tripping me up wasn't the math — it was how often "canonical" circuits from papers and tutorials would fail quietly. Silently broken Hamiltonians. Reversed bit orders. Post-deprecation API drift. You run the code, get a plausible-looking number, and have no way to tell if it was right.

So I started building a personal library where every circuit is checked against its reference output before it's listed. That's now open to browse at https://qubithub.co?utm_source=nostr&utm_medium=social&utm_campaign=m25-library-open&utm_content=personal

No signup required — 50+ curated circuits across Qiskit, PennyLane, and Cirq.

A few things I'm happy about:

- Readable URLs — every circuit lives at qubithub.co/{owner}/{name}, no UUIDs in the shareable link
- Audited — every circuit verified against its reference output (the ones I had to fix are a separate post)
- Multi-framework — the same algorithm can show up in Qiskit, PennyLane, and Cirq side by side, so you can compare implementations in one place

Sign-up's open today — you get star and save. Creating your own circuit is still invite-only while I stabilize the builder flow; drop me a line after you sign up and I'll flip the switch as slots free up. In-browser execution is the next thing I'm finishing — separate post when it's live.

Six months in, this is the thing I wish had existed when I started. Reply with what you'd want to see next.

#quantumcomputing #qiskit #pennylane #learninginpublic #quantumcircuits
👍1
Nandan profile picture
The circuit that broke my intuition and then rebuilt it.

Quantum teleportation. The name sounds like science fiction, but the protocol is real and surprisingly simple: 3 qubits, a handful of gates (H, CX, X, Z), 2 classical bits. That's it.

Here's what happens: Alice has a qubit in some unknown state |ψ⟩ she wants to send to Bob. They share a Bell pair — the same entangled state (Bell State) I wrote about recently. Alice entangles her message qubit with her half of the pair, measures both, and gets two classical bits. She sends those to Bob. Bob applies one or two simple corrections (an X gate, a Z gate, or both) based on Alice's bits. His qubit is now in state |ψ⟩.

The part that tripped me up: nothing quantum travels between Alice and Bob. The entanglement is a shared resource that gets consumed. The classical bits travel at normal speed. There's no faster-than-light anything. And the original state is destroyed in the process — the no-cloning theorem is satisfied.

What I love about this circuit: it connects three deep ideas in one protocol. Entanglement (the Bell pair), measurement (Alice's Bell measurement collapses the state), and classical communication (Bob can't decode without Alice's bits). Remove any one of those and the protocol fails.

I rebuilt this in my side-project hours using Qiskit's if_test for the classically conditioned corrections — that's the part most tutorials skip or fake with barriers. The real circuit has Bob's X and Z gates fire only when Alice's measurement results say so.

Explore it on QubitHub:
→ qubithub.co/circuits/e99b8b75-b2fd-47b7-a7d1-ad786ae177c5

Bennett et al. published this in 1993 — over three decades ago. You can now explore it in a browser. The gap between "theoretically possible" and "see the circuit laid out gate by gate" is what I keep trying to close.

What's a quantum protocol that seemed impossible until you built it yourself? Reply and let me know.

#quantumcomputing #physics #learninginpublic #quantumcircuits
Nandan profile picture
If you're learning quantum computing, two algorithms keep coming up: VQE and QAOA. I finally understand why.

They're both variational — a parameterized quantum circuit paired with a classical optimizer. The quantum part explores a solution space that's exponentially large. The classical part steers the search. They meet in the middle.

VQE (Variational Quantum Eigensolver) finds molecular ground-state energies. I implemented it for H₂ in my nights-and-weekends notebook — the simplest molecule. Two qubits, four rotation parameters, a COBYLA optimizer. Under 100 iterations it gets near -1.137 Hartree — close to the exact FCI/STO-3G result. The Hamiltonian only has 5 terms, so you need just 2 measurement bases. Elegant.

The part that surprised me: the ansatz (circuit structure) matters more than the optimizer. A bad ansatz can't find the ground state no matter how clever the optimizer is. A good one converges in under 100 iterations.

QAOA (Quantum Approximate Optimization Algorithm) solves combinatorial optimization — MaxCut, routing, scheduling. Same variational structure, different objective. Instead of minimizing energy, you maximize cut edges in a graph.

The 2014 Farhi et al. result still amazes me: even at depth p=1 (just 2 parameters), QAOA has a proven worst-case guarantee around 0.692 for 3-regular MaxCut. Add layers, get closer to optimal. It's not a heuristic hoping for the best — there's a provable floor.

Both circuits are on QubitHub:
VQE → qubithub.co/circuits/2e744d85-c706-4926-98a5-05877f318eb4
QAOA → qubithub.co/circuits/6915d62d-a518-42f9-89f6-482a1283818b

If you've implemented either of these, what ansatz worked best for you? The hardware-efficient one is convenient but I've read it can have barren plateaus at scale. Reply — I'd love to hear what worked.

#quantumcomputing #physics #learninginpublic #quantumalgorithms