qdk_chemistry.plugins package

Plugin registration and discovery for QDK/Chemistry extensions.

Plugins connect QDK/Chemistry to optional chemistry packages, quantum software, and execution services while preserving the library’s common interfaces. An extension can contribute:

  • implementations of existing algorithm types or entirely new algorithm types;

  • data classes used by algorithm inputs and outputs;

  • remote execution backends; and

  • cache backends.

External plugins

An installed package exposes a QdkChemistryPlugin subclass through the qdk_chemistry.plugins entry-point group:

[project.entry-points."qdk_chemistry.plugins"]
custom = "custom_package.plugin:CustomPlugin"

Importing qdk_chemistry discovers each entry point and calls its QdkChemistryPlugin.register() method with a PluginRegistrar. The registrar provides access to the standard QDK/Chemistry registries without requiring application code to import the plugin package directly.

from qdk_chemistry.plugins import PluginRegistrar, QdkChemistryPlugin

class CustomPlugin(QdkChemistryPlugin):
     def register(self, registrar: PluginRegistrar) -> None:
          registrar.register_algorithm(lambda: CustomAlgorithm())
          registrar.register_remote_backend("custom", CustomRemoteBackend)

Bundled integrations

QDK/Chemistry also includes integrations for:

Bundled integrations are loaded automatically when their optional dependencies are available. Their implementations can then be created through the standard algorithm registry, for example create("scf_solver", "pyscf").

qdk_chemistry.plugins.ChemistryPlugin

alias of QdkChemistryPlugin

exception qdk_chemistry.plugins.DuplicateRegistrationError

Bases: ValueError

class qdk_chemistry.plugins.PluginRegistrar

Bases: object

Register plugin capabilities through the existing public registries.

register_algorithm_factory(factory)

Register a factory that introduces an algorithm type.

Parameters:

factory (AlgorithmFactory) – Factory that defines and creates the algorithm type.

Raises:

DuplicateRegistrationError – If the algorithm type is already registered.

Return type:

None

register_algorithm(factory, *, data_classes=())

Register an algorithm factory and its DataClass input or output types.

Parameters:
  • factory (Callable[[], Any]) – Factory that creates the algorithm implementation.

  • data_classes (Iterable[Type[Any]]) – DataClass loaders used by the algorithm’s inputs or outputs.

Raises:
Return type:

None

register_dataclass(dataclass_type)

Register a DataClass loader used in algorithm inputs or outputs.

Parameters:

dataclass_type (Type[Any]) – Canonical DataClass loader to register.

Raises:

DuplicateRegistrationError – If the DataClass wire type is already registered.

Return type:

None

register_remote_backend(name, backend_type)

Register a remote execution backend.

Backends may expose selected constructor parameters to untrusted MCP clients by declaring mcp_safe_config_options as a frozenset on the concrete class. The declaration is validated during registration; an omitted declaration exposes no parameters.

Parameters:
  • name (str) – Registry name for the backend.

  • backend_type (Type[Any]) – Backend class to register.

Raises:

DuplicateRegistrationError – If the backend name or class is already registered.

Return type:

None

register_cache_backend(name, backend_type)

Register a cache backend.

Parameters:
  • name (str) – Registry name for the cache backend.

  • backend_type (Type[Any]) – Cache backend class to register.

Raises:

DuplicateRegistrationError – If the cache name or class is already registered.

Return type:

None

class qdk_chemistry.plugins.QdkChemistryPlugin

Bases: ABC

Base class for plugins discovered through qdk_chemistry.plugins.

api_version = 1
abstractmethod register(registrar)

Register the capabilities provided by this plugin.

Return type:

None

Parameters:

registrar (PluginRegistrar)

Subpackages

Submodules