qmb
Advanced tools
+66
| """ | ||
| This file implements a perturbation estimator from haar. | ||
| """ | ||
| import logging | ||
| import typing | ||
| import dataclasses | ||
| import tyro | ||
| from .common import CommonConfig | ||
| from .subcommand_dict import subcommand_dict | ||
| @dataclasses.dataclass | ||
| class PerturbationConfig: | ||
| """ | ||
| The perturbation estimator from haar. | ||
| """ | ||
| common: typing.Annotated[CommonConfig, tyro.conf.OmitArgPrefixes] | ||
| def main(self, *, model_param: typing.Any = None, network_param: typing.Any = None) -> None: | ||
| """ | ||
| The main function of two-step optimization process based on imaginary time. | ||
| """ | ||
| # pylint: disable=too-many-locals | ||
| # pylint: disable=too-many-statements | ||
| # pylint: disable=too-many-branches | ||
| model, _, data = self.common.main(model_param=model_param, network_param=network_param) | ||
| if "haar" not in data and "imag" in data: | ||
| data["haar"] = data.pop("imag") | ||
| configs, psi = data["haar"]["pool"] | ||
| configs = configs.to(self.common.device) | ||
| psi = psi.to(self.common.device) | ||
| energy0_num = psi.conj() @ model.apply_within(configs, psi, configs) | ||
| energy0_den = psi.conj() @ psi | ||
| energy0 = (energy0_num / energy0_den).real.item() | ||
| logging.info("Current energy is %.8f", energy0) | ||
| logging.info("Reference energy is %.8f", model.ref_energy) | ||
| number = configs.size(0) | ||
| last_result_number = 0 | ||
| current_target_number = number | ||
| logging.info("Starting finding relative configurations with %d.", number) | ||
| while True: | ||
| other_configs = model.find_relative(configs, psi, current_target_number, configs) | ||
| current_result_number = other_configs.size(0) | ||
| logging.info("Found %d relative configurations.", current_result_number) | ||
| if current_result_number == last_result_number: | ||
| logging.info("No new configurations found, stopping at %d.", current_result_number) | ||
| break | ||
| current_target_number = current_target_number * 2 | ||
| logging.info("Doubling target number to %d.", current_target_number) | ||
| break | ||
| hamiltonian_psi = model.apply_within(configs, psi, other_configs) | ||
| energy2_num = (hamiltonian_psi.conj() @ hamiltonian_psi).real / (psi.conj() @ psi).real | ||
| energy2_den = energy0 - model.diagonal_term(other_configs).real | ||
| energy2 = (energy2_num / energy2_den).sum().item() | ||
| logging.info("Correct energy is %.8f", energy2) | ||
| logging.info("Error is reduced from %.8f to %.8f", energy0 - model.ref_energy, energy2 - model.ref_energy) | ||
| subcommand_dict["pert"] = PerturbationConfig |
@@ -20,3 +20,3 @@ name: Build docker images | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
@@ -23,0 +23,0 @@ fetch-depth: 0 |
@@ -12,3 +12,3 @@ name: Pre-commit Hooks | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v5 | ||
@@ -15,0 +15,0 @@ - uses: actions/setup-python@v5 |
@@ -13,3 +13,3 @@ name: Build wheels | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
@@ -31,3 +31,3 @@ fetch-depth: 0 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
@@ -53,6 +53,6 @@ fetch-depth: 0 | ||
| id-token: write | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.event.repository.visibility == 'public' | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| - uses: actions/download-artifact@v5 | ||
| with: | ||
@@ -59,0 +59,0 @@ pattern: build-* |
+1
-1
| # Use the specified CUDA base image with Rocky Linux 9 | ||
| FROM nvidia/cuda:12.9.1-cudnn-devel-rockylinux9 | ||
| FROM nvidia/cuda:13.0.0-cudnn-devel-rockylinux9 | ||
@@ -4,0 +4,0 @@ # Install dependencies |
+10
-10
| Metadata-Version: 2.4 | ||
| Name: qmb | ||
| Version: 0.0.51 | ||
| Version: 0.0.52 | ||
| Summary: Quantum Manybody Problem | ||
@@ -25,11 +25,11 @@ Author-email: Hao Zhang <hzhangxyz@outlook.com> | ||
| Requires-Dist: platformdirs~=4.3.7 | ||
| Requires-Dist: numpy~=1.26.4 | ||
| Requires-Dist: scipy~=1.15.2 | ||
| Requires-Dist: torch<2.8,>=2.6 | ||
| Requires-Dist: pybind11~=2.13.6 | ||
| Requires-Dist: ninja~=1.11.1.4 | ||
| Requires-Dist: numpy<2.4.0,>=1.26.4 | ||
| Requires-Dist: scipy<1.17.0,>=1.15.2 | ||
| Requires-Dist: torch<2.9,>=2.6 | ||
| Requires-Dist: pybind11<3.1.0,>=2.13.6 | ||
| Requires-Dist: ninja<1.13.1.0,>=1.11.1.4 | ||
| Requires-Dist: tyro~=0.9.18 | ||
| Requires-Dist: pyyaml~=6.0.2 | ||
| Requires-Dist: openfermion~=1.7.0 | ||
| Requires-Dist: tensorboard~=2.19.0 | ||
| Requires-Dist: tensorboard<2.21,>=2.19 | ||
| Requires-Dist: standard-imghdr~=3.13.0; python_version >= "3.13" | ||
@@ -41,9 +41,9 @@ Provides-Extra: dev | ||
| Requires-Dist: pytest<8.5.0,>=8.3.5; extra == "dev" | ||
| Requires-Dist: pytest-cov~=6.0.0; extra == "dev" | ||
| Requires-Dist: pytest-cov<6.3,>=6.0; extra == "dev" | ||
| Requires-Dist: types-pyyaml~=6.0.12.20250326; extra == "dev" | ||
| Dynamic: license-file | ||
| # An efficient Neural-Network Quantum States Architecture for Strongly Correlated Systems | ||
| # Hamiltonian-Guided Autoregressive Selected-Configuration Interaction(HAAR-SCI) Achieves Chemical Accuracy in Strongly Correlated Systems | ||
| The Quantum-Many-Body (`qmb`) is a powerful tool designed to solve quantum-many-body problems. | ||
| The current project temporarily named as Quantum-Many-Body (`qmb`) which is a powerful tool designed to solve quantum-many-body problems especially for strongly correlated systems. | ||
@@ -50,0 +50,0 @@ ## About The Project |
+8
-8
| [build-system] | ||
| requires = ["setuptools>=78.0,<80.10", "setuptools_scm~=8.2.0"] | ||
| requires = ["setuptools>=78.0,<80.10", "setuptools_scm>=8.2,<9.3"] | ||
| build-backend = "setuptools.build_meta" | ||
@@ -10,11 +10,11 @@ | ||
| "platformdirs~=4.3.7", | ||
| "numpy~=1.26.4", | ||
| "scipy~=1.15.2", | ||
| "torch>=2.6,<2.8", | ||
| "pybind11~=2.13.6", | ||
| "ninja~=1.11.1.4", | ||
| "numpy>=1.26.4,<2.4.0", | ||
| "scipy>=1.15.2,<1.17.0", | ||
| "torch>=2.6,<2.9", | ||
| "pybind11>=2.13.6,<3.1.0", | ||
| "ninja>=1.11.1.4,<1.13.1.0", | ||
| "tyro~=0.9.18", | ||
| "pyyaml~=6.0.2", | ||
| "openfermion~=1.7.0", | ||
| "tensorboard~=2.19.0", | ||
| "tensorboard>=2.19,<2.21", | ||
| "standard-imghdr~=3.13.0 ; python_version>='3.13'", | ||
@@ -46,3 +46,3 @@ ] | ||
| "pytest>=8.3.5,<8.5.0", | ||
| "pytest-cov~=6.0.0", | ||
| "pytest-cov>=6.0,<6.3", | ||
| "types-pyyaml~=6.0.12.20250326", | ||
@@ -49,0 +49,0 @@ ] |
+10
-10
| Metadata-Version: 2.4 | ||
| Name: qmb | ||
| Version: 0.0.51 | ||
| Version: 0.0.52 | ||
| Summary: Quantum Manybody Problem | ||
@@ -25,11 +25,11 @@ Author-email: Hao Zhang <hzhangxyz@outlook.com> | ||
| Requires-Dist: platformdirs~=4.3.7 | ||
| Requires-Dist: numpy~=1.26.4 | ||
| Requires-Dist: scipy~=1.15.2 | ||
| Requires-Dist: torch<2.8,>=2.6 | ||
| Requires-Dist: pybind11~=2.13.6 | ||
| Requires-Dist: ninja~=1.11.1.4 | ||
| Requires-Dist: numpy<2.4.0,>=1.26.4 | ||
| Requires-Dist: scipy<1.17.0,>=1.15.2 | ||
| Requires-Dist: torch<2.9,>=2.6 | ||
| Requires-Dist: pybind11<3.1.0,>=2.13.6 | ||
| Requires-Dist: ninja<1.13.1.0,>=1.11.1.4 | ||
| Requires-Dist: tyro~=0.9.18 | ||
| Requires-Dist: pyyaml~=6.0.2 | ||
| Requires-Dist: openfermion~=1.7.0 | ||
| Requires-Dist: tensorboard~=2.19.0 | ||
| Requires-Dist: tensorboard<2.21,>=2.19 | ||
| Requires-Dist: standard-imghdr~=3.13.0; python_version >= "3.13" | ||
@@ -41,9 +41,9 @@ Provides-Extra: dev | ||
| Requires-Dist: pytest<8.5.0,>=8.3.5; extra == "dev" | ||
| Requires-Dist: pytest-cov~=6.0.0; extra == "dev" | ||
| Requires-Dist: pytest-cov<6.3,>=6.0; extra == "dev" | ||
| Requires-Dist: types-pyyaml~=6.0.12.20250326; extra == "dev" | ||
| Dynamic: license-file | ||
| # An efficient Neural-Network Quantum States Architecture for Strongly Correlated Systems | ||
| # Hamiltonian-Guided Autoregressive Selected-Configuration Interaction(HAAR-SCI) Achieves Chemical Accuracy in Strongly Correlated Systems | ||
| The Quantum-Many-Body (`qmb`) is a powerful tool designed to solve quantum-many-body problems. | ||
| The current project temporarily named as Quantum-Many-Body (`qmb`) which is a powerful tool designed to solve quantum-many-body problems especially for strongly correlated systems. | ||
@@ -50,0 +50,0 @@ ## About The Project |
| platformdirs~=4.3.7 | ||
| numpy~=1.26.4 | ||
| scipy~=1.15.2 | ||
| torch<2.8,>=2.6 | ||
| pybind11~=2.13.6 | ||
| ninja~=1.11.1.4 | ||
| numpy<2.4.0,>=1.26.4 | ||
| scipy<1.17.0,>=1.15.2 | ||
| torch<2.9,>=2.6 | ||
| pybind11<3.1.0,>=2.13.6 | ||
| ninja<1.13.1.0,>=1.11.1.4 | ||
| tyro~=0.9.18 | ||
| pyyaml~=6.0.2 | ||
| openfermion~=1.7.0 | ||
| tensorboard~=2.19.0 | ||
| tensorboard<2.21,>=2.19 | ||
@@ -20,3 +20,3 @@ [:python_version >= "3.13"] | ||
| pytest<8.5.0,>=8.3.5 | ||
| pytest-cov~=6.0.0 | ||
| pytest-cov<6.3,>=6.0 | ||
| types-pyyaml~=6.0.12.20250326 |
@@ -43,2 +43,3 @@ .clang-format | ||
| qmb/optimizer.py | ||
| qmb/pert.py | ||
| qmb/precompile.py | ||
@@ -45,0 +46,0 @@ qmb/random_engine.py |
+1
-0
@@ -18,2 +18,3 @@ """ | ||
| from . import chop_imag as _ # type: ignore[no-redef] | ||
| from . import pert as _ # type: ignore[no-redef] | ||
| from . import run as _ # type: ignore[no-redef] | ||
@@ -20,0 +21,0 @@ from .subcommand_dict import subcommand_dict |
@@ -87,2 +87,3 @@ #include <pybind11/complex.h> | ||
| ); | ||
| m.def("diagonal_term(Tensor configs, Tensor site, Tensor kind, Tensor coef) -> Tensor"); | ||
| m.def("single_relative(Tensor configs, Tensor site, Tensor kind, Tensor coef) -> Tensor"); | ||
@@ -89,0 +90,0 @@ } |
+16
-3
| # file generated by setuptools-scm | ||
| # don't change, don't track in version control | ||
| __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"] | ||
| __all__ = [ | ||
| "__version__", | ||
| "__version_tuple__", | ||
| "version", | ||
| "version_tuple", | ||
| "__commit_id__", | ||
| "commit_id", | ||
| ] | ||
@@ -12,4 +19,6 @@ TYPE_CHECKING = False | ||
| VERSION_TUPLE = Tuple[Union[int, str], ...] | ||
| COMMIT_ID = Union[str, None] | ||
| else: | ||
| VERSION_TUPLE = object | ||
| COMMIT_ID = object | ||
@@ -20,4 +29,8 @@ version: str | ||
| version_tuple: VERSION_TUPLE | ||
| commit_id: COMMIT_ID | ||
| __commit_id__: COMMIT_ID | ||
| __version__ = version = '0.0.51' | ||
| __version_tuple__ = version_tuple = (0, 0, 51) | ||
| __version__ = version = '0.0.52' | ||
| __version_tuple__ = version_tuple = (0, 0, 52) | ||
| __commit_id__ = commit_id = 'g9ec0312c4' |
+3
-0
@@ -195,2 +195,5 @@ """ | ||
| def diagonal_term(self, configs: torch.Tensor) -> torch.Tensor: | ||
| return self.hamiltonian.diagonal_term(configs) | ||
| def single_relative(self, configs: torch.Tensor) -> torch.Tensor: | ||
@@ -197,0 +200,0 @@ return self.hamiltonian.single_relative(configs) |
+1
-15
@@ -526,16 +526,2 @@ """ | ||
| subcommand_dict["haar"] = HaarConfig | ||
| class ImagConfig(HaarConfig): | ||
| """ | ||
| Deprecated, use "haar" instead. | ||
| """ | ||
| # pylint: disable=too-few-public-methods | ||
| def __post_init__(self) -> None: | ||
| logging.warning("The 'imag' subcommand is deprecated, please use 'haar' instead.") | ||
| super().__post_init__() | ||
| subcommand_dict["imag"] = ImagConfig | ||
| subcommand_dict["imag"] = HaarConfig |
+20
-0
@@ -168,2 +168,22 @@ """ | ||
| def diagonal_term(self, configs: torch.Tensor) -> torch.Tensor: | ||
| """ | ||
| Get the diagonal term of the Hamiltonian for the given configurations. | ||
| Parameters | ||
| ---------- | ||
| configs : torch.Tensor | ||
| A uint8 tensor of shape [batch_size, n_qubytes] representing the input configurations. | ||
| Returns | ||
| ------- | ||
| torch.Tensor | ||
| A complex64 tensor of shape [batch_size] representing the diagonal term of the Hamiltonian for the given configurations. | ||
| """ | ||
| self._prepare_data(configs.device) | ||
| _diagonal_term: typing.Callable[[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor], torch.Tensor] | ||
| _diagonal_term = getattr(self._load_module(configs.device.type, configs.size(1), self.particle_cut), "diagonal_term") | ||
| psi_result = torch.view_as_complex(_diagonal_term(configs, self.site, self.kind, self.coef)) | ||
| return psi_result | ||
| def single_relative(self, configs: torch.Tensor) -> torch.Tensor: | ||
@@ -170,0 +190,0 @@ """ |
+3
-0
@@ -115,2 +115,5 @@ """ | ||
| def diagonal_term(self, configs: torch.Tensor) -> torch.Tensor: | ||
| return self.hamiltonian.diagonal_term(configs) | ||
| def single_relative(self, configs: torch.Tensor) -> torch.Tensor: | ||
@@ -117,0 +120,0 @@ return self.hamiltonian.single_relative(configs) |
+3
-0
@@ -224,2 +224,5 @@ """ | ||
| def diagonal_term(self, configs: torch.Tensor) -> torch.Tensor: | ||
| return self.hamiltonian.diagonal_term(configs) | ||
| def single_relative(self, configs: torch.Tensor) -> torch.Tensor: | ||
@@ -226,0 +229,0 @@ return self.hamiltonian.single_relative(configs) |
+15
-0
@@ -176,2 +176,17 @@ """ | ||
| def diagonal_term(self, configs: torch.Tensor) -> torch.Tensor: | ||
| """ | ||
| Calculate the diagonal term for the given configurations. | ||
| Parameters | ||
| ---------- | ||
| configs : torch.Tensor | ||
| The configurations to calculate the diagonal term for. | ||
| Returns | ||
| ------- | ||
| torch.Tensor | ||
| The diagonal term of the configurations. | ||
| """ | ||
| def single_relative(self, configs: torch.Tensor) -> torch.Tensor: | ||
@@ -178,0 +193,0 @@ """ |
@@ -89,2 +89,5 @@ """ | ||
| def diagonal_term(self, configs: torch.Tensor) -> torch.Tensor: | ||
| return self.hamiltonian.diagonal_term(configs) | ||
| def single_relative(self, configs: torch.Tensor) -> torch.Tensor: | ||
@@ -91,0 +94,0 @@ return self.hamiltonian.single_relative(configs) |
+2
-2
@@ -1,4 +0,4 @@ | ||
| # An efficient Neural-Network Quantum States Architecture for Strongly Correlated Systems | ||
| # Hamiltonian-Guided Autoregressive Selected-Configuration Interaction(HAAR-SCI) Achieves Chemical Accuracy in Strongly Correlated Systems | ||
| The Quantum-Many-Body (`qmb`) is a powerful tool designed to solve quantum-many-body problems. | ||
| The current project temporarily named as Quantum-Many-Body (`qmb`) which is a powerful tool designed to solve quantum-many-body problems especially for strongly correlated systems. | ||
@@ -5,0 +5,0 @@ ## About The Project |
Sorry, the diff of this file is not supported yet
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
384583
3.18%60
1.69%4425
2.22%