Solve single-variable QUBO inputs exactly instead of crashing#50
Merged
Conversation
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
commented
Jun 8, 2026
bernalde
left a comment
Member
Author
There was a problem hiding this comment.
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)'onorigin/main: reproduceddmrg 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.
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 free
to 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.
Summary
minimize/maximizecrashed on single-variable (1x1) QUBO inputs because the underlying ITensor DMRG solver 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 atx = 0andx = 1, returns the minimizer's energy (or reports degeneracy as a uniform superposition when the two are equal), and constructs aSolutionconsistent with the multi-variable path (energies/bond_dims/elapsed_times populated, iteration log andon_iterationcallback 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.jlunder "QUBO Correctness": single variable, single variable with linear and constant terms, single-variable degeneracy, and single-variable maximize. On unmodifiedmainthe first of these throws (dmrg ... system sizes of 1); with this change they pass.Commands and results (Julia 1.10.11):
main(clean re-resolved env):minimize(reshape([-2.0], 1, 1))throwsErrorException: 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 Correctness82/82 (was 78 onmain), all other testsets green (Ill-formed input, PUBO, Logging, JuMP, QUBODrivers.jl, Aqua.jl, VRP, HDF5, Doctests).Notes
Manifest.tomlfiles are gitignored and must be re-resolved for the active Julia version; a stale 1.12-resolved manifest causesPkg.test()to fail on 1.10. Removing it forces a fresh resolve, which is what CI does. No manifest is committed.Closes #49