Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"RapidFire AI Integration","local":"rapidfire-ai-integration","sections":[{"title":"Why use RapidFire AI with TRL?","local":"why-use-rapidfire-ai-with-trl","sections":[{"title":"How It Works","local":"how-it-works","sections":[],"depth":3}],"depth":2},{"title":"Key Features","local":"key-features","sections":[],"depth":2},{"title":"Installation","local":"installation","sections":[{"title":"Prerequisites","local":"prerequisites","sections":[],"depth":3},{"title":"pip install","local":"pip-install","sections":[],"depth":3}],"depth":2},{"title":"Quick Start: SFT Training with Multiple Configs","local":"quick-start-sft-training-with-multiple-configs","sections":[{"title":"What Happens During Execution","local":"what-happens-during-execution","sections":[],"depth":3}],"depth":2},{"title":"Supported TRL Trainers","local":"supported-trl-trainers","sections":[{"title":"SFTTrainer","local":"sfttrainer","sections":[],"depth":3},{"title":"DPOTrainer","local":"dpotrainer","sections":[],"depth":3},{"title":"GRPOTrainer","local":"grpotrainer","sections":[],"depth":3}],"depth":2},{"title":"Core Concepts","local":"core-concepts","sections":[{"title":"Chunk-Based Concurrent Training","local":"chunk-based-concurrent-training","sections":[],"depth":3},{"title":"Interactive Control Operations (IC Ops)","local":"interactive-control-operations-ic-ops","sections":[],"depth":3},{"title":"Multi-Config Experimentation","local":"multi-config-experimentation","sections":[],"depth":3}],"depth":2},{"title":"Advanced Features","local":"advanced-features","sections":[{"title":"PEFT/LoRA Integration","local":"peftlora-integration","sections":[],"depth":3},{"title":"Custom Reward Functions (GRPO)","local":"custom-reward-functions-grpo","sections":[],"depth":3},{"title":"Multi-GPU Support","local":"multi-gpu-support","sections":[],"depth":3},{"title":"Multi-GPU Training with FSDP","local":"multi-gpu-training-with-fsdp","sections":[],"depth":3},{"title":"Experiment Tracking Backends","local":"experiment-tracking-backends","sections":[],"depth":3},{"title":"Running in Google Colab","local":"running-in-google-colab","sections":[],"depth":3}],"depth":2},{"title":"Best Practices","local":"best-practices","sections":[{"title":"Tuning Chunk Granularity","local":"tuning-chunk-granularity","sections":[],"depth":3},{"title":"Memory Management","local":"memory-management","sections":[],"depth":3}],"depth":2},{"title":"Performance Benchmarks","local":"performance-benchmarks","sections":[],"depth":2},{"title":"Troubleshooting","local":"troubleshooting","sections":[],"depth":2},{"title":"Additional Resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/trl/pr_5622/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/entry/start.05d1d9bd.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/scheduler.7b731bd4.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/singletons.a7e173c6.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/index.ac28c20f.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/paths.8a79b63c.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/entry/app.a8009617.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/preload-helper.1bba5ac2.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/index.cc268345.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/nodes/0.cd70a2c9.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/nodes/47.ce3e2584.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.2484815d.js"> | |
| <link rel="modulepreload" href="/docs/trl/pr_5622/en/_app/immutable/chunks/CodeBlock.5bbfa459.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"RapidFire AI Integration","local":"rapidfire-ai-integration","sections":[{"title":"Why use RapidFire AI with TRL?","local":"why-use-rapidfire-ai-with-trl","sections":[{"title":"How It Works","local":"how-it-works","sections":[],"depth":3}],"depth":2},{"title":"Key Features","local":"key-features","sections":[],"depth":2},{"title":"Installation","local":"installation","sections":[{"title":"Prerequisites","local":"prerequisites","sections":[],"depth":3},{"title":"pip install","local":"pip-install","sections":[],"depth":3}],"depth":2},{"title":"Quick Start: SFT Training with Multiple Configs","local":"quick-start-sft-training-with-multiple-configs","sections":[{"title":"What Happens During Execution","local":"what-happens-during-execution","sections":[],"depth":3}],"depth":2},{"title":"Supported TRL Trainers","local":"supported-trl-trainers","sections":[{"title":"SFTTrainer","local":"sfttrainer","sections":[],"depth":3},{"title":"DPOTrainer","local":"dpotrainer","sections":[],"depth":3},{"title":"GRPOTrainer","local":"grpotrainer","sections":[],"depth":3}],"depth":2},{"title":"Core Concepts","local":"core-concepts","sections":[{"title":"Chunk-Based Concurrent Training","local":"chunk-based-concurrent-training","sections":[],"depth":3},{"title":"Interactive Control Operations (IC Ops)","local":"interactive-control-operations-ic-ops","sections":[],"depth":3},{"title":"Multi-Config Experimentation","local":"multi-config-experimentation","sections":[],"depth":3}],"depth":2},{"title":"Advanced Features","local":"advanced-features","sections":[{"title":"PEFT/LoRA Integration","local":"peftlora-integration","sections":[],"depth":3},{"title":"Custom Reward Functions (GRPO)","local":"custom-reward-functions-grpo","sections":[],"depth":3},{"title":"Multi-GPU Support","local":"multi-gpu-support","sections":[],"depth":3},{"title":"Multi-GPU Training with FSDP","local":"multi-gpu-training-with-fsdp","sections":[],"depth":3},{"title":"Experiment Tracking Backends","local":"experiment-tracking-backends","sections":[],"depth":3},{"title":"Running in Google Colab","local":"running-in-google-colab","sections":[],"depth":3}],"depth":2},{"title":"Best Practices","local":"best-practices","sections":[{"title":"Tuning Chunk Granularity","local":"tuning-chunk-granularity","sections":[],"depth":3},{"title":"Memory Management","local":"memory-management","sections":[],"depth":3}],"depth":2},{"title":"Performance Benchmarks","local":"performance-benchmarks","sections":[],"depth":2},{"title":"Troubleshooting","local":"troubleshooting","sections":[],"depth":2},{"title":"Additional Resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="rapidfire-ai-integration" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rapidfire-ai-integration"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>RapidFire AI Integration</span></h1> <p data-svelte-h="svelte-q2w4ye">RapidFire AI is an open-source experiment execution framework that integrates with TRL to turn “train one configuration at a time” into <strong>real-time, side-by-side comparison of many configurations on the same GPU(s)</strong> — so you can iterate on hyperparameters, LoRA settings, prompt schemes, and ablations <strong>16–24× faster with no extra hardware</strong>.</p> <p data-svelte-h="svelte-gu56sl">Links: <a href="https://github.com/RapidFireAI/rapidfireai" rel="nofollow">GitHub</a> · <a href="https://oss-docs.rapidfire.ai" rel="nofollow">Docs</a> · <a href="http://tinyurl.com/rapidfireai-colab" rel="nofollow">Try in Colab</a></p> <h2 class="relative group"><a id="why-use-rapidfire-ai-with-trl" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#why-use-rapidfire-ai-with-trl"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Why use RapidFire AI with TRL?</span></h2> <p data-svelte-h="svelte-18rxg15">When fine-tuning or post-training with TRL, you typically need to:</p> <ul data-svelte-h="svelte-1xl2xuq"><li>Try different hyperparameter configurations</li> <li>Compare different LoRA settings</li> <li>Test different prompt schemes</li> <li>Run ablation studies</li></ul> <table data-svelte-h="svelte-1f5q8sd"><thead><tr><th>Scenario: comparing N training configs on the same GPU(s)</th> <th>TRL alone</th> <th>TRL + RapidFire AI</th></tr></thead> <tbody><tr><td>Training strategy</td> <td>Run N configs sequentially</td> <td>Run N configs concurrently</td></tr> <tr><td>When can you compare configs?</td> <td>After all runs finish</td> <td>Live, from the first chunk</td></tr> <tr><td>Stop losers / clone winners mid-training</td> <td>No</td> <td>Yes (Interactive Control Operations)</td></tr></tbody></table> <h3 class="relative group"><a id="how-it-works" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-it-works"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>How It Works</span></h3> <p data-svelte-h="svelte-11ucddv">RapidFire AI employs <strong>adaptive chunk-based scheduling</strong>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->GPU Timeline (Single GPU): | |
| Chunk 1: <span class="hljs-comment">[Config A]</span> → <span class="hljs-comment">[Config B]</span> → <span class="hljs-comment">[Config C]</span> → <span class="hljs-comment">[Config D]</span> | |
| Chunk 2: <span class="hljs-comment">[Config A]</span> → <span class="hljs-comment">[Config B]</span> → <span class="hljs-comment">[Config C]</span> → <span class="hljs-comment">[Config D]</span> | |
| Chunk 3: <span class="hljs-comment">[Config A]</span> → <span class="hljs-comment">[Config B]</span> → <span class="hljs-comment">[Config C]</span> → <span class="hljs-comment">[Config D]</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1cwa3cu">This enables:</p> <ul data-svelte-h="svelte-1fggrxd"><li>Early comparison of configurations on same data subsets incrementally</li> <li>Efficient GPU utilization and minimizing idle times</li> <li>Real-time and automated experiment metrics tracking</li> <li>Dynamic control over runs in flight to incentivize more experimentation</li></ul> <h2 class="relative group"><a id="key-features" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#key-features"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Key Features</span></h2> <ul data-svelte-h="svelte-1e37dg1"><li><strong>16-24× higher experimentation throughput</strong> compared to sequential training.</li> <li><strong>Almost no code changes</strong> - simple drop-in config APIs that just wrap around existing TRL and PEFT config APIs.</li> <li><strong>Interactive Control Operations</strong> - real-time control to stop, resume, and clone-modify (with or without warm starting) training runs in flight.</li> <li><strong>Integration with Fully Sharded Data Parallel (FSDP)</strong> for training large models that do not fit on a single GPU by sharding parameters, gradients, and optimizer states across multiple GPUs.</li> <li><strong>Full compatibility</strong> with transformers, PEFT, SFTTrainer, DPOTrainer, and GRPOTrainer.</li> <li><strong>Pluggable experiment tracking</strong>: MLflow (default), TensorBoard, and Trackio, enabled individually or in combination.</li> <li><strong>Zero-setup Google Colab support</strong>: one-click tutorial notebooks for SFT, DPO, and GRPO on free T4 GPUs.</li> <li><strong>Production-Ready</strong>: Already used in production environments with complete working examples.</li></ul> <h2 class="relative group"><a id="installation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#installation"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Installation</span></h2> <h3 class="relative group"><a id="prerequisites" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#prerequisites"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Prerequisites</span></h3> <ul data-svelte-h="svelte-p6yibt"><li>Python 3.12.x</li> <li>NVIDIA GPU with Compute Capability 7.x or 8.x (multiple GPUs required for FSDP)</li> <li>CUDA Toolkit 11.8+</li> <li>PyTorch 2.8+</li></ul> <h3 class="relative group"><a id="pip-install" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#pip-install"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>pip install</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->pip install rapidfireai<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-mollbd">Once installed, authenticate with Hugging Face and initialize RapidFire AI:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment"># Authenticate with Hugging Face</span> | |
| hf auth login --token YOUR_TOKEN | |
| <span class="hljs-comment"># Workaround for current issue: https://github.com/huggingface/xet-core/issues/527</span> | |
| pip uninstall -y hf-xet | |
| <span class="hljs-comment"># Initialize RapidFire AI</span> | |
| rapidfireai init | |
| <span class="hljs-comment"># Start the RapidFire AI server</span> | |
| rapidfireai start<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-tzukrn">The dashboard will be available at <code>http://localhost:8853</code> where you can monitor and control experiments in real-time.</p> <h2 class="relative group"><a id="quick-start-sft-training-with-multiple-configs" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#quick-start-sft-training-with-multiple-configs"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Quick Start: SFT Training with Multiple Configs</span></h2> <p data-svelte-h="svelte-zka7sg">Here’s a complete example showing how to train multiple SFT configurations concurrently:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> rapidfireai <span class="hljs-keyword">import</span> Experiment | |
| <span class="hljs-keyword">from</span> rapidfireai.automl <span class="hljs-keyword">import</span> <span class="hljs-type">List</span>, RFGridSearch, RFModelConfig, RFLoraConfig, RFSFTConfig | |
| <span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer | |
| <span class="hljs-comment"># Load dataset</span> | |
| dataset = load_dataset(<span class="hljs-string">"bitext/Bitext-customer-support-llm-chatbot-training-dataset"</span>) | |
| train_dataset = dataset[<span class="hljs-string">"train"</span>].select(<span class="hljs-built_in">range</span>(<span class="hljs-number">128</span>)).shuffle(seed=<span class="hljs-number">42</span>) | |
| eval_dataset = dataset[<span class="hljs-string">"train"</span>].select(<span class="hljs-built_in">range</span>(<span class="hljs-number">100</span>, <span class="hljs-number">124</span>)).shuffle(seed=<span class="hljs-number">42</span>) | |
| <span class="hljs-comment"># Define data formatting function</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">formatting_function</span>(<span class="hljs-params">row</span>): | |
| <span class="hljs-keyword">return</span> { | |
| <span class="hljs-string">"prompt"</span>: [ | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"system"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"You are a helpful customer support assistant."</span>}, | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: row[<span class="hljs-string">"instruction"</span>]}, | |
| ], | |
| <span class="hljs-string">"completion"</span>: [ | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, <span class="hljs-string">"content"</span>: row[<span class="hljs-string">"response"</span>]} | |
| ] | |
| } | |
| <span class="hljs-comment"># Initialize experiment</span> | |
| experiment = Experiment(experiment_name=<span class="hljs-string">"sft-customer-support"</span>) | |
| <span class="hljs-comment"># Define multiple LoRA configurations to compare</span> | |
| peft_configs = <span class="hljs-type">List</span>([ | |
| RFLoraConfig(r=<span class="hljs-number">8</span>, lora_alpha=<span class="hljs-number">16</span>, lora_dropout=<span class="hljs-number">0.1</span>, | |
| target_modules=[<span class="hljs-string">"q_proj"</span>, <span class="hljs-string">"v_proj"</span>], bias=<span class="hljs-string">"none"</span>), | |
| RFLoraConfig(r=<span class="hljs-number">32</span>, lora_alpha=<span class="hljs-number">64</span>, lora_dropout=<span class="hljs-number">0.1</span>, | |
| target_modules=[<span class="hljs-string">"q_proj"</span>, <span class="hljs-string">"k_proj"</span>, <span class="hljs-string">"v_proj"</span>, <span class="hljs-string">"o_proj"</span>], bias=<span class="hljs-string">"none"</span>) | |
| ]) | |
| <span class="hljs-comment"># Define multiple training configurations</span> | |
| <span class="hljs-comment"># 2 base configs × 2 PEFT configs = 4 total training runs</span> | |
| config_set = <span class="hljs-type">List</span>([ | |
| RFModelConfig( | |
| model_name=<span class="hljs-string">"TinyLlama/TinyLlama-1.1B-Chat-v1.0"</span>, | |
| peft_config=peft_configs, | |
| training_args=RFSFTConfig( <span class="hljs-comment"># Wraps TRL's SFTConfig</span> | |
| learning_rate=<span class="hljs-number">1e-3</span>, | |
| per_device_train_batch_size=<span class="hljs-number">4</span>, | |
| max_steps=<span class="hljs-number">128</span>, | |
| fp16=<span class="hljs-literal">True</span>, | |
| ), | |
| model_type=<span class="hljs-string">"causal_lm"</span>, | |
| model_kwargs={<span class="hljs-string">"device_map"</span>: <span class="hljs-string">"auto"</span>, <span class="hljs-string">"torch_dtype"</span>: <span class="hljs-string">"auto"</span>, <span class="hljs-string">"use_cache"</span>: <span class="hljs-literal">False</span>}, | |
| formatting_func=formatting_function, | |
| ), | |
| RFModelConfig( | |
| model_name=<span class="hljs-string">"TinyLlama/TinyLlama-1.1B-Chat-v1.0"</span>, | |
| peft_config=peft_configs, | |
| training_args=RFSFTConfig( | |
| learning_rate=<span class="hljs-number">1e-4</span>, <span class="hljs-comment"># Different learning rate</span> | |
| per_device_train_batch_size=<span class="hljs-number">4</span>, | |
| max_steps=<span class="hljs-number">128</span>, | |
| fp16=<span class="hljs-literal">True</span>, | |
| ), | |
| model_type=<span class="hljs-string">"causal_lm"</span>, | |
| model_kwargs={<span class="hljs-string">"device_map"</span>: <span class="hljs-string">"auto"</span>, <span class="hljs-string">"torch_dtype"</span>: <span class="hljs-string">"auto"</span>, <span class="hljs-string">"use_cache"</span>: <span class="hljs-literal">False</span>}, | |
| formatting_func=formatting_function, | |
| ) | |
| ]) | |
| <span class="hljs-comment"># Define model creation function</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">create_model</span>(<span class="hljs-params">model_config</span>): | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_config[<span class="hljs-string">"model_name"</span>], | |
| **model_config[<span class="hljs-string">"model_kwargs"</span>] | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained(model_config[<span class="hljs-string">"model_name"</span>]) | |
| <span class="hljs-keyword">return</span> (model, tokenizer) | |
| <span class="hljs-comment"># Create grid search over all configurations</span> | |
| config_group = RFGridSearch(configs=config_set, trainer_type=<span class="hljs-string">"SFT"</span>) | |
| <span class="hljs-comment"># Run all 4 configurations concurrently with chunk-based scheduling</span> | |
| experiment.run_fit(config_group, create_model, train_dataset, eval_dataset, | |
| num_chunks=<span class="hljs-number">4</span>, seed=<span class="hljs-number">42</span>) | |
| <span class="hljs-comment"># End experiment</span> | |
| experiment.end()<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="what-happens-during-execution" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#what-happens-during-execution"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>What Happens During Execution</span></h3> <p data-svelte-h="svelte-1xxqf12">When you run this example:</p> <ol data-svelte-h="svelte-1x2hkfa"><li><strong>Config Expansion</strong>: 2 base configurations × 2 PEFT configs = 4 total training runs</li> <li><strong>Chunk-based Scheduling</strong>: Training data is divided into chunks, and all 4 configs train concurrently</li> <li><strong>GPU Swapping</strong>: Models are swapped in/out of GPU memory based on chunk boundaries</li> <li><strong>Real-time Tracking</strong>: All metrics visible in the dashboard at <code>http://localhost:8853</code></li> <li><strong>Interactive Control</strong>: Stop, resume, or clone-modify any configuration from the dashboard</li></ol> <p data-svelte-h="svelte-149o20l">This delivers <strong>16-24× higher throughput</strong> compared to training each configuration sequentially!</p> <h2 class="relative group"><a id="supported-trl-trainers" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#supported-trl-trainers"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Supported TRL Trainers</span></h2> <h3 class="relative group"><a id="sfttrainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#sfttrainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>SFTTrainer</span></h3> <p data-svelte-h="svelte-12actga">Use <code>RFSFTConfig</code> as a drop-in replacement for <code>SFTConfig</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> rapidfireai.automl <span class="hljs-keyword">import</span> RFSFTConfig | |
| training_args = RFSFTConfig( | |
| learning_rate=<span class="hljs-number">5e-5</span>, | |
| per_device_train_batch_size=<span class="hljs-number">4</span>, | |
| num_train_epochs=<span class="hljs-number">3</span>, | |
| max_length = <span class="hljs-number">512</span>, | |
| <span class="hljs-comment"># ... all other SFTConfig parameters supported</span> | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-173rsg0"><strong>Example Notebook</strong>: <a href="https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/rf-tutorial-sft-chatqa-lite.ipynb" rel="nofollow">SFT for Customer Support</a></p> <h3 class="relative group"><a id="dpotrainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#dpotrainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>DPOTrainer</span></h3> <p data-svelte-h="svelte-rzx1zq">Use <code>RFDPOConfig</code> as a drop-in replacement for <code>DPOConfig</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> rapidfireai.automl <span class="hljs-keyword">import</span> RFDPOConfig | |
| training_args = RFDPOConfig( | |
| beta=<span class="hljs-number">0.1</span>, | |
| loss_type=<span class="hljs-string">"sigmoid"</span>, | |
| max_length=<span class="hljs-number">1024</span>, | |
| learning_rate=<span class="hljs-number">5e-4</span>, | |
| <span class="hljs-comment"># ... all other DPOConfig parameters supported</span> | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-18vvpm9"><strong>Example Notebook</strong>: <a href="https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/post-training/rf-tutorial-dpo-alignment-lite.ipynb" rel="nofollow">DPO for Preference Alignment</a></p> <h3 class="relative group"><a id="grpotrainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#grpotrainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>GRPOTrainer</span></h3> <p data-svelte-h="svelte-1i1klvq">Use <code>RFGRPOConfig</code> as a drop-in replacement for <code>GRPOConfig</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> rapidfireai.automl <span class="hljs-keyword">import</span> RFGRPOConfig | |
| training_args = RFGRPOConfig( | |
| learning_rate=<span class="hljs-number">5e-6</span>, | |
| num_generations=<span class="hljs-number">8</span>, | |
| max_completion_length=<span class="hljs-number">256</span>, | |
| <span class="hljs-comment"># ... all other GRPOConfig parameters supported</span> | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1a7u194"><strong>Example Notebook</strong>: <a href="https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/post-training/rf-tutorial-grpo-mathreasoning-lite.ipynb" rel="nofollow">GRPO for Math Reasoning</a></p> <h2 class="relative group"><a id="core-concepts" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#core-concepts"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Core Concepts</span></h2> <h3 class="relative group"><a id="chunk-based-concurrent-training" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#chunk-based-concurrent-training"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Chunk-Based Concurrent Training</span></h3> <p data-svelte-h="svelte-93qe9b">RapidFire AI divides training data into chunks and alternates between configurations:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-symbol">GPU</span> <span class="hljs-symbol">Timeline</span> (<span class="hljs-symbol">Single</span> <span class="hljs-symbol">GPU</span>): | |
| <span class="hljs-symbol">Chunk</span> <span class="hljs-number">1</span>: [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">A</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">B</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">C</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">D</span>] | |
| <span class="hljs-symbol">Chunk</span> <span class="hljs-number">2</span>: [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">A</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">B</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">C</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">D</span>] | |
| <span class="hljs-symbol">Chunk</span> <span class="hljs-number">3</span>: [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">A</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">B</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">C</span>] → [<span class="hljs-symbol">Config</span> <span class="hljs-symbol">D</span>] | |
| ...<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-xzau2l">This approach maximizes GPU utilization and enables early comparison of configurations while maintaining training stability through automatic checkpointing.</p> <h3 class="relative group"><a id="interactive-control-operations-ic-ops" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#interactive-control-operations-ic-ops"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Interactive Control Operations (IC Ops)</span></h3> <p data-svelte-h="svelte-1k6633c">Through the RapidFire AI dashboard, you can dynamically control running experiments:</p> <ul data-svelte-h="svelte-196cotr"><li><strong>Stop</strong>: Pause a configuration (checkpointed automatically)</li> <li><strong>Resume</strong>: Continue from last checkpoint</li> <li><strong>Clone-Modify</strong>: Duplicate a configuration with modifications (new run starts from scratch)</li> <li><strong>Clone-Modify with Warm Start</strong>: Clone-modify and initialize from the parent’s weights</li> <li><strong>Delete</strong>: Remove failed or unwanted runs</li></ul> <p data-svelte-h="svelte-1l1pplb">This enables adaptive experimentation where you can stop underperforming configs early and clone promising ones with tweaked hyperparameters.</p> <h3 class="relative group"><a id="multi-config-experimentation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#multi-config-experimentation"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Multi-Config Experimentation</span></h3> <p data-svelte-h="svelte-2bmx54">Use <code>RFGridSearch</code> or <code>RFRandomSearch</code> to automatically generate configuration combinations:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment"># Grid search: tests all combinations</span> | |
| config_group = RFGridSearch(configs=config_list, trainer_type=<span class="hljs-string">"SFT"</span>) | |
| <span class="hljs-comment"># Random search: samples N configurations</span> | |
| config_group = RFRandomSearch(configs=config_list, trainer_type=<span class="hljs-string">"DPO"</span>, num_samples=<span class="hljs-number">10</span>)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="advanced-features" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#advanced-features"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Advanced Features</span></h2> <h3 class="relative group"><a id="peftlora-integration" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#peftlora-integration"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>PEFT/LoRA Integration</span></h3> <p data-svelte-h="svelte-gilylc">Full support for parameter-efficient fine-tuning:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> rapidfireai.automl <span class="hljs-keyword">import</span> RFLoraConfig | |
| <span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> TaskType | |
| lora_config = RFLoraConfig( | |
| task_type=TaskType.CAUSAL_LM, | |
| r=<span class="hljs-number">64</span>, | |
| lora_alpha=<span class="hljs-number">64</span>, | |
| lora_dropout=<span class="hljs-number">0.1</span>, | |
| target_modules=[<span class="hljs-string">"q_proj"</span>, <span class="hljs-string">"k_proj"</span>, <span class="hljs-string">"v_proj"</span>, <span class="hljs-string">"o_proj"</span>], | |
| bias=<span class="hljs-string">"none"</span> | |
| )<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="custom-reward-functions-grpo" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#custom-reward-functions-grpo"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Custom Reward Functions (GRPO)</span></h3> <p data-svelte-h="svelte-hg3mr6">Define multiple reward functions for GRPO training:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">def</span> <span class="hljs-title function_">correctness_reward</span>(<span class="hljs-params">prompts, completions, answer, **kwargs</span>): | |
| <span class="hljs-string">"""Reward for correct answers"""</span> | |
| responses = [completion[<span class="hljs-number">0</span>][<span class="hljs-string">'content'</span>] <span class="hljs-keyword">for</span> completion <span class="hljs-keyword">in</span> completions] | |
| extracted = [extract_answer(r) <span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> responses] | |
| <span class="hljs-keyword">return</span> [<span class="hljs-number">2.0</span> <span class="hljs-keyword">if</span> r == a <span class="hljs-keyword">else</span> <span class="hljs-number">0.0</span> <span class="hljs-keyword">for</span> r, a <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(extracted, answer)] | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">format_reward</span>(<span class="hljs-params">completions, **kwargs</span>): | |
| <span class="hljs-string">"""Reward for proper formatting"""</span> | |
| <span class="hljs-keyword">import</span> re | |
| pattern = <span class="hljs-string">r"<reasoning>.*?</reasoning>\s*<answer>.*?</answer>"</span> | |
| responses = [completion[<span class="hljs-number">0</span>][<span class="hljs-string">"content"</span>] <span class="hljs-keyword">for</span> completion <span class="hljs-keyword">in</span> completions] | |
| matches = [re.<span class="hljs-keyword">match</span>(pattern, r) <span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> responses] | |
| <span class="hljs-keyword">return</span> [<span class="hljs-number">0.5</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">match</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0.0</span> <span class="hljs-keyword">for</span> <span class="hljs-keyword">match</span> <span class="hljs-keyword">in</span> matches] | |
| <span class="hljs-comment"># Use in model config</span> | |
| config = RFModelConfig( | |
| reward_funcs=[correctness_reward, format_reward], | |
| <span class="hljs-comment"># ... other parameters</span> | |
| )<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="multi-gpu-support" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#multi-gpu-support"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Multi-GPU Support</span></h3> <p data-svelte-h="svelte-1iwqvet">RapidFire AI automatically detects and utilizes all available GPUs. By default, the scheduler distributes independent configurations across GPUs (data-parallel across configs), so no special setup is required to run <code>N</code> configs on <code>N</code> GPUs concurrently.</p> <p data-svelte-h="svelte-b6yyz3">For models that do not fit on a single GPU, RapidFire AI also supports <strong>Fully Sharded Data Parallel (FSDP)</strong> to shard a single configuration across multiple GPUs — see the next section.</p> <h3 class="relative group"><a id="multi-gpu-training-with-fsdp" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#multi-gpu-training-with-fsdp"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Multi-GPU Training with FSDP</span></h3> <p data-svelte-h="svelte-m5hnwu">When a model is too large for a single GPU, enable FSDP directly through the training args of <code>RFSFTConfig</code> or <code>RFDPOConfig</code> — the same <code>fsdp</code> and <code>fsdp_config</code> fields exposed by Hugging Face <code>TrainingArguments</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> rapidfireai.automl <span class="hljs-keyword">import</span> RFModelConfig, RFSFTConfig, RFLoraConfig | |
| model_config = RFModelConfig( | |
| model_name=<span class="hljs-string">"meta-llama/Llama-3.1-8B-Instruct"</span>, | |
| peft_config=RFLoraConfig( | |
| r=<span class="hljs-number">16</span>, lora_alpha=<span class="hljs-number">32</span>, lora_dropout=<span class="hljs-number">0.05</span>, | |
| target_modules=[<span class="hljs-string">"q_proj"</span>, <span class="hljs-string">"k_proj"</span>, <span class="hljs-string">"v_proj"</span>, <span class="hljs-string">"o_proj"</span>], | |
| bias=<span class="hljs-string">"none"</span>, | |
| ), | |
| training_args=RFSFTConfig( | |
| learning_rate=<span class="hljs-number">2e-4</span>, | |
| per_device_train_batch_size=<span class="hljs-number">1</span>, | |
| gradient_accumulation_steps=<span class="hljs-number">8</span>, | |
| fsdp=<span class="hljs-string">"full_shard auto_wrap"</span>, | |
| fsdp_config={ | |
| <span class="hljs-string">"sharding_strategy"</span>: <span class="hljs-string">"FULL_SHARD"</span>, | |
| <span class="hljs-string">"auto_wrap_policy"</span>: <span class="hljs-string">"TRANSFORMER_BASED_WRAP"</span>, | |
| <span class="hljs-string">"backward_prefetch"</span>: <span class="hljs-string">"backward_pre"</span>, | |
| <span class="hljs-string">"forward_prefetch"</span>: <span class="hljs-literal">True</span>, | |
| <span class="hljs-string">"use_orig_params"</span>: <span class="hljs-literal">False</span>, | |
| <span class="hljs-string">"cpu_ram_efficient_loading"</span>: <span class="hljs-literal">True</span>, | |
| <span class="hljs-string">"offload_params"</span>: <span class="hljs-literal">True</span>, | |
| <span class="hljs-string">"sync_module_states"</span>: <span class="hljs-literal">True</span>, | |
| <span class="hljs-string">"limit_all_gathers"</span>: <span class="hljs-literal">True</span>, | |
| }, | |
| ), | |
| model_type=<span class="hljs-string">"causal_lm"</span>, | |
| model_kwargs={<span class="hljs-string">"torch_dtype"</span>: <span class="hljs-string">"auto"</span>}, | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-13e4au4">Key points:</p> <ul data-svelte-h="svelte-lnjz01"><li>FSDP works transparently with RapidFire AI’s chunk-based scheduling, IC Ops (stop / resume / clone-modify with or without warm-starting), and all supported metric tracking backends.</li> <li>FSDP is fully compatible with PEFT / LoRA — LoRA adapter weights are collected efficiently across shards when saving checkpoints.</li> <li>FSDP composes with grid search and random search: each expanded config gets its own sharded training run.</li></ul> <p data-svelte-h="svelte-1iygzqz"><strong>Example Notebooks</strong>:</p> <ul data-svelte-h="svelte-142u3g3"><li><a href="https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/rf-tutorial-sft-chatqa-fsdp-lite.ipynb" rel="nofollow">SFT with FSDP (lite, small model)</a></li> <li><a href="https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/rf-tutorial-sft-chatqa-fsdp-large.ipynb" rel="nofollow">SFT with FSDP (large model)</a></li> <li><a href="https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/post-training/rf-tutorial-dpo-alignment-fsdp-lite.ipynb" rel="nofollow">DPO with FSDP</a></li></ul> <h3 class="relative group"><a id="experiment-tracking-backends" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#experiment-tracking-backends"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Experiment Tracking Backends</span></h3> <p data-svelte-h="svelte-gby674">RapidFire AI supports three metric logging backends that can be used individually or together: <strong>MLflow</strong> (the default for local installs), <strong>TensorBoard</strong> (the default in Google Colab), and <strong>Trackio</strong>.</p> <p data-svelte-h="svelte-olls5t">Select one or more backends at server startup with the <code>--tracking-backends</code> flag:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment"># MLflow only (default on local installs)</span> | |
| rapidfireai start --tracking-backends mlflow | |
| <span class="hljs-comment"># TensorBoard only</span> | |
| rapidfireai start --tracking-backends tensorboard | |
| <span class="hljs-comment"># Any combination</span> | |
| rapidfireai start --tracking-backends mlflow tensorboard trackio<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1nafnok">Equivalent environment variables are also available:</p> <ul data-svelte-h="svelte-1hnyjtm"><li><code>RF_MLFLOW_ENABLED</code> (default <code>true</code>, or <code>false</code> in Colab)</li> <li><code>RF_TENSORBOARD_ENABLED</code> (default <code>false</code>, or <code>true</code> in Colab)</li> <li><code>RF_TRACKIO_ENABLED</code> (default <code>false</code>)</li></ul> <p data-svelte-h="svelte-1ruq4j5">All three backends receive the same metrics (loss, evaluation scores, learning rate, etc.) and respect IC Ops run lifecycle events, so you can use, for example, Trackio for lightweight sharing alongside MLflow for a full local dashboard.</p> <h3 class="relative group"><a id="running-in-google-colab" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#running-in-google-colab"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Running in Google Colab</span></h3> <p data-svelte-h="svelte-1rz2ufe">RapidFire AI runs on free Google Colab T4 GPUs, with tutorial notebooks for SFT, DPO, GRPO, and RAG / context-engineering workflows. In Colab, TensorBoard is the default tracking backend (MLflow is disabled for simplicity), and the usual <code>rapidfireai init</code> / <code>rapidfireai start</code> commands run directly from notebook cells — no terminal access required.</p> <p data-svelte-h="svelte-1vdkips">Get started: <a href="http://tinyurl.com/rapidfireai-colab" rel="nofollow">RapidFire AI in Google Colab</a>.</p> <h2 class="relative group"><a id="best-practices" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#best-practices"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Best Practices</span></h2> <h3 class="relative group"><a id="tuning-chunk-granularity" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tuning-chunk-granularity"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tuning Chunk Granularity</span></h3> <p data-svelte-h="svelte-128g1b1">The <code>num_chunks</code> parameter controls swap frequency:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment"># Fewer chunks = less overhead, less frequent comparison</span> | |
| experiment.run_fit(..., num_chunks=<span class="hljs-number">2</span>) | |
| <span class="hljs-comment"># More chunks = more overhead, more frequent comparison</span> | |
| experiment.run_fit(..., num_chunks=<span class="hljs-number">16</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1ylh89g"><strong>Rule of thumb</strong>: Start with <code>num_chunks=4</code> and adjust based on dataset size and number of configurations.</p> <h3 class="relative group"><a id="memory-management" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#memory-management"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Memory Management</span></h3> <p data-svelte-h="svelte-407if8">For large models, use quantization:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BitsAndBytesConfig | |
| <span class="hljs-keyword">import</span> torch | |
| bnb_config = BitsAndBytesConfig( | |
| load_in_4bit=<span class="hljs-literal">True</span>, | |
| bnb_4bit_compute_dtype=torch.bfloat16, | |
| bnb_4bit_use_double_quant=<span class="hljs-literal">True</span>, | |
| bnb_4bit_quant_type=<span class="hljs-string">"nf4"</span>, | |
| ) | |
| model_kwargs = { | |
| <span class="hljs-string">"quantization_config"</span>: bnb_config, | |
| <span class="hljs-string">"device_map"</span>: <span class="hljs-string">"auto"</span>, | |
| }<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="performance-benchmarks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#performance-benchmarks"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Performance Benchmarks</span></h2> <p data-svelte-h="svelte-qxrbo">Based on internal benchmarks comparing sequential vs. RapidFire AI concurrent training:</p> <table data-svelte-h="svelte-1tz9eyo"><thead><tr><th>Scenario</th> <th>Sequential Time</th> <th>RapidFire AI Time</th> <th>Speedup</th></tr></thead> <tbody><tr><td>4 configs, 1 GPU</td> <td>120 min</td> <td>7.5 min</td> <td>16×</td></tr> <tr><td>8 configs, 1 GPU</td> <td>240 min</td> <td>12 min</td> <td>20×</td></tr> <tr><td>4 configs, 2 GPUs</td> <td>60 min</td> <td>4 min</td> <td>15×</td></tr> <tr><td>8 configs, 4 GPUs</td> <td>60 min</td> <td>3 min</td> <td>20×</td></tr></tbody></table> <p data-svelte-h="svelte-1d0mph6"><em>Benchmarks performed on NVIDIA A100 40GB with TinyLlama-1.1B and Llama-3.2-1B models</em></p> <h2 class="relative group"><a id="troubleshooting" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#troubleshooting"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Troubleshooting</span></h2> <p data-svelte-h="svelte-kxys1u">For troubleshooting guidance, see the <a href="https://oss-docs.rapidfire.ai/en/latest/troubleshooting.html" rel="nofollow">RapidFire AI Troubleshooting Guide</a>.</p> <h2 class="relative group"><a id="additional-resources" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#additional-resources"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Additional Resources</span></h2> <ul data-svelte-h="svelte-3bxntc"><li><strong>Colab Notebook</strong>: <a href="http://tinyurl.com/rapidfireai-colab" rel="nofollow">RapidFire AI in Google Colab</a></li> <li><strong>Documentation</strong>: <a href="https://oss-docs.rapidfire.ai" rel="nofollow">oss-docs.rapidfire.ai</a></li> <li><strong>GitHub</strong>: <a href="https://github.com/RapidFireAI/rapidfireai" rel="nofollow">RapidFireAI/rapidfireai</a></li> <li><strong>PyPI</strong>: <a href="https://pypi.org/project/rapidfireai/" rel="nofollow">pypi.org/project/rapidfireai</a></li> <li><strong>Discord</strong>: <a href="https://discord.gg/6vSTtncKNN" rel="nofollow">Join our Discord</a></li> <li><strong>Tutorial Notebooks</strong>: <a href="https://github.com/RapidFireAI/rapidfireai/tree/main/tutorial_notebooks" rel="nofollow">GitHub Repository</a></li></ul> <p data-svelte-h="svelte-1tkler6">Learn more about RapidFire AI in their <a href="https://github.com/RapidFireAI/rapidfireai" rel="nofollow">official repository</a> and <a href="https://oss-docs.rapidfire.ai" rel="nofollow">documentation</a>.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/trl/blob/main/docs/source/rapidfire_integration.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_ew3sc8 = { | |
| assets: "/docs/trl/pr_5622/en", | |
| base: "/docs/trl/pr_5622/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/trl/pr_5622/en/_app/immutable/entry/start.05d1d9bd.js"), | |
| import("/docs/trl/pr_5622/en/_app/immutable/entry/app.a8009617.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 47], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 95.4 kB
- Xet hash:
- f77463417b1d15807dd4dc1f9dfd8953541a68caaba7f05519d13751a498bc08
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.