Skip to content

Return QuTiP backend results as OQD datastores#47

Open
glasses666 wants to merge 1 commit into
OpenQuantumDesign:masterfrom
glasses666:codex/unitaryhack-44-trical-datastore
Open

Return QuTiP backend results as OQD datastores#47
glasses666 wants to merge 1 commit into
OpenQuantumDesign:masterfrom
glasses666:codex/unitaryhack-44-trical-datastore

Conversation

@glasses666

@glasses666 glasses666 commented Jun 3, 2026

Copy link
Copy Markdown
  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Closes #44.

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Feature: updates the QuTiP backend result API to return an oqd_dataschema.Datastore.

  • What is the current behavior? (You can also link to an open issue here)

QutipBackend.run(...) currently returns an ad hoc dict containing QuTiP runtime objects (final_state, states, tspan, frame, hilbert_space), which cannot be saved through the shared OQD dataschema HDF5 path.

  • What is the new behavior (if this is a feature change)?

QutipBackend.run(...) now returns a Datastore with one "emulation" group containing:

  • tspan: float timeline dataset
  • states: complex ket or density-matrix trajectory dataset
  • final_state: complex final ket or density matrix dataset
  • scalar attrs for backend, solver, timestep, Hilbert-space sizes, fock cutoff, and frame presence/type

The QuTiP VM execution path is unchanged; the old VM result is wrapped after execution. The QuTiP reference docs now show the new Datastore usage and HDF5 dump path.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Yes. Code using result["tspan"] / result["states"] now needs to access the datastore group, for example result["emulation"].tspan.data and result["emulation"].states.data. This matches the requested issue behavior.

  • Other information:

Depends on OpenQuantumDesign/oqd-dataschema#12, which adds TrICalEmulatorDataGroup. To keep this PR testable before that schema PR lands, the temporary uv source points at glasses666/oqd-dataschema:codex/unitaryhack-44-trical-group. After #12 is merged, I can update this PR to point back at OpenQuantumDesign/oqd-dataschema and relock.

AI-assisted with OpenAI Codex; the diff was reviewed and locally verified before submission.

Validation run locally:

uv run --with-editable ../oqd-dataschema --extra tests pytest tests/ -q
3 passed, 2 xfailed

uv run --with-editable ../oqd-dataschema ruff check src tests
All checks passed!

git diff --check
passed

The QuTiP backend previously surfaced an ad hoc dictionary containing Qobj instances, which could not be saved through the shared OQD dataschema path. This wraps the existing VM result in a Datastore with numeric tspan, state trajectory, final state datasets, and scalar run metadata.

Constraint: Depends on oqd-dataschema exposing TrICalEmulatorDataGroup for the shared schema
Rejected: Keep returning the legacy dict alongside Datastore | issue OpenQuantumDesign#44 asks for backend.run to return dataschema output directly
Confidence: medium
Scope-risk: moderate
Directive: Do not serialize QuTiP runtime objects into attrs; keep HDF5 payload numeric and scalar metadata only
Tested: uv run --with-editable ../oqd-dataschema --extra tests pytest tests/ -q
Tested: uv run --with-editable ../oqd-dataschema ruff check src tests
Tested: git diff --check
@benjimaclellan

Copy link
Copy Markdown
Member

@glasses666 Thanks for the PR, this looks good and meets all the requirements for #44. The branch for the oqd-dataschema in pyproject.toml will need to change once everything has been merged, but that is an easy tweak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unitaryHACK 2026: Update oqd-trical Qutip backend to return a datastore

2 participants