ファインチューニング・トレーニング・データ

Hydra: Managing Training Configurations, Parameter Combinations, and Experiment Runs

hydra-ecosystem/hydra

A configuration framework for Python applications that manages experiments through configuration composition, command-line overrides, and multirun execution. It is suitable for organizing data, model, and training parameters into reusable configuration structures.

★ 10.6Kスター
⑂ 977フォーク数
155未解決の問題
Python言語
MITライセンス
Q92編集部スコア

概要

When a machine learning project includes multiple datasets, models, and training approaches, copying scripts or manually modifying constants makes experiments increasingly difficult to track. Hydra organizes these choices into composable configurations: common settings go into a base configuration, while changing components such as data, models, and optimizers go into independent configuration groups, after which specific combinations can be selected through the command line. The project is currently maintained by the hydra-ecosystem organization, and the former facebookresearch/hydra address redirects to the current repository. It primarily addresses application configuration and run organization. It is suitable for integrating with existing Python programs so that the same code can be executed repeatedly with explicit parameters.

主な機能

  • Combine base configurations and configuration groups to manage different dimensions such as data, models, and runtime environments.
  • Override parameters through the command line, reducing the need to copy scripts for each experiment.
  • Use multirun to scan parameter combinations and generate organized experiment runs.
  • Combine structured configurations to check fields and types, helping identify configuration errors.
  • Save run configurations and output locations to facilitate reviewing the settings used for a particular experiment.
  • Extend parameter search and task-launch methods through sweeper and launcher plugins.

要件、インストール、クイックスタート

Run pip install hydra-core --upgrade in the project's Python environment, and first follow the stable-version introductory documentation to create a minimal configuration application. Place configurations in a clearly defined directory, then have the entry function receive the configuration object.

Migrate data paths, batch sizes, and model selections from an existing script into the configuration one by one. First verify that a single run reads the correct parameters, then add configuration groups and multirun execution. Pin the versions actually used in the dependency file, and ensure the team documentation corresponds to those versions.

使用方法

Practical example: compare two model configurations and three learning rates.

1. Put common training settings in the base configuration, and place the model architectures separately in the model configuration group.
2. Keep one default combination, run it once, and check the parsed configuration, input path, and output directory.
3. Override an individual parameter through the command line and confirm that the program actually reads the new value.
4. Organize the combinations of two models and three learning rates according to the multirun documentation, producing six experiments in total.
5. Save the configuration, random seed, evaluation metrics, and output model location for each run.
6. When summarizing, compare results using the same data split and evaluation method, then decide whether to expand the parameter range.

The default multirun launch executes locally and serially; when parallel execution or cluster scheduling is needed, select the corresponding launcher. This allows configuration correctness and task resource scheduling to be handled separately at first.

How it works
The application entry point declares the configuration location. Hydra reads the default configuration and configuration groups, merges command-line overrides, and forms the final configuration object. A single run passes this object to the program; a multirun uses the sweeper to generate parameter combinations and then passes them to the launcher for execution. Configuration organization, combination generation, and execution methods can therefore be extended separately.

Who it is for
Machine learning engineers and research teams that need to manage experiment parameters, as well as Python application developers working with multiple runtime environments and optional components.

Environment and inputs
A Python environment compatible with the selected Hydra version. The application's data, training framework, and computing resources are configured independently; when using additional plugins, check their dependencies and launch requirements.

Practical use cases
• Training experiments: combine model, optimizer, and dataset configurations.
• Data processing: have the same processing program read different input paths and transformation rules.
• Service configuration: reuse base configurations across development, testing, and deployment environments while overriding differing items.

Implementation notes
Multidimensional parameter scans can quickly increase the number of runs, so calculate the number of combinations before launching. File paths, working directories, and output directories should be clearly agreed upon. Handle sensitive information through dedicated environment configuration, avoiding its inclusion in experiment records that can be publicly shared.

Common questions
Q: Are more configuration files always better?
Divide configurations according to stable dimensions of variation, such as data and models; small parameters that occur only once can initially remain in the base configuration.

Q: Does multirun automatically run in parallel?
The default launch method is local and serial; other execution methods are configured through the corresponding launcher.

Related projects and workflow ideas
Lightning-AI/pytorch-lightning: Hydra can manage training parameters, while Lightning organizes the training loop; the two can be connected in the application entry point.

hpcaitech/ColossalAI: Suitable for managing parallelism and model configurations in large-scale training experiments; computation and communication are still handled by the training framework.

モデルの互換性とユースケース

Hydra is not tied to any model architecture and does not perform training computations. It can pass configurations to PyTorch, other training frameworks, or ordinary Python functions; the specific fields are defined by the application.

ライセンスとリスクに関する注意事項

Hydra is licensed under the MIT License. The current official repository is hydra-ecosystem/hydra; migration notes and historical content can be viewed through the repository and official website.

Langfuse

langfuse/langfuse

★ 32.4KTypeScript

DeepSpeed

deepspeedai/deepspeed

★ 43KPython

aikit

kaito-project/aikit

★ 535Go

keras

keras-team/keras

★ 64.3KPython