Introduce solver backend interface#43
Conversation
bernalde
left a comment
There was a problem hiding this comment.
GitHub rejected REQUEST_CHANGES because this authenticated account is the pull request author, so I am submitting this as COMMENT. Maintainer recommendation: do not merge as-is.
Review summary:
- Blocking issues: 1. The symbolic backend normalization is not extensible for the later optional
backend = :pepspath described by the docs. - Nonblocking issues: none.
- Questions: none.
- Tests run and outcomes:
julia --project=. -e 'using Pkg; Pkg.instantiate()': passed.- Targeted
test/backend.jlon Julia 1.11.5: passed, 13/13. - Custom backend object dispatch probe: passed.
- Symbol-extension dispatch probe: confirmed value-specific symbol extension is not reachable.
git diff --check origin/feature/issue-36-qubo-ising-conversion...HEAD: passed.- Targeted
test/backend.jlon Julia 1.10.11: passed, 13/13. julia --project=. -e 'using Pkg; Pkg.test()': passed.- Documented docs setup command: passed.
julia --project=docs/ docs/make.jl local: passed.- GitHub CI checks inspected: all current checks are passing.
- Merge as-is: no.
I would not merge this until the blocking issue above is addressed.
|
|
||
| _normalize_backend(backend::DMRGBackend) = backend | ||
| _normalize_backend(backend::AbstractTenSolverBackend) = backend | ||
| function _normalize_backend(backend::Symbol) |
There was a problem hiding this comment.
Blocking: This catches every Symbol backend in one concrete method, so an optional package extension cannot later implement the documented backend = :peps path with normal Julia dispatch. minimize(...; backend = :peps) will always enter this method and throw before backend-specific _minimize methods can run, which makes the new backend interface much harder to extend without editing core TenSolver again or overwriting this method.
Use a value-dispatch hook instead, for example _normalize_backend(backend::Symbol) = _normalize_backend(Val(backend)), _normalize_backend(::Val{:dmrg}) = default_backend, and a fallback _normalize_backend(::Val{backend}) where backend = throw(_backend_error(backend)). Then a PEPS extension can add _normalize_backend(::Val{:peps}) = PEPSBackend(...). Please also add a regression test with a fake symbolic backend so this extension path stays covered.
There was a problem hiding this comment.
Addressed in f4a3769. Symbol normalization now dispatches through Val(backend), :dmrg stays mapped to the default backend, and test/backend.jl covers a fake symbol-specific backend reaching its _minimize method.
|
Pushed commit Main changes:
Tests run:
Comments intentionally not addressed: none. Remaining risks/follow-up:
|
|
Blocking: The PR introduces the backend boundary, but the committed symbol normalization currently hard-codes A concrete fix is to route symbols through _normalize_backend(backend::Symbol) = _normalize_backend(Val(backend))
_normalize_backend(::Val{:dmrg}) = default_backend
function _normalize_backend(::Val{backend}) where {backend}
throw(_backend_error(backend))
endThen a later PEPS bridge can implement |
bernalde
left a comment
There was a problem hiding this comment.
GitHub rejected APPROVE because this authenticated account is the pull request author, so I am submitting this as COMMENT. Maintainer recommendation: merge-ready as-is.
Review summary:
- Blocking issues: none.
- Nonblocking issues: none.
- Questions: none.
- Tests run and outcomes:
julia --project=. -e 'using Pkg; Pkg.instantiate()': passed.- Targeted
test/backend.jlon Julia 1.11.5: passed, 19/19. - Targeted
test/backend.jlon Julia 1.10.11: passed, 19/19. - Module-scoped fake backend extension probe: passed.
git diff --check origin/feature/issue-36-qubo-ising-conversion...HEAD: passed.julia --project=. -e 'using Pkg; Pkg.test()': passed.- Documented docs setup command: passed.
julia --project=docs/ docs/make.jl local: passed.- GitHub CI checks inspected: all current checks are passing.
- Merge as-is: yes.
The latest head uses Val dispatch for symbolic backend normalization and covers the extension path with a fake symbolic backend test. I found no actionable issues requiring inline comments.
f4a3769 to
009bcd1
Compare
Summary
AbstractTenSolverBackendandDMRGBackendas the core backend boundary.minimizecalls through backend-specific dispatch while keeping the current DMRG implementation as the default.backend = :dmrgorbackend = DMRGBackend().maximize, QUBO/PUBO lowering, existing DMRG keywords,Solution, sampling, and QUBODrivers default behavior.backend = :peps.This is stacked on PR #42 and targets
feature/issue-36-qubo-ising-conversion.Tests run
git diff --check- passed.julia +1.12 --project=. -e 'using Test, Random, LinearAlgebra, TenSolver; include("test/backend.jl")'- passed, 13 tests.julia --project=docs/ docs/make.jl local- passed, including Documenter doctests.julia +1.12 --project=. -e 'using Pkg; Pkg.test()'- passed.Notes
Closes #37