General
Taming ML Configuration Complexity with Hydra in Kled.io
Emma Wilson
January 25, 2025 (2mo ago)
<h2>Introduction</h2>
<p>Machine learning project configurations can quickly spiral into unmanageable complexity. As models grow more sophisticated, the number of hyperparameters, data preprocessing settings, and environmental variables multiplies. Tracking, versioning, and reproducing these configurations becomes a significant challenge for ML teams.</p>
<p>In the Kled.io platform, we've integrated Hydra—a powerful configuration framework from Facebook Research—to tame this complexity and provide a streamlined approach to configuration management. This article explores how Hydra integration in Kled.io helps ML teams manage configurations more effectively, improving experiment reproducibility and team collaboration.</p>
<h2>The Configuration Challenge in ML</h2>
<p>Machine learning workflows face several configuration-related challenges:</p>
<ul>
<li><strong>Parameter explosion</strong>: Modern models can have hundreds of hyperparameters</li>
<li><strong>Environment variability</strong>: Configurations differ across development, testing, and production</li>
<li><strong>Experiment tracking</strong>: Associating results with specific configuration settings</li>
<li><strong>Collaboration friction</strong>: Sharing and merging configuration changes across team members</li>
<li><strong>Configuration inheritance</strong>: Managing shared settings across multiple model variants</li>
</ul>
<p>Traditional approaches like hardcoded parameters, simple config files, or command-line arguments quickly become unwieldy as projects scale. These methods often lead to configuration duplication, difficult-to-reproduce experiments, and cumbersome workflows.</p>
<h2>What is Hydra?</h2>
<p>Hydra is an open-source Python framework developed by Facebook Research that provides a more elegant solution to configuration management. Its key features include:</p>
<ul>
<li><strong>Hierarchical configuration</strong>: Compose config files from multiple sources</li>
<li><strong>Command-line overrides</strong>: Override config values directly from the command line</li>
<li><strong>Config groups</strong>: Manage families of related configurations</li>
<li><strong>Dynamic command-line tab completion</strong>: Auto-complete available config options</li>
<li><strong>Run output management</strong>: Automatically track outputs of different runs</li>
</ul>
<p>Hydra uses YAML as its configuration format and provides a clean API for accessing configuration values in code.</p>
<h2>Hydra Integration in Kled.io</h2>
<p>Kled.io's Hydra integration is specifically tailored for ML workflows:</p>
<h3>1. Centralized Configuration Management</h3>
<p>Kled.io provides a unified interface for managing Hydra configurations:</p>
<p><img src="https://images.unsplash.com/photo-1555949963-aa79dcee981c?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" alt="Hydra Configuration Interface"></p>
<h3>2. Config Structure Templates</h3>
<p>We provide predefined templates for common ML configuration patterns:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># Base configuration (config.yaml)</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">defaults</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">model</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> transformer</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">dataset</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> text_classification</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">optimizer</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> adam</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">scheduler</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> cosine</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">_self_</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">training</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> epochs</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 10</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> batch_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 32</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> gradient_accumulation_steps</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 1</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> mixed_precision</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "fp16"</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> seed</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 42</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">evaluation</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> eval_batch_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 64</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> eval_steps</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 500</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">logging</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> log_level</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> INFO</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> wandb</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> enabled</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> true</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> project</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> ${dataset.name}</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> tags</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> [</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5">$</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">{</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5">model.type</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">}</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">,</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> $</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">{</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5">dataset.name</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">}]</span></span></code></pre></figure>
<h3>3. Environment-Specific Overrides</h3>
<p>Easily manage configurations across environments:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># configs/environment/dev.yaml</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">training</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> epochs</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 2</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> batch_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 4</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">evaluation</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> eval_steps</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 20</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">logging</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> wandb</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> enabled</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> false</span></span></code></pre></figure>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># configs/environment/prod.yaml</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">training</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> epochs</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 20</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> gradient_accumulation_steps</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 4</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">evaluation</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> eval_steps</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 1000</span></span></code></pre></figure>
<h3>4. Experiment Tracking Integration</h3>
<p>Hydra configurations are automatically tracked with experiment metrics:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="python" data-theme="min-light min-dark"><code data-language="python" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">@hydra</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">main</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(config_path</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"configs"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">, config_name</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"config"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">)</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> train</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">(</span><span style="--shiki-light:#FF9800;--shiki-dark:#FF9800">cfg</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">:</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> DictConfig):</span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Initialize experiment tracking</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> kled</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">init_experiment</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(cfg)</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Access nested config values</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> model </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> build_model</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(</span></span>
<span data-line=""><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB"> model_type</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">cfg.model.type,</span></span>
<span data-line=""><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB"> num_layers</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">cfg.model.num_layers,</span></span>
<span data-line=""><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB"> hidden_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">cfg.model.hidden_size</span></span>
<span data-line=""><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB"> )</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Training loop with tracked config</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> for</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> epoch </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">in</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> range</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(cfg.training.epochs):</span></span>
<span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> train_epoch</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(model, cfg)</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> eval_metrics </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> evaluate</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(model, cfg)</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Metrics automatically associated with this config</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> kled</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">log_metrics</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(eval_metrics)</span></span></code></pre></figure>
<h2>Real-World Example: NLP Model Development</h2>
<p>Let's explore a practical example of using Hydra in Kled.io for a complex NLP model development workflow:</p>
<h3>1. Base Configuration Structure</h3>
<p>The team starts with a well-organized configuration hierarchy:</p>
<pre><code>configs/
├── config.yaml # Main config with defaults
├── dataset/
│ ├── text_classification.yaml
│ ├── sentiment_analysis.yaml
│ └── named_entity_recognition.yaml
├── model/
│ ├── transformer.yaml
│ ├── lstm.yaml
│ └── cnn.yaml
├── optimizer/
│ ├── adam.yaml
│ ├── sgd.yaml
│ └── adafactor.yaml
└── scheduler/
├── linear.yaml
├── cosine.yaml
└── constant.yaml
</code></pre>
<h3>2. Task-Specific Configuration</h3>
<p>A team member working on sentiment analysis creates a specialized config:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># configs/task/sentiment_amazon_reviews.yaml</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">defaults</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">model</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> transformer</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">dataset</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> sentiment_analysis</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">optimizer</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> adam</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">scheduler</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> linear</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">_self_</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># Override base transformer settings</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">model</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> num_layers</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 4</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> hidden_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 512</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> dropout</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 0.2</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">dataset</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> name</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "amazon_reviews"</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> max_seq_length</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 256</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> preprocessing</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> lowercase</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> true</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> remove_punctuation</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> false</span></span></code></pre></figure>
<h3>3. Experiment Variants</h3>
<p>The data scientist runs experiments with different configurations:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="bash" data-theme="min-light min-dark"><code data-language="bash" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># Base experiment</span></span>
<span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">python</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> train.py</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> task=sentiment_amazon_reviews</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># Override batch size and learning rate</span></span>
<span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">python</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> train.py</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> task=sentiment_amazon_reviews</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> training.batch_size=</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">64</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> optimizer.lr=2e-5</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># Use a different model architecture</span></span>
<span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">python</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> train.py</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> task=sentiment_amazon_reviews</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> model=lstm</span></span></code></pre></figure>
<p>Kled.io tracks each experiment variant and its results, with automatic versioning of configurations and outputs.</p>
<h3>4. Environment Switching</h3>
<p>For deployment, the team applies production overrides:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="bash" data-theme="min-light min-dark"><code data-language="bash" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">python</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> deploy.py</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> task=sentiment_amazon_reviews</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> environment=prod</span></span></code></pre></figure>
<p>The configuration automatically adjusts for the production environment (larger batch sizes, more training epochs, etc.)</p>
<h2>Benefits Realized</h2>
<p>ML teams using Hydra in Kled.io have experienced several key benefits:</p>
<ol>
<li><strong>Reduced configuration errors</strong>: Structured configs catch mistakes before runtime</li>
<li><strong>Improved experiment reproducibility</strong>: Every experiment has a complete configuration record</li>
<li><strong>Faster experimentation cycles</strong>: Easy parameter overriding enables rapid iteration</li>
<li><strong>Better team collaboration</strong>: Shared configuration structure with individual overrides</li>
<li><strong>Cleaner codebase</strong>: Separation of configuration from code logic</li>
</ol>
<h2>Best Practices for ML Configuration with Hydra</h2>
<p>Based on our experience, we recommend these best practices:</p>
<h3>1. Design a Thoughtful Configuration Hierarchy</h3>
<p>Organize configurations by logical groups:</p>
<pre><code>configs/
├── config.yaml # Main configuration
├── dataset/ # Dataset configs
├── model/ # Model architecture configs
├── training/ # Training process configs
├── environment/ # Environment-specific overrides
└── experiment/ # Specific experiment configurations
</code></pre>
<h3>2. Use Interpolation for Derived Values</h3>
<p>Leverage Hydra's variable interpolation to avoid redundancy:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">dataset</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> name</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "imagenet"</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> train_path</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "${paths.data_dir}/${dataset.name}/train"</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> val_path</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "${paths.data_dir}/${dataset.name}/val"</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">paths</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Base paths can be overridden per environment</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> data_dir</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "/data/datasets"</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> output_dir</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> "/outputs/${dataset.name}/${model.name}"</span></span></code></pre></figure>
<h3>3. Implement Validation for Configuration Values</h3>
<p>Add runtime validation to catch configuration errors early:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="python" data-theme="min-light min-dark"><code data-language="python" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">@hydra</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">main</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(config_path</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"configs"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">, config_name</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"config"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">)</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> train</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">(</span><span style="--shiki-light:#FF9800;--shiki-dark:#FF9800">cfg</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">:</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> DictConfig):</span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Validate configuration</span></span>
<span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> validate_config</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(cfg)</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # ...rest of training code</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> validate_config</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">(</span><span style="--shiki-light:#FF9800;--shiki-dark:#FF9800">cfg</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">:</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> DictConfig):</span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> """Validate configuration values."""</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> cfg</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">training</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">batch_size </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"><=</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 0</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> raise</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> ValueError</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">f</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"Batch size must be positive, got </span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">{</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">cfg.training.batch_size</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">}</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">)</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> cfg</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">model</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">num_layers </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"><=</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 0</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> raise</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> ValueError</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">f</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"Number of layers must be positive, got </span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">{</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">cfg.model.num_layers</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">}</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">)</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> </span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"> # Validate dataset existence</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> not</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> os</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">path</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">exists</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(cfg.dataset.train_path):</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> raise</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> FileNotFoundError</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">(</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">f</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"Training data not found at </span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">{</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">cfg.dataset.train_path</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8">}</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">"</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">)</span></span></code></pre></figure>
<h3>4. Leverage Sweepers for Hyperparameter Optimization</h3>
<p>Use Hydra's built-in sweeping capabilities for parameter searches:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># sweeper.yaml</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">defaults</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">override hydra/sweeper</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> optuna</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">override hydra/sweeper/sampler</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> tpe</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">hydra</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> sweeper</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> sampler</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> seed</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 123</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> direction</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> minimize</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> study_name</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> learning_rate_study</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> storage</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF"> null</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> n_trials</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 20</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> n_jobs</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 1</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> params</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> optimizer.lr</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> range(1e-5, 1e-2, log=true)</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> model.dropout</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> range(0.1, 0.5)</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> training.batch_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> choice(16, 32, 64)</span></span></code></pre></figure>
<p>This can be launched with:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="bash" data-theme="min-light min-dark"><code data-language="bash" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">python</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> train.py</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> --config-name=sweeper.yaml</span></span></code></pre></figure>
<h3>5. Create Specialized Config Composites</h3>
<p>For common experiment types, create composite configurations:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="yaml" data-theme="min-light min-dark"><code data-language="yaml" data-theme="min-light min-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># configs/experiment/sentiment_small.yaml</span></span>
<span data-line=""><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C"># Configuration for quick sentiment analysis experiments</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">defaults</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">model</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> transformer</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">dataset</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> sentiment_analysis</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">optimizer</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> adam</span></span>
<span data-line=""><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">_self_</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">model</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> num_layers</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 2</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> hidden_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 128</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8">training</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> epochs</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 1</span></span>
<span data-line=""><span style="--shiki-light:#D32F2F;--shiki-dark:#F8F8F8"> batch_size</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">:</span><span style="--shiki-light:#1976D2;--shiki-dark:#F8F8F8"> 16</span></span></code></pre></figure>
<h2>Ethical Considerations</h2>
<p>Configuration management has important ethical dimensions:</p>
<ul>
<li><strong>Reproducibility</strong>: Proper configuration management is essential for scientific integrity</li>
<li><strong>Knowledge sharing</strong>: Configurations should be accessible and understandable by all team members</li>
<li><strong>Resource efficiency</strong>: Well-managed configurations help avoid wasteful compute usage</li>
<li><strong>Bias documentation</strong>: Configurations should document potential sources of bias in data processing</li>
</ul>
<h2>Conclusion</h2>
<p>Hydra integration in Kled.io provides ML teams with a powerful solution to the challenge of configuration management. By creating a structured, hierarchical approach to configuration, teams can improve experiment reproducibility, accelerate iteration cycles, and enhance collaboration.</p>
<p>Future enhancements to our Hydra integration will include:</p>
<ul>
<li>Visual configuration builders with validation</li>
<li>Configuration version control and diffing</li>
<li>Parameter importance analysis</li>
<li>Automated configuration optimization based on prior experiments</li>
</ul>
<p>As machine learning projects continue to grow in complexity, robust configuration management becomes increasingly important. Hydra's approach, enhanced by Kled.io's specialized integration, offers a powerful solution for modern ML teams.</p>
<blockquote>
<p>"Configuration may seem mundane, but it's the foundation of reproducible science and reliable ML systems."</p>
</blockquote>
<p>For more information on Hydra integration in Kled.io, visit our <a href="https://kled.io/docs/configurations/hydra">configuration documentation</a>.</p>