Uh oh!
There was an error while loading. Please reload this page.
feat(extension): record the Hamiltonian on the System entity; stop fabricating roles - #220
Merged
Merged
Conversation
…bricating roles The System card re-derives the Hamiltonian in the renderer from (role, levels, platform) with hardcoded tables, so it is only ever right for platforms someone hardcoded — and silently wrong for the rest. It showed the transmon ladder, and asked for an anharmonicity, on an exchange-only spin qubit. Two changes here; the renderer half is harmoniqs/opencode#93. 1. `amicode_set_model` gains `hamiltonian` — the model term by term ({kind: drift|coupling|drive, latex, acts_on?, label?}) plus `hamiltonian_notes` for frame/unit/basis conventions. The agent already understands the model well enough to author the Julia solve; this is where that understanding gets written down instead of evaporating into the script. It knows what an exchange-only spin qubit is — the renderer's table never will. Full path: validation (closed kind set, non-empty latex, acts_on ids must exist, brace balance since the plugin can't parse LaTeX but the card renders it straight into KaTeX), TOML round-trip, wholesale patch-replace, hashing, normalizeSystem read-through. 2. `role` gains `other`, and `platformDefaultRole` stops inventing one. Only platforms we model get a role from the string (rydberg→atom, transmon→qubit, bosonic→mode); everything else is `other` until MODEL asks. The old blanket "unknown → qubit" was also wrong for photonic and bosonic, which are modes. AGENTS.md tells the interview to record the Hamiltonian — mandatory off-template, worth confirming even on template — and to use `other` over a near-miss. Note for the reviewer: this lands the recording side. The card only renders it once the fork release carrying #93 is pinned via `pnpm opencode:pin`, so there is no lock bump here. Verified: 782 tests pass (78 files), tsc clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
aarontrowbridge added a commit
to harmoniqs/opencode
that referenced
this pull request
Jul 28, 2026
…f-template
The card re-derived the Hamiltonian in the renderer from (role, levels, platform)
using hardcoded tables, so it could only ever be right for platforms someone had
hardcoded. Two separate leaks put the transmon model on a spin qubit:
- `platformDefaultRole` maps every unfamiliar platform to "qubit", so an
exchange-only HRL spin qubit arrived indistinguishable from a transmon.
- levels >= 3 was read as "anharmonic ladder". It is not. Three levels is a
Hilbert-space DIMENSION: an exchange-only qubit at levels=3 is three dots, a
spin-1 defect is three Zeeman sublevels. Neither is an oscillator.
So the platform is now the only thing that licenses a ladder for a `qubit` role
(transmon, bosonic). levels=2 still earns the generic two-level model, which is
safe on any platform — every two-level system has an ω σ_z/2 splitting and σx/σy
control. Everything else is opaque.
Recorded beats inferred. `systemHamiltonian()` returns {latex, source}: a model
recorded on the entity (amicode_set_model's `hamiltonian`, see harmoniqs/amicode#220) renders
verbatim; otherwise the canonical form for the platform renders under an
"inferred · confirm or correct" label. When nothing is recorded AND nothing is
modelled the card says "not recorded" rather than showing `Ĥ_drift + Ĥ_c(t)`, which
is true of every control problem ever posed and would occupy the slot the real model
belongs in. Mixed systems still get a named placeholder per unmodelled component.
One `classify()` now drives both the equation and the physics rows, so the two
halves of the card cannot describe different physics again.
Also fixes a three-way drift found while doing this: the ladder drive was a single
`ε(t)(â+â†)` while the plugin's TRANSMON_LATEX (shown in chat) and Piccolo's
n_drives = 2 both say two quadratures. Two is correct; the card now matches.
Verified: 399 pass across 30 files, tsgo clean. The KaTeX sweep now crosses the
platform axis too (8k systems) and asserts BOTH directions: no output when nothing
is modelled, and never a model invented for an all-unmodelled system.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>aarontrowbridgeforce-pushed
the
feat/system-recorded-hamiltonian
branch
from
July 28, 2026 21:53
3b45aaf to
8dda178Comparejack-champagne pushed a commit
to harmoniqs/opencode
that referenced
this pull request
Jul 28, 2026
…f-template
The card re-derived the Hamiltonian in the renderer from (role, levels, platform)
using hardcoded tables, so it could only ever be right for platforms someone had
hardcoded. Two separate leaks put the transmon model on a spin qubit:
- `platformDefaultRole` maps every unfamiliar platform to "qubit", so an
exchange-only HRL spin qubit arrived indistinguishable from a transmon.
- levels >= 3 was read as "anharmonic ladder". It is not. Three levels is a
Hilbert-space DIMENSION: an exchange-only qubit at levels=3 is three dots, a
spin-1 defect is three Zeeman sublevels. Neither is an oscillator.
So the platform is now the only thing that licenses a ladder for a `qubit` role
(transmon, bosonic). levels=2 still earns the generic two-level model, which is
safe on any platform — every two-level system has an ω σ_z/2 splitting and σx/σy
control. Everything else is opaque.
Recorded beats inferred. `systemHamiltonian()` returns {latex, source}: a model
recorded on the entity (amicode_set_model's `hamiltonian`, see harmoniqs/amicode#220) renders
verbatim; otherwise the canonical form for the platform renders under an
"inferred · confirm or correct" label. When nothing is recorded AND nothing is
modelled the card says "not recorded" rather than showing `Ĥ_drift + Ĥ_c(t)`, which
is true of every control problem ever posed and would occupy the slot the real model
belongs in. Mixed systems still get a named placeholder per unmodelled component.
One `classify()` now drives both the equation and the physics rows, so the two
halves of the card cannot describe different physics again.
Also fixes a three-way drift found while doing this: the ladder drive was a single
`ε(t)(â+â†)` while the plugin's TRANSMON_LATEX (shown in chat) and Piccolo's
n_drives = 2 both say two quadratures. Two is correct; the card now matches.
Verified: 399 pass across 30 files, tsgo clean. The KaTeX sweep now crosses the
platform axis too (8k systems) and asserts BOTH directions: no output when nothing
is modelled, and never a model invented for an all-unmodelled system.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>jack-champagne pushed a commit
to harmoniqs/opencode
that referenced
this pull request
Jul 29, 2026
…s inventing one (#93) * feat(amicode): per-component physics rows on the system card The card made its component-count claim implicitly, so an unanswered 'how many atoms?' read as 'one'. systemCountLabel now states it as its own badge ('2 atoms x 3 levels') that a researcher can read and correct. componentPhysicsRows renders what each role actually has, in card order: - unanswered params read 'not set', so the list doubles as the interview's to-do - anything else on file is still shown, so nothing recorded is dropped - an unrecognized role expects NOTHING -- the honest floor for a platform we have no model for - units are never assumed (transmon params are GHz, the Rydberg templates work in rad/us, a bare omega says which only by convention), so a unit appears only when the recorded key spells it out - a zero keeps the '0 means unset' reading, so an all-zeros seed does not look like a specified device driftTerm now keys the qubit ladder off LEVELS rather than off whether delta happens to be filled in: a 3-level transmon with empty params is still an anharmonic ladder, and rendering it as a bare spin misstates the model the solve will use. A mode's Kerr stays params-driven, since a linear cavity genuinely has none. * feat(amicode): extend the system card's physics rows Continues 0793fd6. Committed on the author's behalf as part of folding the worktree's in-progress work onto the branch; the content is theirs. +169 lines of tests alongside +278 of implementation; ui suite 442 -> 448 pass. * feat(amicode): render the recorded Hamiltonian; stop inferring one off-template The card re-derived the Hamiltonian in the renderer from (role, levels, platform) using hardcoded tables, so it could only ever be right for platforms someone had hardcoded. Two separate leaks put the transmon model on a spin qubit: - `platformDefaultRole` maps every unfamiliar platform to "qubit", so an exchange-only HRL spin qubit arrived indistinguishable from a transmon. - levels >= 3 was read as "anharmonic ladder". It is not. Three levels is a Hilbert-space DIMENSION: an exchange-only qubit at levels=3 is three dots, a spin-1 defect is three Zeeman sublevels. Neither is an oscillator. So the platform is now the only thing that licenses a ladder for a `qubit` role (transmon, bosonic). levels=2 still earns the generic two-level model, which is safe on any platform — every two-level system has an ω σ_z/2 splitting and σx/σy control. Everything else is opaque. Recorded beats inferred. `systemHamiltonian()` returns {latex, source}: a model recorded on the entity (amicode_set_model's `hamiltonian`, see harmoniqs/amicode#220) renders verbatim; otherwise the canonical form for the platform renders under an "inferred · confirm or correct" label. When nothing is recorded AND nothing is modelled the card says "not recorded" rather than showing `Ĥ_drift + Ĥ_c(t)`, which is true of every control problem ever posed and would occupy the slot the real model belongs in. Mixed systems still get a named placeholder per unmodelled component. One `classify()` now drives both the equation and the physics rows, so the two halves of the card cannot describe different physics again. Also fixes a three-way drift found while doing this: the ladder drive was a single `ε(t)(â+â†)` while the plugin's TRANSMON_LATEX (shown in chat) and Piccolo's n_drives = 2 both say two quadratures. Two is correct; the card now matches. Verified: 399 pass across 30 files, tsgo clean. The KaTeX sweep now crosses the platform axis too (8k systems) and asserts BOTH directions: no output when nothing is modelled, and never a model invented for an all-unmodelled system. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(amicode): dedupe the KaTeX sweep — render each distinct equation once The sweep enumerates ~8k systems, but they collapse onto a few hundred distinct equations, and KaTeX is the expensive part. Rendering the same string 200 times proves nothing and took 22s on CI against a 5s default timeout (it passed locally on a fast machine, and I had only been running src/amicode — CI runs all of src). Coverage is unchanged: every distinct output is still parsed, and the mapping back to a producing system is kept for the failure message. Adds an assertion that the sweep really does vary its output, so a future change that collapses everything to one equation can't quietly pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The System card re-derives the Hamiltonian in the renderer from
(role, levels, platform)with hardcoded tables, so it is only ever right for platforms someone hardcoded — and silently wrong for the rest. It showed the transmon ladder, and asked for an anharmonicity, on an exchange-only spin qubit.This is the recording half. The renderer half is harmoniqs/opencode#93.
1 ·
amicode_set_modelgainshamiltonianThe model term by term —
{kind: drift|coupling|drive, latex, acts_on?, label?}— plushamiltonian_notesfor frame / unit / basis conventions.The argument for putting it here: the agent already understands the model well enough to author the Julia solve. That understanding currently evaporates into a
.jlfile and never reaches the entity, so the UI re-derives it badly. Amico knows what an exchange-only spin qubit is; the renderer's lookup table never will.Full path implemented: validation (closed
kindset, non-emptylatex,acts_onids must exist, and a brace-balance check — the plugin stays dependency-free so it can't parse LaTeX, but the card renders it straight into KaTeX), TOML round-trip, wholesale patch-replace, hashing,normalizeSystemread-through.Precedence in the card: recorded renders verbatim; otherwise the canonical form for the platform renders under an
inferred · confirm or correctlabel; off-template it shows no Hamiltonian at all.2 ·
rolegainsother, andplatformDefaultRolestops inventing oneOnly platforms we model get a role from the string (rydberg→atom, transmon→qubit, bosonic→mode). Everything else is
otheruntil the MODEL stage asks. The old blanket "unknown → qubit" was a fabrication that every downstream consumer then read as a statement — and it was also wrong for photonic and bosonic, which are modes.3 · AGENTS.md
Tells the interview to record the Hamiltonian — mandatory off-template, worth confirming even on template — and to prefer
otherover a near-miss role.Also leaves a
THIRD COPY WARNINGatTRANSMON_LATEX: the same physics is written down in the plugin, the card's fallback tables, and the Julia templates, and they had drifted (the card said one drive quadrature; this constant and Piccolo'sn_drives = 2say two). Fixed in #93. Recording the model is what makes the constants a pre-MODEL fallback rather than a third source of truth.Reviewer note
This lands recording only. The card renders it once a fork release carrying harmoniqs/opencode#93 is pinned via
pnpm --filter amicode opencode:pin <tag>— so no lock bump here, and the two can merge independently.Verification
782 tests pass (78 files),
tsc --noEmitclean.🤖 Generated with Claude Code