From a086026b8dd136acdd3d035b288137d306d52975 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 18:56:22 +0000 Subject: [PATCH 1/3] Initial plan From bb8bcb79b6cf10ed2ea8a56e698fa34eee6cfc87 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 18:59:06 +0000 Subject: [PATCH 2/3] Rename subcommand_dict to action_dict and SubcommandProto to ActionProto Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com> --- qmp/__main__.py | 4 ++-- qmp/algorithms/chop_imag.py | 4 ++-- qmp/algorithms/guide.py | 4 ++-- qmp/algorithms/haar.py | 8 ++++---- qmp/algorithms/haar_with_orbit.py | 6 +++--- qmp/algorithms/orbit.py | 4 ++-- qmp/algorithms/pert.py | 4 ++-- qmp/algorithms/pretrain.py | 4 ++-- qmp/algorithms/vmc.py | 4 ++-- qmp/utility/subcommand_dict.py | 16 ++++++++-------- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/qmp/__main__.py b/qmp/__main__.py index 29d7913..ee64a78 100644 --- a/qmp/__main__.py +++ b/qmp/__main__.py @@ -9,7 +9,7 @@ import omegaconf from .utility.context import RuntimeContext, DACITE_CAST -from .utility.subcommand_dict import subcommand_dict +from .utility.action_dict import action_dict @hydra.main(version_base=None, config_path=str(pathlib.Path().resolve()), config_name="config") @@ -30,7 +30,7 @@ def main(runtime_config: omegaconf.DictConfig) -> None: # 2. Instantiate Algorithm run = dacite.from_dict( - data_class=subcommand_dict[runtime_config.action.name], # type: ignore[arg-type] + data_class=action_dict[runtime_config.action.name], # type: ignore[arg-type] data=omegaconf.OmegaConf.to_container(runtime_config.action.params, resolve=True), # type: ignore[arg-type] config=dacite.Config(cast=DACITE_CAST), ) diff --git a/qmp/algorithms/chop_imag.py b/qmp/algorithms/chop_imag.py index 6f807bb..5059e56 100644 --- a/qmp/algorithms/chop_imag.py +++ b/qmp/algorithms/chop_imag.py @@ -8,7 +8,7 @@ import omegaconf import torch.utils.tensorboard from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict @dataclasses.dataclass @@ -98,4 +98,4 @@ def main( context.save(data, 0) -subcommand_dict["chop_imag"] = ChopImagConfig +action_dict["chop_imag"] = ChopImagConfig diff --git a/qmp/algorithms/guide.py b/qmp/algorithms/guide.py index d8762bb..8610a00 100644 --- a/qmp/algorithms/guide.py +++ b/qmp/algorithms/guide.py @@ -9,7 +9,7 @@ import torch import torch.utils.tensorboard from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict @dataclasses.dataclass @@ -188,4 +188,4 @@ def distribution() -> torch.Tensor: logging.info("Current optimization cycle completed") -subcommand_dict["guide"] = GuideConfig +action_dict["guide"] = GuideConfig diff --git a/qmp/algorithms/haar.py b/qmp/algorithms/haar.py index fab0a63..31e7833 100644 --- a/qmp/algorithms/haar.py +++ b/qmp/algorithms/haar.py @@ -13,7 +13,7 @@ import torch.utils.tensorboard from ..utility import losses from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict from ..utility.model_dict import ModelProto from ..utility.optimizer import scale_learning_rate @@ -392,7 +392,7 @@ def main( ) if "haar" not in data and "imag" in data: - logging.warning("The 'imag' subcommand is deprecated, please use 'haar' instead.") + logging.warning("The 'imag' action is deprecated, please use 'haar' instead.") data["haar"] = data["imag"] del data["imag"] if "haar" not in data: @@ -587,5 +587,5 @@ def closure() -> torch.Tensor: logging.info("Current optimization cycle completed") -subcommand_dict["haar"] = HaarConfig -subcommand_dict["imag"] = HaarConfig +action_dict["haar"] = HaarConfig +action_dict["imag"] = HaarConfig diff --git a/qmp/algorithms/haar_with_orbit.py b/qmp/algorithms/haar_with_orbit.py index c0c8611..fb68d76 100644 --- a/qmp/algorithms/haar_with_orbit.py +++ b/qmp/algorithms/haar_with_orbit.py @@ -13,7 +13,7 @@ from scipy.optimize import linear_sum_assignment from ..utility import losses from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict from ..utility.model_dict import ModelProto from ..utility.optimizer import scale_learning_rate from ..hamiltonian import Hamiltonian @@ -211,7 +211,7 @@ def main( ) if "haar" not in data and "imag" in data: - logging.warning("The 'imag' subcommand is deprecated, please use 'haar' instead.") + logging.warning("The 'imag' action is deprecated, please use 'haar' instead.") data["haar"] = data["imag"] del data["imag"] if "haar" not in data: @@ -412,4 +412,4 @@ def closure() -> torch.Tensor: logging.info("Checkpoint successfully saved") -subcommand_dict["haar_with_orbit"] = HaarWithOrbitConfig +action_dict["haar_with_orbit"] = HaarWithOrbitConfig diff --git a/qmp/algorithms/orbit.py b/qmp/algorithms/orbit.py index 61ddcf7..dddeb12 100644 --- a/qmp/algorithms/orbit.py +++ b/qmp/algorithms/orbit.py @@ -12,7 +12,7 @@ import omegaconf from ..hamiltonian import Hamiltonian from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict @dataclasses.dataclass @@ -202,4 +202,4 @@ def calculate_rdm(self, configs: torch.Tensor, psi: torch.Tensor) -> torch.Tenso return rdm -subcommand_dict["orbit"] = OrbitConfig +action_dict["orbit"] = OrbitConfig diff --git a/qmp/algorithms/pert.py b/qmp/algorithms/pert.py index e93e0e1..a48c04a 100644 --- a/qmp/algorithms/pert.py +++ b/qmp/algorithms/pert.py @@ -7,7 +7,7 @@ import dataclasses import omegaconf from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict @dataclasses.dataclass @@ -64,4 +64,4 @@ def main( logging.info("Error is reduced from %.8f to %.8f", energy0 - model.ref_energy, energy2 - model.ref_energy) -subcommand_dict["pert"] = PerturbationConfig +action_dict["pert"] = PerturbationConfig diff --git a/qmp/algorithms/pretrain.py b/qmp/algorithms/pretrain.py index 864ec30..8e099e0 100644 --- a/qmp/algorithms/pretrain.py +++ b/qmp/algorithms/pretrain.py @@ -9,7 +9,7 @@ import torch from ..utility import losses from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict @dataclasses.dataclass @@ -74,4 +74,4 @@ def closure() -> torch.Tensor: logging.info("Current optimization cycle completed") -subcommand_dict["pretrain"] = PretrainConfig +action_dict["pretrain"] = PretrainConfig diff --git a/qmp/algorithms/vmc.py b/qmp/algorithms/vmc.py index 1c19c83..89b5eba 100644 --- a/qmp/algorithms/vmc.py +++ b/qmp/algorithms/vmc.py @@ -9,7 +9,7 @@ import torch import torch.utils.tensorboard from ..utility.context import RuntimeContext -from ..utility.subcommand_dict import subcommand_dict +from ..utility.action_dict import action_dict @dataclasses.dataclass @@ -117,4 +117,4 @@ def closure() -> torch.Tensor: logging.info("Current optimization cycle completed") -subcommand_dict["vmc"] = VmcConfig +action_dict["vmc"] = VmcConfig diff --git a/qmp/utility/subcommand_dict.py b/qmp/utility/subcommand_dict.py index 7a7c72d..86e5146 100644 --- a/qmp/utility/subcommand_dict.py +++ b/qmp/utility/subcommand_dict.py @@ -1,10 +1,10 @@ """ -This module is used to store a dictionary that maps subcommand names to their corresponding dataclass types. +This module is used to store a dictionary that maps action names to their corresponding dataclass types. -Other packages or subpackages can register their subcommands by adding entries to this dictionary, such as +Other packages or subpackages can register their actions by adding entries to this dictionary, such as ``` -from qmp.utility.subcommand_dict import subcommand_dict -subcommand_dict["my_subcommand"] = MySubcommand +from qmp.utility.action_dict import action_dict +action_dict["my_action"] = MyAction ``` """ @@ -13,9 +13,9 @@ from .context import RuntimeContext -class SubcommandProto(typing.Protocol): +class ActionProto(typing.Protocol): """ - This protocol defines a dataclass with a `main` method, which will be called when the subcommand is executed. + This protocol defines a dataclass with a `main` method, which will be called when the action is executed. """ def main( @@ -25,8 +25,8 @@ def main( checkpoint_data: dict[str, typing.Any], ) -> None: """ - The main method to be called when the subcommand is executed. + The main method to be called when the action is executed. """ -subcommand_dict: dict[str, type[SubcommandProto]] = {} +action_dict: dict[str, type[ActionProto]] = {} From 5e8bf44e8e3c82e2239a810044c9228b85dccf16 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Fri, 6 Mar 2026 03:14:51 +0800 Subject: [PATCH 3/3] Rename the file. --- qmp/utility/{subcommand_dict.py => action_dict.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename qmp/utility/{subcommand_dict.py => action_dict.py} (100%) diff --git a/qmp/utility/subcommand_dict.py b/qmp/utility/action_dict.py similarity index 100% rename from qmp/utility/subcommand_dict.py rename to qmp/utility/action_dict.py