Skip to content

Preserve optimizer solutions and report the original constraint cost - #93

Open
davrens101 wants to merge 1 commit into
sqdlab:mainfrom
davrens101:fix/qubit-optimizer-results
Open

davrens101 wants to merge 1 commit into
sqdlab:mainfrom
davrens101:fix/qubit-optimizer-results

Conversation

@davrens101

Copy link
Copy Markdown
Contributor

Problem

Qubit design reporting aliases the SciPy solution vector and replaces optimization targets with derived physical quantities. All-fixed Xmon optimization can return a read-only vector and crash during this reporting step. Floating-transmon reporting mutates the vector before recomputing its objective, understating the residual against the original constraints; its returned cost is also a one-element set rather than a number.

Change

  • Copy the solution before substituting report values in both designers.
  • Use the optimizer's saved objective (sol.fun) for reporting, without evaluating an altered vector.
  • Return a numeric cost_error_% from floating-transmon optimization.
  • Document the cost semantics and add real-SciPy, fixed-constraint regressions.

No optimizer algorithm, objective, physical formula, public signature or Xmon return convention changes.

Verification

  • Before: all-fixed Xmon raises ValueError: assignment destination is read-only; floating-transmon reporting gives 48.73865330737892 instead of the independently calculated 140.26009493027976 percent, and returns a set.
  • After: actual Xmon optimization completes with cost 80.76048600418196 percent; floating-transmon cost equals 140.26009493027976 and its result serializes to JSON.
  • python -m pytest -q UnitTests/test_qubit_optimisation.py UnitTests/testBasicQiskitMetal.py: 4 passed. Existing initial-guess-outside-bounds SciPy warning and two dependency deprecation warnings remain; they are not suppressed.
  • New-test Ruff check/format and changed Python compile checks pass. Independent read-only AI review found no blocker.
  • Windows/Python 3.11, CPU only. No full-suite or external EM-solver validation claimed.

Review and assistance

Human review: davrens101 confirmed reviewing the work live before submission. AI assistance was used for investigation, implementation and verification. No maintainer review or approval is claimed. Verification was CPU-only; no GPU validation is claimed.

@davrens101

davrens101 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

I cherry-picked the four independent SQDMetal fixes (#91-94) onto their shared upstream base and they apply cleanly together. Parser, LC, optimizer, transmon and the existing component geometry tests: 14 passed, 21 subtests passed. The optimizer/JSON run and a 61-state charge-basis Hamiltonian check also pass. With #94's corrected energy physics the floating original-target cost becomes 131.30895980700444 and still matches the independently calculated residual. CPU only, existing warnings not suppressed, no full suite or external EM solver.

This branch has not been deployed

No deployments
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.

1 participant