{"id":9270,"library":"quimb","title":"quimb","description":"quimb is a versatile Python library for quantum information and many-body physics, offering tools for exact diagonalization, tensor networks (Matrix Product States, PEPS, etc.), quantum circuits, and general quantum mechanics simulations. It is currently at version 1.13.0 and maintains an active release cadence, with major and minor updates often arriving monthly or bi-monthly, frequently including breaking changes.","status":"active","version":"1.13.0","language":"en","source_language":"en","source_url":"https://github.com/jcmgray/quimb/","tags":["quantum","tensor networks","physics","matrix product states","quantum computing","simulation"],"install":[{"cmd":"pip install quimb","lang":"bash","label":"Basic installation"},{"cmd":"pip install quimb[tensor,cut]","lang":"bash","label":"Recommended for full tensor network features"}],"dependencies":[{"reason":"Core numerical operations and array manipulation.","package":"numpy"},{"reason":"Scientific computing functionalities like linear algebra and sparse matrices.","package":"scipy"},{"reason":"Just-in-time compilation for performance critical code sections (requires numba>=0.56).","package":"numba"},{"reason":"Optimized tensor contraction path finding, highly recommended for tensor networks.","package":"opt_einsum","optional":true},{"reason":"Advanced tensor contraction path finding, offering significant speedups for complex networks.","package":"cotengra","optional":true}],"imports":[{"symbol":"quimb","correct":"import quimb as qb"},{"symbol":"quimb.tensor","correct":"import quimb.tensor as qb.tn"},{"note":"Moved in v1.12.0 from its own submodule to the main `quimb.operator` module.","wrong":"from quimb.operatorbuilder import OperatorBuilder","symbol":"OperatorBuilder","correct":"from quimb.operator import OperatorBuilder"},{"note":"Moved in v1.11.0 from `quimb.tensor` to its dedicated `quimb.tensor.belief_propagation` submodule.","wrong":"from quimb.tensor import belief_propagation","symbol":"belief_propagation","correct":"from quimb.tensor.belief_propagation import ..."}],"quickstart":{"code":"import quimb as qb\nimport quimb.tensor as qb.tn\n\n# Create a random state vector\npsi = qb.rand_ket(8)  # 8-dimensional random state\nprint(f\"State vector shape: {psi.shape}\")\n\n# Create a simple Matrix Product State (MPS)\nL = 10  # Number of sites\nD = 8   # Max bond dimension\nd = 2   # Local dimension\npsi_mps = qb.tn.rand_mps(L, D, d)\nprint(f\"MPS with {L} sites, max bond dim {psi_mps.max_bond_dim()}, local dim {d}\")\n\n# Calculate the MPS norm\nprint(f\"MPS norm: {psi_mps.norm()}\")\n\n# Contract the MPS to a single tensor (the full state vector)\n# Note: This can be memory intensive for large L and D\nfull_state_from_mps = psi_mps.contract()\nprint(f\"Full state from MPS shape: {full_state_from_mps.shape}\")","lang":"python","description":"This quickstart demonstrates creating a random state vector and a simple Matrix Product State (MPS) using quimb's core and tensor network modules, along with basic operations like calculating norm and contraction."},"warnings":[{"fix":"Ensure your Python environment is 3.11 or greater. Consider using pyenv or conda for managing Python versions.","message":"quimb now requires Python 3.11 or newer.","severity":"breaking","affected_versions":">=1.12.1"},{"fix":"If using these Hamiltonian generation functions, review your energy calculations and potentially adjust signs in your code to match the new convention (refer to official docs for details).","message":"Sign conventions for hopping strength `t` in `ham_hubbard_hardcore` and magnetic field terms in `heisenberg_from_edges` have been fixed/changed.","severity":"breaking","affected_versions":">=1.13.0"},{"fix":"Update your import statements from `from quimb.operatorbuilder import OperatorBuilder` to `from quimb.operator import OperatorBuilder`.","message":"The `OperatorBuilder` class has moved from `quimb.operatorbuilder` to `quimb.operator`.","severity":"breaking","affected_versions":">=1.12.0"},{"fix":"Adjust import paths from `from quimb.tensor import belief_propagation` (or specific functions) to `from quimb.tensor.belief_propagation import ...`.","message":"The `belief_propagation` module has moved from `quimb.tensor` to its own submodule `quimb.tensor.belief_propagation`.","severity":"breaking","affected_versions":">=1.11.0"},{"fix":"Update calls from `mps.partial_trace(...)` to `mps.partial_trace_to_mpo(...)`.","message":"The method `MatrixProductState.partial_trace` was renamed to `MatrixProductState.partial_trace_to_mpo` to clarify its output type (an MPO).","severity":"breaking","affected_versions":">=1.9.0"},{"fix":"For performance, consider installing `opt_einsum` and `cotengra` (`pip install quimb[tensor,cut]`). For specific problems, manually specify `optimize` strategies (e.g., `'optimal'`, `'greedy'`, or use a `ContractionTree` object) for `tn.contract()`.","message":"Tensor network contraction can be computationally and memory intensive. Default optimization (`optimize='auto'`) might not always be ideal for very large or complex networks.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change your import statement to `from quimb.operator import OperatorBuilder`.","cause":"The `OperatorBuilder` class was moved in quimb v1.12.0 from `quimb.operatorbuilder` to `quimb.operator`.","error":"ImportError: cannot import name 'OperatorBuilder' from 'quimb.operatorbuilder'"},{"fix":"Upgrade your Python installation to version 3.11 or higher. For example, using `conda create -n quimb_env python=3.11` or `pyenv install 3.11`.","cause":"You are attempting to run quimb version 1.12.1 or newer on a Python environment older than 3.11.","error":"RuntimeError: 'quimb' requires python>=3.11."},{"fix":"Carefully review the indices of your tensors and the `output_inds` argument passed to `tn.contract()`. Ensure all internal indices are matched for summation and only desired external indices are left.","cause":"When performing a tensor network contraction, some indices that were expected to be summed over remain uncontracted, often due to an incorrect `output_inds` specification or a mismatch in tensor indices.","error":"TypeError: not all indices were contracted (contracting ... to ...)"},{"fix":"Upgrade both `numba` and `numpy` to their latest compatible versions. Use `pip install --upgrade numba numpy`.","cause":"This warning typically indicates a minor compatibility issue between the installed `numba` and `numpy` versions, or a general Numba best-practice recommendation. While usually harmless, it can sometimes precede other issues.","error":"NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'jit' decorator."}]}