qxmt.experiment.executor module#
- class qxmt.experiment.executor.QKernelExecutor(experiment)
Bases:
RunExecutorBase
Executor for QKernel models (classification / regression).
This class handles the execution of quantum kernel-based machine learning models, including both classification and regression tasks.
- Parameters:
experiment (Experiment)
- run_from_config(*, config, commit_id, run_dirc, n_jobs, show_progress, repo_path, add_results=True)
Run a QKernel model using configuration settings.
- Parameters:
config (ExperimentConfig) – Configuration settings for the experiment.
commit_id (str) – Git commit ID for the current run.
run_dirc (Path) – Directory to store run artifacts.
n_jobs (int) – Number of parallel jobs to run.
show_progress (bool) – Whether to display progress bars.
repo_path (Optional[str]) – Path to the repository.
add_results (bool, optional) – Whether to save results. Defaults to True.
- Returns:
Tuple containing the run artifact and record.
- Return type:
tuple[RunArtifact, RunRecord]
Note
This method builds the dataset and model from the configuration before executing the run.
- run_from_instance(*, task_type, dataset, model, save_shots_path, save_model_path, default_metrics_name, custom_metrics, desc, commit_id, config_file_name, repo_path, add_results=True)
Run a QKernel model using pre-built instances.
This method executes the model training, validation, and testing phases, and records the results.
- Parameters:
task_type (Optional[str]) – Type of the task (classification/regression).
dataset (Dataset) – Dataset to use for training and evaluation.
model (BaseMLModel) – Pre-built model instance.
save_shots_path (Optional[Path]) – Path to save shot results.
save_model_path (Path) – Path to save the trained model.
default_metrics_name (Optional[list[str]]) – List of default metrics to use.
custom_metrics (Optional[list[dict[str, Any]]]) – List of custom metrics.
desc (str) – Description of the run.
commit_id (str) – Git commit ID.
config_file_name (Path) – Name of the configuration file.
repo_path (Optional[str]) – Path to the repository.
add_results (bool, optional) – Whether to save results. Defaults to True.
- Returns:
Tuple containing the run artifact and record.
- Return type:
tuple[RunArtifact, RunRecord]
- class qxmt.experiment.executor.RunExecutorBase(experiment)
Bases:
ABC
Abstract base class for experiment run executors.
This class provides common functionality and attributes for concrete executor implementations. It serves as a base class for both QKernel and VQE executors.
- Parameters:
experiment (Experiment)
- exp
Reference to the experiment instance.
- Type:
Experiment
- logger
Logger instance for logging operations.
- eval_factory
Factory for creating evaluation instances.
- Type:
EvaluationFactory
- __init__(experiment)
Initialize the base executor.
- Parameters:
experiment (Experiment) – The experiment instance to use for execution.
- Return type:
None
- abstractmethod run_from_config(*args, **kwargs)
Run a model using configuration settings.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
tuple[RunArtifact, RunRecord]
- abstractmethod run_from_instance(*args, **kwargs)
Run a model using a pre-built instance.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
tuple[RunArtifact, RunRecord]
- class qxmt.experiment.executor.VQEExecutor(experiment)
Bases:
RunExecutorBase
Executor for Variational Quantum Eigensolver models.
This class handles the execution of VQE models, which are used for finding the ground state energy of quantum systems.
- Parameters:
experiment (Experiment)
- run_from_config(*, config, commit_id, run_dirc, n_jobs, show_progress, repo_path, add_results=True)
Run a VQE model using configuration settings.
- Parameters:
config (ExperimentConfig) – Configuration settings for the experiment.
commit_id (str) – Git commit ID for the current run.
run_dirc (Path) – Directory to store run artifacts.
n_jobs (int) – Number of parallel jobs to run.
show_progress (bool) – Whether to display progress bars.
repo_path (Optional[str]) – Path to the repository.
add_results (bool, optional) – Whether to save results. Defaults to True.
- Returns:
Tuple containing the run artifact and record.
- Return type:
tuple[RunArtifact, RunRecord]
- run_from_instance(*, model, save_shots_path, default_metrics_name, custom_metrics, desc, commit_id, config_file_name, repo_path, add_results=True)
Run a VQE model using a pre-built instance.
This method executes the VQE optimization process and records the results.
- Parameters:
model (BaseVQE) – Pre-built VQE model instance.
save_shots_path (Optional[Path]) – Path to save shot results.
default_metrics_name (Optional[list[str]]) – List of default metrics to use.
custom_metrics (Optional[list[dict[str, Any]]]) – List of custom metrics.
desc (str) – Description of the run.
commit_id (str) – Git commit ID.
config_file_name (Path) – Name of the configuration file.
repo_path (Optional[str]) – Path to the repository.
add_results (bool, optional) – Whether to save results. Defaults to True.
- Returns:
Tuple containing the run artifact and record.
- Return type:
tuple[RunArtifact, RunRecord]
- Raises:
NotImplementedError – If remote machine execution is attempted.