Skip to content

MesoHOPS 1.8.0 - #8

Open
alexiahartzell wants to merge 1 commit into
masterfrom
release-v1.8.0
Open

MesoHOPS 1.8.0#8
alexiahartzell wants to merge 1 commit into
masterfrom
release-v1.8.0

Conversation

@alexiahartzell

@alexiahartzell alexiahartzell commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

MesoHOPS 1.8.0

This commit introduces tensor-network HOPS, a Matrix Product State representation of the hierarchy wavefunction, and adds rectangular hierarchy truncation, nondyadic spectroscopy, and per-step timing instrumentation.

Key improvements and features:

  1. Tensor-network HOPS: The new mesohops.tensor subpackage represents the hierarchy wavefunction as a Matrix Product State rather than a flat auxiliary-enumerated vector. HopsTensorWavefunction handles MPS storage, normalization, operator application, and bond-dimension control; HopsTensorEOM evaluates the equation of motion directly on the MPS; and mpo_constructors.py builds the Hamiltonian, dipole, and state-number MPOs. Hierarchy depth is encoded in the MPS core dimensions (k_max + 1 per mode) rather than through explicit auxiliary-vector enumeration, so n_hier, n_hmodes, and ADAPTIVE_H do not apply on this path. Two representations are available via method: 'number', in which the ground state is implicit as the all-zero MPS configuration, and 'fullstate'. Tensor adaptivity is not supported in this release — see the note below.

  2. Rectangular hierarchy truncation: HopsHierarchy gains a TRUNCATION_METHOD parameter ('triangular', the default and prior behavior, or 'rectangular'). define_rectangular_hierarchy() admits every per-mode depth combination in [0, MAXHIER]^n_hmodes, matching the MPS core structure used by tensor HOPS. Rectangular truncation is unsupported for adaptive calculations and raises NotImplementedError, because the vector adaptive flux filters enforce the MAXHIER boundary through total auxiliary depth, which is inherently triangular. Relatedly, add_connections no longer short-circuits the k+1 loop on total depth, which rectangular hierarchies require since their per-mode depths may sum above MAXHIER.

  3. Nondyadic spectroscopy: util/nondyadic_spectroscopy.py dispatches on trajectory type, tensor method, and Hilbert-space convention: embedded, where the ground state occupies an explicit basis slot; vacuum, where it is the implicit all-zero MPS configuration; and excited_only.

  4. Nearest-neighbor Hamiltonian detection: HopsSystem exposes flag_nearest_neighbor_ham, computed at construction, indicating whether all non-zero Hamiltonian elements satisfy |row - col| <= 1. Explicit stored zeros are eliminated first so that a user-supplied sparse matrix with padded off-diagonals is not misclassified.

  5. Per-step timing and storage additions: A new STORE_STEP_TIMING integration parameter (default False) records wall-clock time for each integration step. When enabled, storage.metadata["LIST_PROPAGATION_TIME"] holds (t, elapsed) tuples per step rather than a single total-elapsed float per propagate() call; the default is unchanged. A psi_g_traj storage option captures <0,...,0|psi> per step, which the vacuum-convention spectroscopy path requires because extract_psi sees only the excited-state slots.

  6. Integrator rename and hierarchy error handling: mesohops.integrator.integrator_rk is renamed to mesohops.integrator.integrator, so code importing runge_kutta_step or runge_kutta_variables must update the import path. Integrator setup moved into an overridable HopsTrajectory._setup_integrator() hook so subclasses can register additional integrators.

Warning

NOTE — this release breaks existing scripts that import the Runge-Kutta integrator. mesohops.integrator.integrator_rk is renamed to mesohops.integrator.integrator, with no backwards-compatible alias, so any script importing from the old path fails immediately with ModuleNotFoundError:

# before (1.7.0)
from mesohops.integrator.integrator_rk import runge_kutta_step, runge_kutta_variables
# after (1.8.0)
from mesohops.integrator.integrator import runge_kutta_step, runge_kutta_variables

Warning

NOTE — adaptivity is not supported for tensor HOPS in this release. The adaptive code paths (HopsTensorBasis.update_basis, tensor_functions_adaptive.py, and HopsTensorTrajectory.make_adaptive) are present in the source but are not finished. Calling make_adaptive() on a HopsTensorTrajectory is not blocked at runtime, so do not use tensor adaptivity for production results. Non-adaptive tensor HOPS is unaffected.

These enhancements extend MesoHOPS beyond vector HOPS into tensor-network territory, broadening the range of system sizes and bath structures the library can reach.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Highlights of v1.8.0 (vs. mesohops 1.7.0):

Tensor-network HOPS (TadHOPS):
- src/mesohops/tensor/: new subpackage representing the hierarchy
  wavefunction as an MPS rather than a flat auxiliary-enumerated vector.
  hops_tensor_wavefunction.py holds MPS storage, normalization, operator
  application, and bond-dimension control; hops_tensor_eom.py and
  tensor_eom_functions.py evaluate the EOM directly on the MPS;
  mpo_constructors.py builds the Hamiltonian, dipole, and state-number
  MPOs. Hierarchy depth lives in the MPS core dimensions (k_max + 1 per
  mode), so n_hier, n_hmodes, and ADAPTIVE_H do not apply on this path.
  Representation selected by method: 'number' (ground state implicit as
  the all-zero MPS configuration) or 'fullstate'.
- src/mesohops/tensor/tdvp.py: one- and two-site TDVP following Paeckel
  et al. (2019), in mixed canonical form over bare lists of np.ndarray.
  Local update solvers: Arnoldi, Lanczos, solve_ivp.
- src/mesohops/trajectory/hops_tensor_trajectory.py: user-facing driver.
  INTEGRATOR accepts 'TDVP1' and 'TDVP2' alongside 'RUNGE_KUTTA';
  TDVP_UPDATE_TYPE selects the local update scheme (default 'krylov').
- src/mesohops/integrator/tensor_integrator.py: MPS-aware RK4 path.
- src/mesohops/util/tensor_operations.py: core MPS arithmetic (add,
  compress via Oseledets rounding, extraction, contraction).
- Adaptivity is NOT supported for tensor HOPS in this release. The
  adaptive paths (hops_tensor_basis.update_basis,
  tensor_functions_adaptive.py, HopsTensorTrajectory.make_adaptive) are
  present but unfinished, and are not blocked at runtime. Non-adaptive
  tensor HOPS is unaffected. list_permanent_sites raises
  NotImplementedError, since HopsTensorBasis never reads it and would
  otherwise ignore it silently.

Hierarchy:
- src/mesohops/basis/hops_hierarchy.py: add TRUNCATION_METHOD
  ('triangular', the default and prior behavior, or 'rectangular').
  define_rectangular_hierarchy() admits every per-mode depth combination
  in [0, MAXHIER]^n_hmodes, matching the MPS core structure. Rectangular
  truncation raises NotImplementedError for adaptive calculations: the
  vector adaptive flux filters enforce the MAXHIER boundary through total
  auxiliary depth, which is inherently triangular.
- src/mesohops/basis/hops_hierarchy.py: add_connections no longer
  short-circuits the k+1 loop on total depth, required for rectangular
  hierarchies whose per-mode depths may sum above MAXHIER.
- src/mesohops/basis/hops_hierarchy.py: a negative _count_by_modes entry
  now raises ValueError rather than printing and continuing; the
  MAXHIER > 255 notice moves from print to warnings.warn; remove the
  private static method _const_aux_edge().

Spectroscopy:
- src/mesohops/util/nondyadic_spectroscopy.py: new dispatch on trajectory
  type, tensor method, and Hilbert-space convention (embedded, vacuum,
  excited_only).

System and storage:
- src/mesohops/basis/hops_system.py: add flag_nearest_neighbor_ham,
  True when all non-zero Hamiltonian elements satisfy |row - col| <= 1.
  Explicit stored zeros are eliminated first so padded sparse input is
  not misclassified.
- src/mesohops/storage/hops_storage.py: add psi_g_traj storage option
  capturing <0,...,0|psi> per step, needed by the vacuum-convention
  spectroscopy path because extract_psi sees only excited-state slots.
- src/mesohops/storage/storage_functions.py: add tensor-aware
  save_phi_traj_tensor, save_phi_norm_tensor, save_max_tensor_complexity.

Integration:
- src/mesohops/integrator/integrator_rk.py -> integrator.py: module
  rename. Imports of runge_kutta_step and runge_kutta_variables must be
  updated.
- src/mesohops/trajectory/hops_trajectory.py: move integrator setup into
  an overridable _setup_integrator() hook so subclasses can register
  additional integrators.
- src/mesohops/trajectory/hops_trajectory.py: add STORE_STEP_TIMING
  integration parameter (default False). When enabled,
  storage.metadata["LIST_PROPAGATION_TIME"] holds (t, elapsed) tuples per
  step rather than one total-elapsed float per propagate() call.

Coverage:
- .github/workflows/coverage.yml: also run on pushes to master, so
  Codecov has a base report to diff against; upgrade codecov-action from
  the sunset v3 uploader to v5; rename the deprecated file: input to
  files:; set fail_ci_if_error to true. Uploads had been failing silently
  since the workflow was introduced, leaving every job green and Codecov
  empty.
- .github/workflows/coverage.yml: run the coverage suite at --level 3,
  overriding the --level=1 in pytest.ini addopts. At level 1 the level-2
  and level-3 tests are deselected and contribute nothing, understating
  measured coverage.
- README.md: add coverage badge.

Cleanup:
- tests/test_hierarchy_class.py -> test_hops_hierarchy.py: rename to
  match its subject.
- tests/test_eom_hops_ksuper.py: correct a stale library name in a docstring.
- .gitignore: expand from a single *.pyc line to a full Python ignore set,
  so coverage and build artifacts stop appearing as untracked noise.
- style_guide.md: document when to annotate docstring units, including
  the [units: dimensionless] convention and bracket contents for
  heterogeneous container types.
- .github/CODEOWNERS: add, gating master merges on approval from a listed
  owner. Takes effect only where branch protection enables
  require_code_owner_reviews.

Test results: level-1 suite passes 780/780 (2 xfailed, 93 deselected).
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.

2 participants