Skip to content

Solve single-variable QUBO inputs exactly instead of crashing#50

Merged
iagoleal merged 1 commit into
mainfrom
fix/issue-49-single-variable-solve
Jun 11, 2026
Merged

Solve single-variable QUBO inputs exactly instead of crashing#50
iagoleal merged 1 commit into
mainfrom
fix/issue-49-single-variable-solve

Conversation

@bernalde

@bernalde bernalde commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

minimize/maximize crashed on single-variable (1x1) QUBO inputs because the underlying ITensor DMRG solver does not support system sizes of 1:

ERROR: `dmrg` currently does not support system sizes of 1.

This adds an exact single-variable path in _minimize: when the tensorized Hamiltonian has one site, it evaluates the objective at x = 0 and x = 1, returns the minimizer's energy (or reports degeneracy as a uniform superposition when the two are equal), and constructs a Solution consistent with the multi-variable path (energies/bond_dims/elapsed_times populated, iteration log and on_iteration callback honored). No public API or default behavior changes for multi-variable inputs.

This edge case currently has slightly divergent ad hoc fixes duplicated across open PRs #32, #33, #34, and #41. Landing it once here lets those PRs drop their copies and avoids merge conflicts.

Tests

Added four testsets to test/qubo.jl under "QUBO Correctness": single variable, single variable with linear and constant terms, single-variable degeneracy, and single-variable maximize. On unmodified main the first of these throws (dmrg ... system sizes of 1); with this change they pass.

Commands and results (Julia 1.10.11):

  • Reproduction on main (clean re-resolved env): minimize(reshape([-2.0], 1, 1)) throws ErrorException: dmrg currently does not support system sizes of 1.
  • julia --project=. -e 'using Pkg; Pkg.test()' on this branch: passed (Testing TenSolver tests passed), QUBO Correctness 82/82 (was 78 on main), all other testsets green (Ill-formed input, PUBO, Logging, JuMP, QUBODrivers.jl, Aqua.jl, VRP, HDF5, Doctests).

Notes

  • Local Manifest.toml files are gitignored and must be re-resolved for the active Julia version; a stale 1.12-resolved manifest causes Pkg.test() to fail on 1.10. Removing it forces a fresh resolve, which is what CI does. No manifest is committed.
  • No new dependencies; no CI/workflow changes.

Closes #49

ITensor DMRG does not support system sizes of 1, so minimize/maximize
crashed on 1x1 QUBO inputs. Add an exact single-variable path that
evaluates the objective at x=0 and x=1 (reporting degeneracy when equal)
and returns a Solution consistent with the multi-variable path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@bernalde bernalde left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues: none.

Nonblocking issues: none.

Questions: none.

Tests run and outcomes:

  • Confirmed PR metadata and diff basis: merge-base ca2788038c2528a312a5315752d45ce2c0dff40a; local diff matched GitHub totals, 2 files changed, +71/-0.
  • julia --project=. -e 'using Pkg; Pkg.test()' on the PR head: passed.
  • julia --project=. -e 'using Pkg; Pkg.instantiate(); using TenSolver; minimize(reshape([-2.0],1,1); verbosity=0)' on origin/main: reproduced dmrg currently does not support system sizes of 1.
  • PR-head smoke for single-variable callback/stat behavior: passed.
  • PR-head smoke for a single-variable DynamicPolynomials input under the test project: passed.

Merge-readiness: I found no blocking issues. The change addresses #49, and the Closes #49 linkage matches the issue scope. This PR is still a draft, and because I am the PR author I am submitting this as COMMENT; formal approval must come from another maintainer.

@bernalde bernalde marked this pull request as ready for review June 8, 2026 22:20
@iagoleal iagoleal merged commit b67de66 into main Jun 11, 2026
11 checks passed
@iagoleal iagoleal deleted the fix/issue-49-single-variable-solve branch June 11, 2026 18:14
@iagoleal

Copy link
Copy Markdown
Collaborator

We should now edit #32, #33, #34, and #41 to remove the redundancy

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.

minimize/maximize crash on single-variable (1x1) QUBO inputs

2 participants