qewton.optim package¶
Module contents¶
Optim Submodule¶
The optim module manages the training, optimization, and hyperparameter tuning of graph-based models. It bridges the gap between the static graph structure and the dynamic training process.
Key Components¶
Trainer: ManagesOptimizationPhases(which specify optimizers), callbacks (like progress bars or logging), and device placement.GraphBasedTrainer: The standard trainer that extracts constraints (losses/metrics) and parameters directly from the computation graphs.Tuner: A framework for hyperparameter optimization (HPO). It supports parallel trial execution across multiple devices and logs results to CSV by default. Subclasses could also use specific HPO libraries like Optuna or Ray Tune.HyperParameter: Represents tunable values in the graph (e.g., learning rates, layer widths) that are managed by theTuner.
Goals¶
Automated Training Pipelines: Simplify the process of moving from a graph definition to a trained model.
Scalable Tuning: Provide built-in support for running multiple trials in parallel using multiprocessing.
State Management: Robustly track training progress, metrics, and hyperparameter snapshots.
Phase-Based Optimization: Support complex training schedules where different parts of the model or different objectives are optimized in sequence.
Parallelism¶
The Tuner uses a worker-queue model to distribute training trials across available CPUs or GPUs, ensuring efficient utilization of hardware during hyperparameter searches.
See DECISIONS.md for design decisions.
Subpackages¶
- qewton.optim.parameters package
- Module contents
- Submodules
- qewton.optim.parameters.categorical_hyperparameter module
- qewton.optim.parameters.dag module
- qewton.optim.parameters.helpers module
- qewton.optim.parameters.hyperparameter_base module
HyperParameterHyperParameter.from_value()HyperParameter.is_fixedHyperParameter.size_from()HyperParameter.is_openHyperParameter.inferred()HyperParameter.infer()HyperParameter.valueHyperParameter.tuning_gridHyperParameter.is_active()HyperParameter.set_value()HyperParameter.sample_parameter_random()HyperParameter.sample_from_unit()HyperParameter.sample_parameter_grid()HyperParameter.dependencies
ArithmeticHyperParameterOperationHyperParameterOperation.dependenciesHyperParameterOperation.set_value()HyperParameterOperation.is_openHyperParameterOperation.valueHyperParameterOperation.sample_parameter_random()HyperParameterOperation.sample_from_config()HyperParameterOperation.sample_from_unit()HyperParameterOperation.sample_parameter_grid()HyperParameterOperation.tuning_grid
- qewton.optim.parameters.number_hyperparameter module
- qewton.optim.parameters.trainable_parameters module
- qewton.optim.trainer package
- Module contents
- Subpackages
- qewton.optim.trainer.callbacks package
- Module contents
- Submodules
- qewton.optim.trainer.callbacks.base_callback module
- qewton.optim.trainer.callbacks.log_callback module
- qewton.optim.trainer.callbacks.memory_callback module
- qewton.optim.trainer.callbacks.progressbar_callback module
- qewton.optim.trainer.callbacks.stoper_callback module
- qewton.optim.trainer.callbacks.training_callbacks module
- qewton.optim.trainer.callbacks package
- Submodules
- qewton.optim.trainer.base_trainer module
TrainerTrainer.set_trainable_parameters()Trainer.run()Trainer.on_training_start()Trainer.on_optimization_phases_start()Trainer.training_step()Trainer.on_training_step_end()Trainer.on_optimization_phases_end()Trainer.on_training_end()Trainer.set_hyperparameter()Trainer.set_device()Trainer.check_tuning_constraints_exist()Trainer.populate_state_dict()Trainer.cleanup()
- qewton.optim.trainer.function_trainer module
- qewton.optim.trainer.graph_trainer module
GraphBasedTrainerGraphBasedTrainer.graphsGraphBasedTrainer.all_nodesGraphBasedTrainer.training_objectivesGraphBasedTrainer.training_constraintsGraphBasedTrainer.validation_constraintsGraphBasedTrainer.train_graphsGraphBasedTrainer.validation_graphsGraphBasedTrainer.check_tuning_constraints_exist()GraphBasedTrainer.collect_graph_hyperparameters()GraphBasedTrainer.set_hyperparameter()GraphBasedTrainer.on_training_start()GraphBasedTrainer.populate_state_dict()
- qewton.optim.trainer.training_controllers module
LogEntryTrainerStateTrainerState.current_optimization_phaseTrainerState.iterationTrainerState.total_train_lossTrainerState.lossesTrainerState.historyTrainerState.callback_infoTrainerState.callback_objectivesTrainerState.stop_stageTrainerState.start_training_timer()TrainerState.stop_training_timer()TrainerState.stop_trainingTrainerState.detach_data()TrainerState.clear_data_dict()TrainerState.check_file_path()TrainerState.log_step()
OptimizationPhase
- qewton.optim.tuner package
Submodules¶
qewton.optim.base module¶
- class qewton.optim.base.EvaluationPhase(*values)[source]¶
Bases:
EnumA marker to distinguish between different behaviors in the training process.
- TRAIN
The behavior while training. May also mean that this quantity is only checked/evaluated when run in the training phase.
- TEST
The behavior while testing.
- VALIDATION
The behavior while validating.
- ALWAYS
Always evaluated independent of the current phase.
- NEVER
Never automatically used. Such nodes are only evaluated when called by the user themselves.
- TRAIN = 0¶
- TEST = 1¶
- VALIDATION = 2¶
- ALWAYS = 3¶
- NEVER = 4¶