mirror of
https://github.com/finegrain-ai/refiners.git
synced 2024-11-22 14:18:46 +00:00
4007 lines
216 KiB
HTML
4007 lines
216 KiB
HTML
|
|
|||
|
<!doctype html>
|
|||
|
<html lang="en" class="no-js">
|
|||
|
<head>
|
|||
|
|
|||
|
<meta charset="utf-8">
|
|||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|||
|
|
|||
|
<meta name="description" content="A micro framework on top of PyTorch with first class citizen APIs for foundation model adaptation">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<link rel="prev" href="../../../guides/comfyui_refiners/">
|
|||
|
|
|||
|
|
|||
|
<link rel="next" href="../layers/">
|
|||
|
|
|||
|
|
|||
|
<link rel="icon" href="../../../assets/favicon.svg">
|
|||
|
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.5.45">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<title>Adapters - Refiners</title>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<link rel="stylesheet" href="../../../assets/stylesheets/main.0253249f.min.css">
|
|||
|
|
|||
|
|
|||
|
<link rel="stylesheet" href="../../../assets/stylesheets/palette.06af60db.min.css">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
|
|||
|
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<link rel="stylesheet" href="../../../assets/_mkdocstrings.css">
|
|||
|
|
|||
|
<link rel="stylesheet" href="../../../stylesheets/extra.css">
|
|||
|
|
|||
|
<script>__md_scope=new URL("../../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="deep-orange" data-md-color-accent="deep-orange">
|
|||
|
|
|||
|
|
|||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
|||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|||
|
<label class="md-overlay" for="__drawer"></label>
|
|||
|
<div data-md-component="skip">
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter" class="md-skip">
|
|||
|
Skip to content
|
|||
|
</a>
|
|||
|
|
|||
|
</div>
|
|||
|
<div data-md-component="announce">
|
|||
|
|
|||
|
<aside class="md-banner">
|
|||
|
<div class="md-banner__inner md-grid md-typeset">
|
|||
|
|
|||
|
<button class="md-banner__button md-icon" aria-label="Don't show this again">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
|
|||
|
</button>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Check out our <a href="https://finegrain.ai/bounties">Bounty Program</a> 💰!
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<script>var el=document.querySelector("[data-md-component=announce]");if(el){var content=el.querySelector(".md-typeset");__md_hash(content.innerHTML)===__md_get("__announce")&&(el.hidden=!0)}</script>
|
|||
|
|
|||
|
</aside>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<header class="md-header md-header--shadow md-header--lifted" data-md-component="header">
|
|||
|
<nav class="md-header__inner md-grid" aria-label="Header">
|
|||
|
<a href="../../.." title="Refiners" class="md-header__button md-logo" aria-label="Refiners" data-md-component="logo">
|
|||
|
|
|||
|
<img src="../../../assets/favicon.svg" alt="logo">
|
|||
|
|
|||
|
</a>
|
|||
|
<label class="md-header__button md-icon" for="__drawer">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
|
|||
|
</label>
|
|||
|
<div class="md-header__title" data-md-component="header-title">
|
|||
|
<div class="md-header__ellipsis">
|
|||
|
<div class="md-header__topic">
|
|||
|
<span class="md-ellipsis">
|
|||
|
Refiners
|
|||
|
</span>
|
|||
|
</div>
|
|||
|
<div class="md-header__topic" data-md-component="header-topic">
|
|||
|
<span class="md-ellipsis">
|
|||
|
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Adapters
|
|||
|
|
|||
|
</span>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<label class="md-header__button md-icon" for="__search">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
|
|||
|
</label>
|
|||
|
<div class="md-search" data-md-component="search" role="dialog">
|
|||
|
<label class="md-search__overlay" for="__search"></label>
|
|||
|
<div class="md-search__inner" role="search">
|
|||
|
<form class="md-search__form" name="search">
|
|||
|
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
|
|||
|
<label class="md-search__icon md-icon" for="__search">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
|
|||
|
</label>
|
|||
|
<nav class="md-search__options" aria-label="Search">
|
|||
|
|
|||
|
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
|
|||
|
</button>
|
|||
|
</nav>
|
|||
|
|
|||
|
</form>
|
|||
|
<div class="md-search__output">
|
|||
|
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
|
|||
|
<div class="md-search-result" data-md-component="search-result">
|
|||
|
<div class="md-search-result__meta">
|
|||
|
Initializing search
|
|||
|
</div>
|
|||
|
<ol class="md-search-result__list" role="presentation"></ol>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<div class="md-header__source">
|
|||
|
<a href="https://github.com/finegrain-ai/refiners" title="Go to repository" class="md-source" data-md-component="source">
|
|||
|
<div class="md-source__icon md-icon">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
|
|||
|
</div>
|
|||
|
<div class="md-source__repository">
|
|||
|
Refiners
|
|||
|
</div>
|
|||
|
</a>
|
|||
|
</div>
|
|||
|
|
|||
|
</nav>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs">
|
|||
|
<div class="md-grid">
|
|||
|
<ul class="md-tabs__list">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-tabs__item">
|
|||
|
<a href="../../.." class="md-tabs__link">
|
|||
|
|
|||
|
|
|||
|
Home
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-tabs__item">
|
|||
|
<a href="../../../getting-started/recommended/" class="md-tabs__link">
|
|||
|
|
|||
|
|
|||
|
Getting started
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-tabs__item">
|
|||
|
<a href="../../../concepts/chain/" class="md-tabs__link">
|
|||
|
|
|||
|
|
|||
|
Key Concepts
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-tabs__item">
|
|||
|
<a href="../../../guides/adapting_sdxl/" class="md-tabs__link">
|
|||
|
|
|||
|
|
|||
|
Guides
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-tabs__item md-tabs__item--active">
|
|||
|
<a href="./" class="md-tabs__link">
|
|||
|
|
|||
|
|
|||
|
API Reference
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
</nav>
|
|||
|
|
|||
|
|
|||
|
</header>
|
|||
|
|
|||
|
<div class="md-container" data-md-component="container">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<main class="md-main" data-md-component="main">
|
|||
|
<div class="md-main__inner md-grid">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
|
|||
|
<div class="md-sidebar__scrollwrap">
|
|||
|
<div class="md-sidebar__inner">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="Navigation" data-md-level="0">
|
|||
|
<label class="md-nav__title" for="__drawer">
|
|||
|
<a href="../../.." title="Refiners" class="md-nav__button md-logo" aria-label="Refiners" data-md-component="logo">
|
|||
|
|
|||
|
<img src="../../../assets/favicon.svg" alt="logo">
|
|||
|
|
|||
|
</a>
|
|||
|
Refiners
|
|||
|
</label>
|
|||
|
|
|||
|
<div class="md-nav__source">
|
|||
|
<a href="https://github.com/finegrain-ai/refiners" title="Go to repository" class="md-source" data-md-component="source">
|
|||
|
<div class="md-source__icon md-icon">
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
|
|||
|
</div>
|
|||
|
<div class="md-source__repository">
|
|||
|
Refiners
|
|||
|
</div>
|
|||
|
</a>
|
|||
|
</div>
|
|||
|
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_1" >
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_1" id="__nav_1_label" tabindex="0">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Home
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_1_label" aria-expanded="false">
|
|||
|
<label class="md-nav__title" for="__nav_1">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Home
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../.." class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m12 3.77-.75.84S9.97 6.06 8.68 7.94 6 12.07 6 14.23a6 6 0 0 0 6 6 6 6 0 0 0 6-6c0-2.16-1.39-4.41-2.68-6.29s-2.57-3.33-2.57-3.33zm0 3.13c.44.52.84.95 1.68 2.17 1.21 1.76 2.32 4 2.32 5.16 0 2.22-1.78 4-4 4s-4-1.78-4-4c0-1.16 1.11-3.4 2.32-5.16.84-1.22 1.24-1.65 1.68-2.17"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Welcome
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../home/why/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11h3v2h-3zM1 11h3v2H1zM13 1v3h-2V1zM4.92 3.5l2.13 2.14-1.42 1.41L3.5 4.93zm12.03 2.13 2.12-2.13 1.43 1.43-2.13 2.12zM12 6a6 6 0 0 1 6 6c0 2.22-1.21 4.16-3 5.2V19a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1v-1.8c-1.79-1.04-3-2.98-3-5.2a6 6 0 0 1 6-6m2 15v1a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-1zm-3-3h2v-2.13c1.73-.44 3-2.01 3-3.87a4 4 0 0 0-4-4 4 4 0 0 0-4 4c0 1.86 1.27 3.43 3 3.87z"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Manifesto
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_2" >
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Getting started
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
|
|||
|
<label class="md-nav__title" for="__nav_2">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Getting started
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../getting-started/recommended/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m12 15.39-3.76 2.27.99-4.28-3.32-2.88 4.38-.37L12 6.09l1.71 4.04 4.38.37-3.32 2.88.99 4.28M22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.45 4.73L5.82 21 12 17.27 18.18 21l-1.64-7.03z"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Recommended usage
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../getting-started/advanced/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 1.09V6H7V1.09C4.16 1.57 2 4.03 2 7c0 2.22 1.21 4.15 3 5.19V21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-8.81c1.79-1.04 3-2.97 3-5.19 0-2.97-2.16-5.43-5-5.91m1 9.37-1 .58V20H7v-8.96l-1-.58C4.77 9.74 4 8.42 4 7c0-1 .37-1.94 1-2.65V8h6V4.35c.63.71 1 1.65 1 2.65 0 1.42-.77 2.74-2 3.46m10.94 7.48a3.3 3.3 0 0 0 0-.89l.97-.73a.22.22 0 0 0 .06-.29l-.92-1.56c-.05-.1-.18-.14-.29-.1l-1.15.45c-.24-.17-.49-.32-.78-.44l-.17-1.19a.235.235 0 0 0-.23-.19h-1.85c-.12 0-.22.08-.24.19l-.17 1.19c-.29.12-.54.27-.78.44l-1.15-.45c-.1-.04-.24 0-.28.1l-.93 1.56c-.06.1-.03.22.06.29l.97.73c-.01.15-.03.3-.03.45s.02.29.03.44l-.97.74a.22.22 0 0 0-.06.29l.93 1.56c.04.1.18.13.28.1l1.15-.46c.24.18.49.33.78.45l.17 1.19c.02.11.12.19.24.19h1.85c.11 0 .21-.08.23-.19l.17-1.19c.29-.12.54-.27.78-.45l1.15.46c.11.03.24 0 .29-.1l.92-1.56a.22.22 0 0 0-.06-.29zM17.5 19c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Advanced usage
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_3" >
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Key Concepts
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
|
|||
|
<label class="md-nav__title" for="__nav_3">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Key Concepts
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../concepts/chain/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 1a2.5 2.5 0 0 0-2.5 2.5A2.5 2.5 0 0 0 11 5.79V7H7a2 2 0 0 0-2 2v.71A2.5 2.5 0 0 0 3.5 12 2.5 2.5 0 0 0 5 14.29V15H4a2 2 0 0 0-2 2v1.21A2.5 2.5 0 0 0 .5 20.5 2.5 2.5 0 0 0 3 23a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 4 18.21V17h4v1.21a2.5 2.5 0 0 0-1.5 2.29A2.5 2.5 0 0 0 9 23a2.5 2.5 0 0 0 2.5-2.5 2.5 2.5 0 0 0-1.5-2.29V17a2 2 0 0 0-2-2H7v-.71A2.5 2.5 0 0 0 8.5 12 2.5 2.5 0 0 0 7 9.71V9h10v.71A2.5 2.5 0 0 0 15.5 12a2.5 2.5 0 0 0 1.5 2.29V15h-1a2 2 0 0 0-2 2v1.21a2.5 2.5 0 0 0-1.5 2.29A2.5 2.5 0 0 0 15 23a2.5 2.5 0 0 0 2.5-2.5 2.5 2.5 0 0 0-1.5-2.29V17h4v1.21a2.5 2.5 0 0 0-1.5 2.29A2.5 2.5 0 0 0 21 23a2.5 2.5 0 0 0 2.5-2.5 2.5 2.5 0 0 0-1.5-2.29V17a2 2 0 0 0-2-2h-1v-.71A2.5 2.5 0 0 0 20.5 12 2.5 2.5 0 0 0 19 9.71V9a2 2 0 0 0-2-2h-4V5.79a2.5 2.5 0 0 0 1.5-2.29A2.5 2.5 0 0 0 12 1m0 1.5a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1M6 11a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1m12 0a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1M3 19.5a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1m6 0a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1m6 0a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1m6 0a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Chain
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../concepts/context/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12zm3-6h-2V6h2zm0 4h-2v-2h2z"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Context
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../concepts/adapter/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 12h2v5h16v-5h2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2m9-12h2v3h3v2h-3v3h-2v-3H8V8h3Z"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Adapter
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_4" >
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Guides
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="false">
|
|||
|
<label class="md-nav__title" for="__nav_4">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Guides
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../guides/adapting_sdxl/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 13h2v2h2v-2h2v2h2v-2h2v2h2v-5l3-3V1h2l4 2-4 2v2l3 3v12H11v-3a2 2 0 0 0-2-2 2 2 0 0 0-2 2v3H2zm16-3c-.55 0-1 .54-1 1.2V13h2v-1.8c0-.66-.45-1.2-1-1.2"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Adapting SDXL
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../guides/training_101/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 22a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-6v7L9.5 7.5 7 9V2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2z"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Training 101
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../../guides/comfyui_refiners/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15 3v4.59L7.59 15H3v6h6v-4.58L16.42 9H21V3m-4 2h2v2h-2M5 17h2v2H5"/></svg>
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
ComfyUI Refiners
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" checked>
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
API Reference
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="true">
|
|||
|
<label class="md-nav__title" for="__nav_5">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
API Reference
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_1" checked>
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_5_1" id="__nav_5_1_label" tabindex="">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
Refiners
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_1_label" aria-expanded="true">
|
|||
|
<label class="md-nav__title" for="__nav_5_1">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Refiners
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_1_1" checked>
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_5_1_1" id="__nav_5_1_1_label" tabindex="0">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Fluxion
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_5_1_1_label" aria-expanded="true">
|
|||
|
<label class="md-nav__title" for="__nav_5_1_1">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Fluxion
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--active">
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link md-nav__link--active" for="__toc">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Adapters
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<a href="./" class="md-nav__link md-nav__link--active">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Adapters
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__title" for="__toc">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Table of contents
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> Adapter
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
<nav class="md-nav" aria-label=" Adapter">
|
|||
|
<ul class="md-nav__list">
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.target" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> target
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.eject" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> eject
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.inject" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> inject
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.setup_adapter" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> setup_adapter
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Conv2dLora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> Conv2dLora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LinearLora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> LinearLora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> Lora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
<nav class="md-nav" aria-label=" Lora">
|
|||
|
<ul class="md-nav__list">
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.down" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> down
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.rank" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> rank
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.scale" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> scale
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.up" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> up
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.from_dict" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> from_dict
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.load_weights" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> load_weights
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.lora_layers" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> lora_layers
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.reset_parameters" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> reset_parameters
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> LoraAdapter
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
<nav class="md-nav" aria-label=" LoraAdapter">
|
|||
|
<ul class="md-nav__list">
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.lora_layers" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> lora_layers
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.loras" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> loras
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.names" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> names
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.scales" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> scales
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.add_lora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> add_lora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.remove_lora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> remove_lora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.auto_attach_loras" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-function"></code> auto_attach_loras
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../layers/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Layers
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../context/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Context
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../utils/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Utils
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item md-nav__item--nested">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_5_1_2" >
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__link" for="__nav_5_1_2" id="__nav_5_1_2_label" tabindex="0">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Foundation Models
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
</label>
|
|||
|
|
|||
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_5_1_2_label" aria-expanded="false">
|
|||
|
<label class="md-nav__title" for="__nav_5_1_2">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Foundation Models
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-scrollfix>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../foundationals/clip/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> CLIP
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../foundationals/dinov2/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> DINOv2
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../foundationals/latent_diffusion/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Latent Diffusion
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../foundationals/segment_anything/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Segment Anything
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="../../foundationals/swin/" class="md-nav__link">
|
|||
|
|
|||
|
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Swin Transformers
|
|||
|
</span>
|
|||
|
|
|||
|
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
|
|||
|
<div class="md-sidebar__scrollwrap">
|
|||
|
<div class="md-sidebar__inner">
|
|||
|
|
|||
|
|
|||
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<label class="md-nav__title" for="__toc">
|
|||
|
<span class="md-nav__icon md-icon"></span>
|
|||
|
Table of contents
|
|||
|
</label>
|
|||
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> Adapter
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
<nav class="md-nav" aria-label=" Adapter">
|
|||
|
<ul class="md-nav__list">
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.target" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> target
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.eject" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> eject
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.inject" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> inject
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.setup_adapter" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> setup_adapter
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Conv2dLora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> Conv2dLora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LinearLora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> LinearLora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> Lora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
<nav class="md-nav" aria-label=" Lora">
|
|||
|
<ul class="md-nav__list">
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.down" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> down
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.rank" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> rank
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.scale" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> scale
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.up" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> up
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.from_dict" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> from_dict
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.load_weights" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> load_weights
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.lora_layers" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> lora_layers
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.reset_parameters" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> reset_parameters
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> LoraAdapter
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
<nav class="md-nav" aria-label=" LoraAdapter">
|
|||
|
<ul class="md-nav__list">
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.lora_layers" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> lora_layers
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.loras" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> loras
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.names" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> names
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.scales" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> scales
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.add_lora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> add_lora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.remove_lora" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code> remove_lora
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
<li class="md-nav__item">
|
|||
|
<a href="#refiners.fluxion.adapters.auto_attach_loras" class="md-nav__link">
|
|||
|
<span class="md-ellipsis">
|
|||
|
<code class="doc-symbol doc-symbol-toc doc-symbol-function"></code> auto_attach_loras
|
|||
|
</span>
|
|||
|
</a>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
|
|||
|
</nav>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="md-content" data-md-component="content">
|
|||
|
<article class="md-content__inner md-typeset">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h1><code class="doc-symbol doc-symbol-nav doc-symbol-module"></code> Adapters</h1>
|
|||
|
|
|||
|
<div class="doc doc-object doc-module">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-contents first">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-children">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-class">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h2 id="refiners.fluxion.adapters.Adapter" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">Adapter</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter" class="headerlink" title="Permanent link">¶</a></h2>
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
<p class="doc doc-class-bases">
|
|||
|
Bases: <code><a class="autorefs autorefs-external" title="typing.Generic" href="https://docs.python.org/3/library/typing.html#typing.Generic">Generic</a>[<span title="refiners.fluxion.adapters.adapter.T">T</span>]</code></p>
|
|||
|
|
|||
|
|
|||
|
<p>Base class for adapters.</p>
|
|||
|
<p>An Adapter modifies the structure of a <a class="autorefs autorefs-internal" href="../layers/#refiners.fluxion.layers.Module"><code>Module</code></a>
|
|||
|
(typically by adding, removing or replacing layers), to adapt it to a new task.</p>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-children">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Adapter.target" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">target</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.target" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">target</span><span class="p">:</span> <span class="n"><span title="refiners.fluxion.adapters.adapter.T">T</span></span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The target of the adapter.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Adapter.eject" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">eject</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.eject" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">eject</span><span class="p">()</span> <span class="o">-></span> <span class="kc">None</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Eject the adapter.</p>
|
|||
|
<p>This method is the inverse of <a class="autorefs autorefs-internal" href="#refiners.fluxion.adapters.Adapter.inject"><code>inject</code></a>,
|
|||
|
and should leave the target in the same state as before the injection.</p>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/adapter.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-85"> 85</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-86"> 86</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-87"> 87</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-88"> 88</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-89"> 89</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-90"> 90</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-91"> 91</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-92"> 92</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-93"> 93</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-94"> 94</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-95"> 95</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-96"> 96</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-97"> 97</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-98"> 98</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-99"> 99</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-100">100</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-101">101</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-102">102</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-103">103</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-104">104</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-85"><a id="__codelineno-0-85" name="__codelineno-0-85"></a><span class="k">def</span> <span class="nf">eject</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-86"><a id="__codelineno-0-86" name="__codelineno-0-86"></a><span class="w"> </span><span class="sd">"""Eject the adapter.</span>
|
|||
|
</span><span id="__span-0-87"><a id="__codelineno-0-87" name="__codelineno-0-87"></a>
|
|||
|
</span><span id="__span-0-88"><a id="__codelineno-0-88" name="__codelineno-0-88"></a><span class="sd"> This method is the inverse of [`inject`][refiners.fluxion.adapters.Adapter.inject],</span>
|
|||
|
</span><span id="__span-0-89"><a id="__codelineno-0-89" name="__codelineno-0-89"></a><span class="sd"> and should leave the target in the same state as before the injection.</span>
|
|||
|
</span><span id="__span-0-90"><a id="__codelineno-0-90" name="__codelineno-0-90"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-91"><a id="__codelineno-0-91" name="__codelineno-0-91"></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">Chain</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-92"><a id="__codelineno-0-92" name="__codelineno-0-92"></a>
|
|||
|
</span><span id="__span-0-93"><a id="__codelineno-0-93" name="__codelineno-0-93"></a> <span class="c1"># In general, the "actual target" is the target.</span>
|
|||
|
</span><span id="__span-0-94"><a id="__codelineno-0-94" name="__codelineno-0-94"></a> <span class="c1"># Here we deal with the edge case where the target</span>
|
|||
|
</span><span id="__span-0-95"><a id="__codelineno-0-95" name="__codelineno-0-95"></a> <span class="c1"># is part of the replacement block and has been adapted by</span>
|
|||
|
</span><span id="__span-0-96"><a id="__codelineno-0-96" name="__codelineno-0-96"></a> <span class="c1"># another adapter after this one. For instance, this is the</span>
|
|||
|
</span><span id="__span-0-97"><a id="__codelineno-0-97" name="__codelineno-0-97"></a> <span class="c1"># case when stacking Controlnets.</span>
|
|||
|
</span><span id="__span-0-98"><a id="__codelineno-0-98" name="__codelineno-0-98"></a> <span class="n">actual_target</span> <span class="o">=</span> <span class="n">lookup_top_adapter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-99"><a id="__codelineno-0-99" name="__codelineno-0-99"></a>
|
|||
|
</span><span id="__span-0-100"><a id="__codelineno-0-100" name="__codelineno-0-100"></a> <span class="k">if</span> <span class="p">(</span><span class="n">parent</span> <span class="o">:=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parent</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-101"><a id="__codelineno-0-101" name="__codelineno-0-101"></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actual_target</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">ContextModule</span><span class="p">):</span>
|
|||
|
</span><span id="__span-0-102"><a id="__codelineno-0-102" name="__codelineno-0-102"></a> <span class="n">actual_target</span><span class="o">.</span><span class="n">_set_parent</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> <span class="c1"># type: ignore[reportPrivateUsage]</span>
|
|||
|
</span><span id="__span-0-103"><a id="__codelineno-0-103" name="__codelineno-0-103"></a> <span class="k">else</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-104"><a id="__codelineno-0-104" name="__codelineno-0-104"></a> <span class="n">parent</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">old_module</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">new_module</span><span class="o">=</span><span class="n">actual_target</span><span class="p">)</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Adapter.inject" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">inject</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.inject" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">inject</span><span class="p">(</span><span class="n">parent</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Chain" href="../layers/#refiners.fluxion.layers.Chain">Chain</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n"><span title="refiners.fluxion.adapters.adapter.TAdapter">TAdapter</span></span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Inject the adapter.</p>
|
|||
|
<p>This method replaces the target of the adapter by the adapter inside the parent of the target.</p>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>parent</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Chain" href="../layers/#refiners.fluxion.layers.Chain">Chain</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The parent to inject the adapter into, if the target doesn't have a parent.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/adapter.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-53">53</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-54">54</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-55">55</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-56">56</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-57">57</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-58">58</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-59">59</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-60">60</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-61">61</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-62">62</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-63">63</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-64">64</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-65">65</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-66">66</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-67">67</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-68">68</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-69">69</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-70">70</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-71">71</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-72">72</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-73">73</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-74">74</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-75">75</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-76">76</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-77">77</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-78">78</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-79">79</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-80">80</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-81">81</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-82">82</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-83">83</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-53"><a id="__codelineno-0-53" name="__codelineno-0-53"></a><span class="k">def</span> <span class="nf">inject</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">TAdapter</span><span class="p">,</span> <span class="n">parent</span><span class="p">:</span> <span class="n">fl</span><span class="o">.</span><span class="n">Chain</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">TAdapter</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-54"><a id="__codelineno-0-54" name="__codelineno-0-54"></a><span class="w"> </span><span class="sd">"""Inject the adapter.</span>
|
|||
|
</span><span id="__span-0-55"><a id="__codelineno-0-55" name="__codelineno-0-55"></a>
|
|||
|
</span><span id="__span-0-56"><a id="__codelineno-0-56" name="__codelineno-0-56"></a><span class="sd"> This method replaces the target of the adapter by the adapter inside the parent of the target.</span>
|
|||
|
</span><span id="__span-0-57"><a id="__codelineno-0-57" name="__codelineno-0-57"></a>
|
|||
|
</span><span id="__span-0-58"><a id="__codelineno-0-58" name="__codelineno-0-58"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-59"><a id="__codelineno-0-59" name="__codelineno-0-59"></a><span class="sd"> parent: The parent to inject the adapter into, if the target doesn't have a parent.</span>
|
|||
|
</span><span id="__span-0-60"><a id="__codelineno-0-60" name="__codelineno-0-60"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-61"><a id="__codelineno-0-61" name="__codelineno-0-61"></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">Chain</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-62"><a id="__codelineno-0-62" name="__codelineno-0-62"></a>
|
|||
|
</span><span id="__span-0-63"><a id="__codelineno-0-63" name="__codelineno-0-63"></a> <span class="k">if</span> <span class="p">(</span><span class="n">parent</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">ContextModule</span><span class="p">):</span>
|
|||
|
</span><span id="__span-0-64"><a id="__codelineno-0-64" name="__codelineno-0-64"></a> <span class="n">parent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">parent</span>
|
|||
|
</span><span id="__span-0-65"><a id="__codelineno-0-65" name="__codelineno-0-65"></a> <span class="k">if</span> <span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-66"><a id="__codelineno-0-66" name="__codelineno-0-66"></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">Chain</span><span class="p">),</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="si">}</span><span class="s2"> has invalid parent </span><span class="si">{</span><span class="n">parent</span><span class="si">}</span><span class="s2">"</span>
|
|||
|
</span><span id="__span-0-67"><a id="__codelineno-0-67" name="__codelineno-0-67"></a>
|
|||
|
</span><span id="__span-0-68"><a id="__codelineno-0-68" name="__codelineno-0-68"></a> <span class="n">target_parent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">find_parent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-69"><a id="__codelineno-0-69" name="__codelineno-0-69"></a>
|
|||
|
</span><span id="__span-0-70"><a id="__codelineno-0-70" name="__codelineno-0-70"></a> <span class="k">if</span> <span class="n">parent</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-71"><a id="__codelineno-0-71" name="__codelineno-0-71"></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">ContextModule</span><span class="p">):</span>
|
|||
|
</span><span id="__span-0-72"><a id="__codelineno-0-72" name="__codelineno-0-72"></a> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">_set_parent</span><span class="p">(</span><span class="n">target_parent</span><span class="p">)</span> <span class="c1"># type: ignore[reportPrivateUsage]</span>
|
|||
|
</span><span id="__span-0-73"><a id="__codelineno-0-73" name="__codelineno-0-73"></a> <span class="k">return</span> <span class="bp">self</span>
|
|||
|
</span><span id="__span-0-74"><a id="__codelineno-0-74" name="__codelineno-0-74"></a>
|
|||
|
</span><span id="__span-0-75"><a id="__codelineno-0-75" name="__codelineno-0-75"></a> <span class="c1"># In general, `true_parent` is `parent`. We do this to support multiple adaptation,</span>
|
|||
|
</span><span id="__span-0-76"><a id="__codelineno-0-76" name="__codelineno-0-76"></a> <span class="c1"># i.e. initializing two adapters before injecting them.</span>
|
|||
|
</span><span id="__span-0-77"><a id="__codelineno-0-77" name="__codelineno-0-77"></a> <span class="n">true_parent</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">ensure_find_parent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-78"><a id="__codelineno-0-78" name="__codelineno-0-78"></a> <span class="n">true_parent</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-79"><a id="__codelineno-0-79" name="__codelineno-0-79"></a> <span class="n">old_module</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-80"><a id="__codelineno-0-80" name="__codelineno-0-80"></a> <span class="n">new_module</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-81"><a id="__codelineno-0-81" name="__codelineno-0-81"></a> <span class="n">old_module_parent</span><span class="o">=</span><span class="n">target_parent</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-82"><a id="__codelineno-0-82" name="__codelineno-0-82"></a> <span class="p">)</span>
|
|||
|
</span><span id="__span-0-83"><a id="__codelineno-0-83" name="__codelineno-0-83"></a> <span class="k">return</span> <span class="bp">self</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Adapter.setup_adapter" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">setup_adapter</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Adapter.setup_adapter" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">setup_adapter</span><span class="p">(</span><span class="n">target</span><span class="p">:</span> <span class="n"><span title="refiners.fluxion.adapters.adapter.T">T</span></span><span class="p">)</span> <span class="o">-></span> <span class="n"><a class="autorefs autorefs-external" title="typing.Iterator" href="https://docs.python.org/3/library/typing.html#typing.Iterator">Iterator</a></span><span class="p">[</span><span class="kc">None</span><span class="p">]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Setup the adapter.</p>
|
|||
|
<p>This method should be called by the constructor of the adapter.
|
|||
|
It sets the target of the adapter and ensures that the adapter
|
|||
|
is not a submodule of the target.</p>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>target</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><span title="refiners.fluxion.adapters.adapter.T">T</span></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The target of the adapter.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/adapter.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-29">29</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-30">30</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-31">31</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-32">32</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-33">33</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-34">34</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-35">35</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-36">36</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-37">37</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-38">38</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-39">39</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-40">40</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-41">41</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-42">42</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-43">43</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-44">44</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-45">45</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-46">46</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-47">47</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-48">48</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-49">49</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-50">50</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-51">51</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-29"><a id="__codelineno-0-29" name="__codelineno-0-29"></a><span class="nd">@contextlib</span><span class="o">.</span><span class="n">contextmanager</span>
|
|||
|
</span><span id="__span-0-30"><a id="__codelineno-0-30" name="__codelineno-0-30"></a><span class="k">def</span> <span class="nf">setup_adapter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="n">Iterator</span><span class="p">[</span><span class="kc">None</span><span class="p">]:</span>
|
|||
|
</span><span id="__span-0-31"><a id="__codelineno-0-31" name="__codelineno-0-31"></a><span class="w"> </span><span class="sd">"""Setup the adapter.</span>
|
|||
|
</span><span id="__span-0-32"><a id="__codelineno-0-32" name="__codelineno-0-32"></a>
|
|||
|
</span><span id="__span-0-33"><a id="__codelineno-0-33" name="__codelineno-0-33"></a><span class="sd"> This method should be called by the constructor of the adapter.</span>
|
|||
|
</span><span id="__span-0-34"><a id="__codelineno-0-34" name="__codelineno-0-34"></a><span class="sd"> It sets the target of the adapter and ensures that the adapter</span>
|
|||
|
</span><span id="__span-0-35"><a id="__codelineno-0-35" name="__codelineno-0-35"></a><span class="sd"> is not a submodule of the target.</span>
|
|||
|
</span><span id="__span-0-36"><a id="__codelineno-0-36" name="__codelineno-0-36"></a>
|
|||
|
</span><span id="__span-0-37"><a id="__codelineno-0-37" name="__codelineno-0-37"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-38"><a id="__codelineno-0-38" name="__codelineno-0-38"></a><span class="sd"> target: The target of the adapter.</span>
|
|||
|
</span><span id="__span-0-39"><a id="__codelineno-0-39" name="__codelineno-0-39"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-40"><a id="__codelineno-0-40" name="__codelineno-0-40"></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">Chain</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-41"><a id="__codelineno-0-41" name="__codelineno-0-41"></a> <span class="k">assert</span> <span class="p">(</span><span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"_modules"</span><span class="p">))</span> <span class="ow">or</span> <span class="p">(</span>
|
|||
|
</span><span id="__span-0-42"><a id="__codelineno-0-42" name="__codelineno-0-42"></a> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span>
|
|||
|
</span><span id="__span-0-43"><a id="__codelineno-0-43" name="__codelineno-0-43"></a> <span class="p">),</span> <span class="s2">"Call the Chain constructor in the setup_adapter context."</span>
|
|||
|
</span><span id="__span-0-44"><a id="__codelineno-0-44" name="__codelineno-0-44"></a> <span class="bp">self</span><span class="o">.</span><span class="n">_target</span> <span class="o">=</span> <span class="p">[</span><span class="n">target</span><span class="p">]</span>
|
|||
|
</span><span id="__span-0-45"><a id="__codelineno-0-45" name="__codelineno-0-45"></a>
|
|||
|
</span><span id="__span-0-46"><a id="__codelineno-0-46" name="__codelineno-0-46"></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">target</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">ContextModule</span><span class="p">):</span>
|
|||
|
</span><span id="__span-0-47"><a id="__codelineno-0-47" name="__codelineno-0-47"></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">target</span><span class="p">,</span> <span class="n">fl</span><span class="o">.</span><span class="n">ContextModule</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-48"><a id="__codelineno-0-48" name="__codelineno-0-48"></a> <span class="k">with</span> <span class="n">target</span><span class="o">.</span><span class="n">no_parent_refresh</span><span class="p">():</span>
|
|||
|
</span><span id="__span-0-49"><a id="__codelineno-0-49" name="__codelineno-0-49"></a> <span class="k">yield</span>
|
|||
|
</span><span id="__span-0-50"><a id="__codelineno-0-50" name="__codelineno-0-50"></a> <span class="k">else</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-51"><a id="__codelineno-0-51" name="__codelineno-0-51"></a> <span class="k">yield</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-class">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h2 id="refiners.fluxion.adapters.Conv2dLora" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">Conv2dLora</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Conv2dLora" class="headerlink" title="Permanent link">¶</a></h2>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">Conv2dLora</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">name</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a> <span class="n">in_channels</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a> <span class="n">out_channels</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a> <span class="n">rank</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a> <span class="n">scale</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a> <span class="n">kernel_size</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-9"><a id="__codelineno-0-9" name="__codelineno-0-9" href="#__codelineno-0-9"></a> <span class="n">stride</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-10"><a id="__codelineno-0-10" name="__codelineno-0-10" href="#__codelineno-0-10"></a> <span class="n">padding</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-11"><a id="__codelineno-0-11" name="__codelineno-0-11" href="#__codelineno-0-11"></a> <span class="n">device</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a></span> <span class="o">|</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-12"><a id="__codelineno-0-12" name="__codelineno-0-12" href="#__codelineno-0-12"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-13"><a id="__codelineno-0-13" name="__codelineno-0-13" href="#__codelineno-0-13"></a><span class="p">)</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
<p class="doc doc-class-bases">
|
|||
|
Bases: <code><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a>[<a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Conv2d" href="../layers/#refiners.fluxion.layers.Conv2d">Conv2d</a>]</code></p>
|
|||
|
|
|||
|
|
|||
|
<p>Low-Rank Adaptation (LoRA) layer for 2D convolutional layers.</p>
|
|||
|
<p>This layer uses two <a class="autorefs autorefs-internal" href="../layers/#refiners.fluxion.layers.Conv2d"><code>Conv2d</code></a> layers as its down and up layers.</p>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>name</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The name of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>in_channels</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The number of input channels.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>out_channels</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The number of output channels.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>rank</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The rank of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>16</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>scale</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The scale of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1.0</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>kernel_size</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a>, <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a>]</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The kernel size of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>(1, 3)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>stride</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a>, <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a>]</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The stride of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>(1, 1)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>padding</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a>, <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a>]</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The padding of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>(0, 1)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>device</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a> | <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The device of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>dtype</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The dtype of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-275">275</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-276">276</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-277">277</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-278">278</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-279">279</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-280">280</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-281">281</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-282">282</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-283">283</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-284">284</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-285">285</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-286">286</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-287">287</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-288">288</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-289">289</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-290">290</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-291">291</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-292">292</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-293">293</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-294">294</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-295">295</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-296">296</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-297">297</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-298">298</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-299">299</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-300">300</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-301">301</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-302">302</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-303">303</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-304">304</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-305">305</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-306">306</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-307">307</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-308">308</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-309">309</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-310">310</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-311">311</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-312">312</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-313">313</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-314">314</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-315">315</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-275"><a id="__codelineno-0-275" name="__codelineno-0-275"></a><span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-276"><a id="__codelineno-0-276" name="__codelineno-0-276"></a> <span class="bp">self</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-277"><a id="__codelineno-0-277" name="__codelineno-0-277"></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-278"><a id="__codelineno-0-278" name="__codelineno-0-278"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-279"><a id="__codelineno-0-279" name="__codelineno-0-279"></a> <span class="n">in_channels</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-280"><a id="__codelineno-0-280" name="__codelineno-0-280"></a> <span class="n">out_channels</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-281"><a id="__codelineno-0-281" name="__codelineno-0-281"></a> <span class="n">rank</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-282"><a id="__codelineno-0-282" name="__codelineno-0-282"></a> <span class="n">scale</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-283"><a id="__codelineno-0-283" name="__codelineno-0-283"></a> <span class="n">kernel_size</span><span class="p">:</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-284"><a id="__codelineno-0-284" name="__codelineno-0-284"></a> <span class="n">stride</span><span class="p">:</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-285"><a id="__codelineno-0-285" name="__codelineno-0-285"></a> <span class="n">padding</span><span class="p">:</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-286"><a id="__codelineno-0-286" name="__codelineno-0-286"></a> <span class="n">device</span><span class="p">:</span> <span class="n">Device</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-287"><a id="__codelineno-0-287" name="__codelineno-0-287"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n">DType</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-288"><a id="__codelineno-0-288" name="__codelineno-0-288"></a><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-289"><a id="__codelineno-0-289" name="__codelineno-0-289"></a><span class="w"> </span><span class="sd">"""Initialize the LoRA layer.</span>
|
|||
|
</span><span id="__span-0-290"><a id="__codelineno-0-290" name="__codelineno-0-290"></a>
|
|||
|
</span><span id="__span-0-291"><a id="__codelineno-0-291" name="__codelineno-0-291"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-292"><a id="__codelineno-0-292" name="__codelineno-0-292"></a><span class="sd"> name: The name of the LoRA.</span>
|
|||
|
</span><span id="__span-0-293"><a id="__codelineno-0-293" name="__codelineno-0-293"></a><span class="sd"> in_channels: The number of input channels.</span>
|
|||
|
</span><span id="__span-0-294"><a id="__codelineno-0-294" name="__codelineno-0-294"></a><span class="sd"> out_channels: The number of output channels.</span>
|
|||
|
</span><span id="__span-0-295"><a id="__codelineno-0-295" name="__codelineno-0-295"></a><span class="sd"> rank: The rank of the LoRA.</span>
|
|||
|
</span><span id="__span-0-296"><a id="__codelineno-0-296" name="__codelineno-0-296"></a><span class="sd"> scale: The scale of the LoRA.</span>
|
|||
|
</span><span id="__span-0-297"><a id="__codelineno-0-297" name="__codelineno-0-297"></a><span class="sd"> kernel_size: The kernel size of the LoRA.</span>
|
|||
|
</span><span id="__span-0-298"><a id="__codelineno-0-298" name="__codelineno-0-298"></a><span class="sd"> stride: The stride of the LoRA.</span>
|
|||
|
</span><span id="__span-0-299"><a id="__codelineno-0-299" name="__codelineno-0-299"></a><span class="sd"> padding: The padding of the LoRA.</span>
|
|||
|
</span><span id="__span-0-300"><a id="__codelineno-0-300" name="__codelineno-0-300"></a><span class="sd"> device: The device of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-301"><a id="__codelineno-0-301" name="__codelineno-0-301"></a><span class="sd"> dtype: The dtype of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-302"><a id="__codelineno-0-302" name="__codelineno-0-302"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-303"><a id="__codelineno-0-303" name="__codelineno-0-303"></a> <span class="bp">self</span><span class="o">.</span><span class="n">in_channels</span> <span class="o">=</span> <span class="n">in_channels</span>
|
|||
|
</span><span id="__span-0-304"><a id="__codelineno-0-304" name="__codelineno-0-304"></a> <span class="bp">self</span><span class="o">.</span><span class="n">out_channels</span> <span class="o">=</span> <span class="n">out_channels</span>
|
|||
|
</span><span id="__span-0-305"><a id="__codelineno-0-305" name="__codelineno-0-305"></a> <span class="bp">self</span><span class="o">.</span><span class="n">kernel_size</span> <span class="o">=</span> <span class="n">kernel_size</span>
|
|||
|
</span><span id="__span-0-306"><a id="__codelineno-0-306" name="__codelineno-0-306"></a> <span class="bp">self</span><span class="o">.</span><span class="n">stride</span> <span class="o">=</span> <span class="n">stride</span>
|
|||
|
</span><span id="__span-0-307"><a id="__codelineno-0-307" name="__codelineno-0-307"></a> <span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">=</span> <span class="n">padding</span>
|
|||
|
</span><span id="__span-0-308"><a id="__codelineno-0-308" name="__codelineno-0-308"></a>
|
|||
|
</span><span id="__span-0-309"><a id="__codelineno-0-309" name="__codelineno-0-309"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-310"><a id="__codelineno-0-310" name="__codelineno-0-310"></a> <span class="n">name</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-311"><a id="__codelineno-0-311" name="__codelineno-0-311"></a> <span class="n">rank</span><span class="o">=</span><span class="n">rank</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-312"><a id="__codelineno-0-312" name="__codelineno-0-312"></a> <span class="n">scale</span><span class="o">=</span><span class="n">scale</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-313"><a id="__codelineno-0-313" name="__codelineno-0-313"></a> <span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-314"><a id="__codelineno-0-314" name="__codelineno-0-314"></a> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-315"><a id="__codelineno-0-315" name="__codelineno-0-315"></a> <span class="p">)</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-children">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-class">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h2 id="refiners.fluxion.adapters.LinearLora" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">LinearLora</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LinearLora" class="headerlink" title="Permanent link">¶</a></h2>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">LinearLora</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">name</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a> <span class="n">in_features</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a> <span class="n">out_features</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a> <span class="n">rank</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a> <span class="n">scale</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a> <span class="n">device</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a></span> <span class="o">|</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-9"><a id="__codelineno-0-9" name="__codelineno-0-9" href="#__codelineno-0-9"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-10"><a id="__codelineno-0-10" name="__codelineno-0-10" href="#__codelineno-0-10"></a><span class="p">)</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
<p class="doc doc-class-bases">
|
|||
|
Bases: <code><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a>[<a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Linear" href="../layers/#refiners.fluxion.layers.Linear">Linear</a>]</code></p>
|
|||
|
|
|||
|
|
|||
|
<p>Low-Rank Adaptation (LoRA) layer for linear layers.</p>
|
|||
|
<p>This layer uses two <a class="autorefs autorefs-internal" href="../layers/#refiners.fluxion.layers.Linear"><code>Linear</code></a> layers as its down and up layers.</p>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>name</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The name of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>in_features</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The number of input features.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>out_features</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The number of output features.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>rank</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The rank of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>16</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>scale</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The scale of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1.0</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>device</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a> | <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The device of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>dtype</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The dtype of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-187">187</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-188">188</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-189">189</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-190">190</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-191">191</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-192">192</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-193">193</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-194">194</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-195">195</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-196">196</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-197">197</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-198">198</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-199">199</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-200">200</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-201">201</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-202">202</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-203">203</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-204">204</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-205">205</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-206">206</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-207">207</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-208">208</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-209">209</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-210">210</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-211">211</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-212">212</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-213">213</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-214">214</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-215">215</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-216">216</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-217">217</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-218">218</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-187"><a id="__codelineno-0-187" name="__codelineno-0-187"></a><span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-188"><a id="__codelineno-0-188" name="__codelineno-0-188"></a> <span class="bp">self</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-189"><a id="__codelineno-0-189" name="__codelineno-0-189"></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-190"><a id="__codelineno-0-190" name="__codelineno-0-190"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-191"><a id="__codelineno-0-191" name="__codelineno-0-191"></a> <span class="n">in_features</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-192"><a id="__codelineno-0-192" name="__codelineno-0-192"></a> <span class="n">out_features</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-193"><a id="__codelineno-0-193" name="__codelineno-0-193"></a> <span class="n">rank</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-194"><a id="__codelineno-0-194" name="__codelineno-0-194"></a> <span class="n">scale</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-195"><a id="__codelineno-0-195" name="__codelineno-0-195"></a> <span class="n">device</span><span class="p">:</span> <span class="n">Device</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-196"><a id="__codelineno-0-196" name="__codelineno-0-196"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n">DType</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-197"><a id="__codelineno-0-197" name="__codelineno-0-197"></a><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-198"><a id="__codelineno-0-198" name="__codelineno-0-198"></a><span class="w"> </span><span class="sd">"""Initialize the LoRA layer.</span>
|
|||
|
</span><span id="__span-0-199"><a id="__codelineno-0-199" name="__codelineno-0-199"></a>
|
|||
|
</span><span id="__span-0-200"><a id="__codelineno-0-200" name="__codelineno-0-200"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-201"><a id="__codelineno-0-201" name="__codelineno-0-201"></a><span class="sd"> name: The name of the LoRA.</span>
|
|||
|
</span><span id="__span-0-202"><a id="__codelineno-0-202" name="__codelineno-0-202"></a><span class="sd"> in_features: The number of input features.</span>
|
|||
|
</span><span id="__span-0-203"><a id="__codelineno-0-203" name="__codelineno-0-203"></a><span class="sd"> out_features: The number of output features.</span>
|
|||
|
</span><span id="__span-0-204"><a id="__codelineno-0-204" name="__codelineno-0-204"></a><span class="sd"> rank: The rank of the LoRA.</span>
|
|||
|
</span><span id="__span-0-205"><a id="__codelineno-0-205" name="__codelineno-0-205"></a><span class="sd"> scale: The scale of the LoRA.</span>
|
|||
|
</span><span id="__span-0-206"><a id="__codelineno-0-206" name="__codelineno-0-206"></a><span class="sd"> device: The device of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-207"><a id="__codelineno-0-207" name="__codelineno-0-207"></a><span class="sd"> dtype: The dtype of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-208"><a id="__codelineno-0-208" name="__codelineno-0-208"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-209"><a id="__codelineno-0-209" name="__codelineno-0-209"></a> <span class="bp">self</span><span class="o">.</span><span class="n">in_features</span> <span class="o">=</span> <span class="n">in_features</span>
|
|||
|
</span><span id="__span-0-210"><a id="__codelineno-0-210" name="__codelineno-0-210"></a> <span class="bp">self</span><span class="o">.</span><span class="n">out_features</span> <span class="o">=</span> <span class="n">out_features</span>
|
|||
|
</span><span id="__span-0-211"><a id="__codelineno-0-211" name="__codelineno-0-211"></a>
|
|||
|
</span><span id="__span-0-212"><a id="__codelineno-0-212" name="__codelineno-0-212"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-213"><a id="__codelineno-0-213" name="__codelineno-0-213"></a> <span class="n">name</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-214"><a id="__codelineno-0-214" name="__codelineno-0-214"></a> <span class="n">rank</span><span class="o">=</span><span class="n">rank</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-215"><a id="__codelineno-0-215" name="__codelineno-0-215"></a> <span class="n">scale</span><span class="o">=</span><span class="n">scale</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-216"><a id="__codelineno-0-216" name="__codelineno-0-216"></a> <span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-217"><a id="__codelineno-0-217" name="__codelineno-0-217"></a> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-218"><a id="__codelineno-0-218" name="__codelineno-0-218"></a> <span class="p">)</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-children">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-class">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h2 id="refiners.fluxion.adapters.Lora" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">Lora</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora" class="headerlink" title="Permanent link">¶</a></h2>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">Lora</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">name</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a> <span class="n">rank</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a> <span class="n">scale</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a> <span class="n">device</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a></span> <span class="o">|</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a><span class="p">)</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
<p class="doc doc-class-bases">
|
|||
|
Bases: <code><a class="autorefs autorefs-external" title="typing.Generic" href="https://docs.python.org/3/library/typing.html#typing.Generic">Generic</a>[<span title="refiners.fluxion.adapters.lora.T">T</span>]</code>, <code><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Chain" href="../layers/#refiners.fluxion.layers.Chain">Chain</a></code>, <code><a class="autorefs autorefs-external" title="abc.ABC" href="https://docs.python.org/3/library/abc.html#abc.ABC">ABC</a></code></p>
|
|||
|
|
|||
|
|
|||
|
<p>Low-Rank Adaptation (LoRA) layer.</p>
|
|||
|
<p>This layer's purpose is to approximate a given layer by two smaller layers:
|
|||
|
the <a class="autorefs autorefs-internal" href="#refiners.fluxion.adapters.Lora.down"><code>down</code></a> layer (aka A) and the <a class="autorefs autorefs-internal" href="#refiners.fluxion.adapters.Lora.up"><code>up</code></a> layer (aka B).
|
|||
|
See <a href="https://arxiv.org/abs/2106.09685">[ arXiv:2106.09685] LoRA: Low-Rank Adaptation of Large Language Models</a> for more details.</p>
|
|||
|
|
|||
|
|
|||
|
<details class="note" open>
|
|||
|
<summary>Note</summary>
|
|||
|
<p>This layer is not meant to be used directly.
|
|||
|
Instead, use one of its subclasses:</p>
|
|||
|
<ul>
|
|||
|
<li><a class="autorefs autorefs-internal" href="#refiners.fluxion.adapters.LinearLora"><code>LinearLora</code></a></li>
|
|||
|
<li><a class="autorefs autorefs-internal" href="#refiners.fluxion.adapters.Conv2dLora"><code>Conv2dLora</code></a></li>
|
|||
|
</ul>
|
|||
|
</details>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>name</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The name of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>rank</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The rank of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>16</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>scale</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The scale of the LoRA.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1.0</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>device</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a> | <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The device of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>dtype</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The dtype of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-29">29</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-30">30</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-31">31</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-32">32</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-33">33</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-34">34</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-35">35</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-36">36</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-37">37</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-38">38</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-39">39</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-40">40</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-41">41</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-42">42</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-43">43</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-44">44</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-45">45</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-46">46</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-47">47</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-48">48</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-49">49</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-50">50</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-51">51</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-52">52</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-53">53</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-54">54</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-55">55</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-29"><a id="__codelineno-0-29" name="__codelineno-0-29"></a><span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-30"><a id="__codelineno-0-30" name="__codelineno-0-30"></a> <span class="bp">self</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-31"><a id="__codelineno-0-31" name="__codelineno-0-31"></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-32"><a id="__codelineno-0-32" name="__codelineno-0-32"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-33"><a id="__codelineno-0-33" name="__codelineno-0-33"></a> <span class="n">rank</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-34"><a id="__codelineno-0-34" name="__codelineno-0-34"></a> <span class="n">scale</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-35"><a id="__codelineno-0-35" name="__codelineno-0-35"></a> <span class="n">device</span><span class="p">:</span> <span class="n">Device</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-36"><a id="__codelineno-0-36" name="__codelineno-0-36"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n">DType</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-37"><a id="__codelineno-0-37" name="__codelineno-0-37"></a><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-38"><a id="__codelineno-0-38" name="__codelineno-0-38"></a><span class="w"> </span><span class="sd">"""Initialize the LoRA layer.</span>
|
|||
|
</span><span id="__span-0-39"><a id="__codelineno-0-39" name="__codelineno-0-39"></a>
|
|||
|
</span><span id="__span-0-40"><a id="__codelineno-0-40" name="__codelineno-0-40"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-41"><a id="__codelineno-0-41" name="__codelineno-0-41"></a><span class="sd"> name: The name of the LoRA.</span>
|
|||
|
</span><span id="__span-0-42"><a id="__codelineno-0-42" name="__codelineno-0-42"></a><span class="sd"> rank: The rank of the LoRA.</span>
|
|||
|
</span><span id="__span-0-43"><a id="__codelineno-0-43" name="__codelineno-0-43"></a><span class="sd"> scale: The scale of the LoRA.</span>
|
|||
|
</span><span id="__span-0-44"><a id="__codelineno-0-44" name="__codelineno-0-44"></a><span class="sd"> device: The device of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-45"><a id="__codelineno-0-45" name="__codelineno-0-45"></a><span class="sd"> dtype: The dtype of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-46"><a id="__codelineno-0-46" name="__codelineno-0-46"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-47"><a id="__codelineno-0-47" name="__codelineno-0-47"></a> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
|
|||
|
</span><span id="__span-0-48"><a id="__codelineno-0-48" name="__codelineno-0-48"></a> <span class="bp">self</span><span class="o">.</span><span class="n">_rank</span> <span class="o">=</span> <span class="n">rank</span>
|
|||
|
</span><span id="__span-0-49"><a id="__codelineno-0-49" name="__codelineno-0-49"></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scale</span> <span class="o">=</span> <span class="n">scale</span>
|
|||
|
</span><span id="__span-0-50"><a id="__codelineno-0-50" name="__codelineno-0-50"></a>
|
|||
|
</span><span id="__span-0-51"><a id="__codelineno-0-51" name="__codelineno-0-51"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-52"><a id="__codelineno-0-52" name="__codelineno-0-52"></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">lora_layers</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-53"><a id="__codelineno-0-53" name="__codelineno-0-53"></a> <span class="n">fl</span><span class="o">.</span><span class="n">Multiply</span><span class="p">(</span><span class="n">scale</span><span class="p">),</span>
|
|||
|
</span><span id="__span-0-54"><a id="__codelineno-0-54" name="__codelineno-0-54"></a> <span class="p">)</span>
|
|||
|
</span><span id="__span-0-55"><a id="__codelineno-0-55" name="__codelineno-0-55"></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset_parameters</span><span class="p">()</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-children">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.down" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">down</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.down" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">down</span><span class="p">:</span> <span class="n"><span title="refiners.fluxion.adapters.lora.T">T</span></span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The down layer.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.rank" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">rank</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.rank" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">rank</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#int">int</a></span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The rank of the low-rank approximation.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.scale" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">scale</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
<small class="doc doc-label doc-label-writable"><code>writable</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.scale" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">scale</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The scale of the low-rank approximation.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.up" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">up</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.up" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">up</span><span class="p">:</span> <span class="n"><span title="refiners.fluxion.adapters.lora.T">T</span></span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The up layer.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.from_dict" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">from_dict</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-classmethod"><code>classmethod</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.from_dict" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">from_dict</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">name</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="n">state_dict</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#dict">dict</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-external" title="torch.Tensor" href="https://pytorch.org/docs/main/tensors.html#torch.Tensor">Tensor</a></span><span class="p">]</span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="p">)</span> <span class="o">-></span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#dict">dict</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">]]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Create a dictionary of LoRA layers from a state dict.</p>
|
|||
|
<p>Expects the state dict to be a succession of down and up weights.</p>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-117">117</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-118">118</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-119">119</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-120">120</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-121">121</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-122">122</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-123">123</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-124">124</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-125">125</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-126">126</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-127">127</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-128">128</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-129">129</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-130">130</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-131">131</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-117"><a id="__codelineno-0-117" name="__codelineno-0-117"></a><span class="nd">@classmethod</span>
|
|||
|
</span><span id="__span-0-118"><a id="__codelineno-0-118" name="__codelineno-0-118"></a><span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="n">state_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Tensor</span><span class="p">])</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="s2">"Lora[Any]"</span><span class="p">]:</span>
|
|||
|
</span><span id="__span-0-119"><a id="__codelineno-0-119" name="__codelineno-0-119"></a><span class="w"> </span><span class="sd">"""</span>
|
|||
|
</span><span id="__span-0-120"><a id="__codelineno-0-120" name="__codelineno-0-120"></a><span class="sd"> Create a dictionary of LoRA layers from a state dict.</span>
|
|||
|
</span><span id="__span-0-121"><a id="__codelineno-0-121" name="__codelineno-0-121"></a>
|
|||
|
</span><span id="__span-0-122"><a id="__codelineno-0-122" name="__codelineno-0-122"></a><span class="sd"> Expects the state dict to be a succession of down and up weights.</span>
|
|||
|
</span><span id="__span-0-123"><a id="__codelineno-0-123" name="__codelineno-0-123"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-124"><a id="__codelineno-0-124" name="__codelineno-0-124"></a> <span class="n">state_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">state_dict</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="s2">".weight"</span> <span class="ow">in</span> <span class="n">k</span><span class="p">}</span>
|
|||
|
</span><span id="__span-0-125"><a id="__codelineno-0-125" name="__codelineno-0-125"></a> <span class="n">loras</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Lora</span><span class="p">[</span><span class="n">Any</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
|
|||
|
</span><span id="__span-0-126"><a id="__codelineno-0-126" name="__codelineno-0-126"></a> <span class="k">for</span> <span class="n">down_key</span><span class="p">,</span> <span class="n">down_tensor</span><span class="p">,</span> <span class="n">up_tensor</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-127"><a id="__codelineno-0-127" name="__codelineno-0-127"></a> <span class="nb">list</span><span class="p">(</span><span class="n">state_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">())[::</span><span class="mi">2</span><span class="p">],</span> <span class="nb">list</span><span class="p">(</span><span class="n">state_dict</span><span class="o">.</span><span class="n">values</span><span class="p">())[::</span><span class="mi">2</span><span class="p">],</span> <span class="nb">list</span><span class="p">(</span><span class="n">state_dict</span><span class="o">.</span><span class="n">values</span><span class="p">())[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
|
|||
|
</span><span id="__span-0-128"><a id="__codelineno-0-128" name="__codelineno-0-128"></a> <span class="p">):</span>
|
|||
|
</span><span id="__span-0-129"><a id="__codelineno-0-129" name="__codelineno-0-129"></a> <span class="n">key</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">down_key</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span>
|
|||
|
</span><span id="__span-0-130"><a id="__codelineno-0-130" name="__codelineno-0-130"></a> <span class="n">loras</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_weights</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">down</span><span class="o">=</span><span class="n">down_tensor</span><span class="p">,</span> <span class="n">up</span><span class="o">=</span><span class="n">up_tensor</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-131"><a id="__codelineno-0-131" name="__codelineno-0-131"></a> <span class="k">return</span> <span class="n">loras</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.load_weights" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">load_weights</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.load_weights" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">load_weights</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">down_weight</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.Tensor" href="https://pytorch.org/docs/main/tensors.html#torch.Tensor">Tensor</a></span><span class="p">,</span> <span class="n">up_weight</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.Tensor" href="https://pytorch.org/docs/main/tensors.html#torch.Tensor">Tensor</a></span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Load the (pre-trained) weights of the LoRA.</p>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>down_weight</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.Tensor" href="https://pytorch.org/docs/main/tensors.html#torch.Tensor">Tensor</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The down weight.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>up_weight</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.Tensor" href="https://pytorch.org/docs/main/tensors.html#torch.Tensor">Tensor</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The up weight.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-168">168</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-169">169</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-170">170</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-171">171</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-172">172</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-173">173</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-174">174</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-175">175</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-176">176</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-177">177</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-178">178</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-168"><a id="__codelineno-0-168" name="__codelineno-0-168"></a><span class="k">def</span> <span class="nf">load_weights</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">down_weight</span><span class="p">:</span> <span class="n">Tensor</span><span class="p">,</span> <span class="n">up_weight</span><span class="p">:</span> <span class="n">Tensor</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-169"><a id="__codelineno-0-169" name="__codelineno-0-169"></a><span class="w"> </span><span class="sd">"""Load the (pre-trained) weights of the LoRA.</span>
|
|||
|
</span><span id="__span-0-170"><a id="__codelineno-0-170" name="__codelineno-0-170"></a>
|
|||
|
</span><span id="__span-0-171"><a id="__codelineno-0-171" name="__codelineno-0-171"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-172"><a id="__codelineno-0-172" name="__codelineno-0-172"></a><span class="sd"> down_weight: The down weight.</span>
|
|||
|
</span><span id="__span-0-173"><a id="__codelineno-0-173" name="__codelineno-0-173"></a><span class="sd"> up_weight: The up weight.</span>
|
|||
|
</span><span id="__span-0-174"><a id="__codelineno-0-174" name="__codelineno-0-174"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-175"><a id="__codelineno-0-175" name="__codelineno-0-175"></a> <span class="k">assert</span> <span class="n">down_weight</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">down</span><span class="o">.</span><span class="n">weight</span><span class="o">.</span><span class="n">shape</span>
|
|||
|
</span><span id="__span-0-176"><a id="__codelineno-0-176" name="__codelineno-0-176"></a> <span class="k">assert</span> <span class="n">up_weight</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">up</span><span class="o">.</span><span class="n">weight</span><span class="o">.</span><span class="n">shape</span>
|
|||
|
</span><span id="__span-0-177"><a id="__codelineno-0-177" name="__codelineno-0-177"></a> <span class="bp">self</span><span class="o">.</span><span class="n">down</span><span class="o">.</span><span class="n">weight</span> <span class="o">=</span> <span class="n">TorchParameter</span><span class="p">(</span><span class="n">down_weight</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dtype</span><span class="p">))</span>
|
|||
|
</span><span id="__span-0-178"><a id="__codelineno-0-178" name="__codelineno-0-178"></a> <span class="bp">self</span><span class="o">.</span><span class="n">up</span><span class="o">.</span><span class="n">weight</span> <span class="o">=</span> <span class="n">TorchParameter</span><span class="p">(</span><span class="n">up_weight</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dtype</span><span class="p">))</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.lora_layers" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">lora_layers</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.lora_layers" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">lora_layers</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">device</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a></span> <span class="o">|</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a> <span class="n">dtype</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a></span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a><span class="p">)</span> <span class="o">-></span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a></span><span class="p">[</span><span class="n"><span title="refiners.fluxion.adapters.lora.T">T</span></span><span class="p">,</span> <span class="n"><span title="refiners.fluxion.adapters.lora.T">T</span></span><span class="p">]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Create the down and up layers of the LoRA.</p>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>device</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.device" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.device">device</a> | <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The device of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>dtype</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" title="torch.dtype" href="https://pytorch.org/docs/main/tensor_attributes.html#torch.dtype">dtype</a> | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The dtype of the LoRA weights.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-62">62</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-63">63</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-64">64</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-65">65</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-66">66</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-67">67</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-68">68</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-69">69</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-70">70</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-62"><a id="__codelineno-0-62" name="__codelineno-0-62"></a><span class="nd">@abstractmethod</span>
|
|||
|
</span><span id="__span-0-63"><a id="__codelineno-0-63" name="__codelineno-0-63"></a><span class="k">def</span> <span class="nf">lora_layers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">device</span><span class="p">:</span> <span class="n">Device</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="n">DType</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">tuple</span><span class="p">[</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">]:</span>
|
|||
|
</span><span id="__span-0-64"><a id="__codelineno-0-64" name="__codelineno-0-64"></a><span class="w"> </span><span class="sd">"""Create the down and up layers of the LoRA.</span>
|
|||
|
</span><span id="__span-0-65"><a id="__codelineno-0-65" name="__codelineno-0-65"></a>
|
|||
|
</span><span id="__span-0-66"><a id="__codelineno-0-66" name="__codelineno-0-66"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-67"><a id="__codelineno-0-67" name="__codelineno-0-67"></a><span class="sd"> device: The device of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-68"><a id="__codelineno-0-68" name="__codelineno-0-68"></a><span class="sd"> dtype: The dtype of the LoRA weights.</span>
|
|||
|
</span><span id="__span-0-69"><a id="__codelineno-0-69" name="__codelineno-0-69"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-70"><a id="__codelineno-0-70" name="__codelineno-0-70"></a> <span class="o">...</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.Lora.reset_parameters" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">reset_parameters</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.Lora.reset_parameters" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">reset_parameters</span><span class="p">()</span> <span class="o">-></span> <span class="kc">None</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Reset the parameters of up and down layers.</p>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-57">57</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-58">58</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-59">59</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-60">60</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-57"><a id="__codelineno-0-57" name="__codelineno-0-57"></a><span class="k">def</span> <span class="nf">reset_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-58"><a id="__codelineno-0-58" name="__codelineno-0-58"></a><span class="w"> </span><span class="sd">"""Reset the parameters of up and down layers."""</span>
|
|||
|
</span><span id="__span-0-59"><a id="__codelineno-0-59" name="__codelineno-0-59"></a> <span class="n">normal_</span><span class="p">(</span><span class="n">tensor</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">down</span><span class="o">.</span><span class="n">weight</span><span class="p">,</span> <span class="n">std</span><span class="o">=</span><span class="mi">1</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">rank</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-60"><a id="__codelineno-0-60" name="__codelineno-0-60"></a> <span class="n">zeros_</span><span class="p">(</span><span class="n">tensor</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">up</span><span class="o">.</span><span class="n">weight</span><span class="p">)</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-class">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h2 id="refiners.fluxion.adapters.LoraAdapter" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">LoraAdapter</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter" class="headerlink" title="Permanent link">¶</a></h2>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">LoraAdapter</span><span class="p">(</span><span class="n">target</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.WeightedModule" href="../layers/#refiners.fluxion.layers.WeightedModule">WeightedModule</a></span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="o">*</span><span class="n">loras</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">])</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
<p class="doc doc-class-bases">
|
|||
|
Bases: <code><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Sum" href="../layers/#refiners.fluxion.layers.Sum">Sum</a></code>, <code><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.adapter.Adapter" href="#refiners.fluxion.adapters.Adapter">Adapter</a>[<a class="autorefs autorefs-internal" title="refiners.fluxion.layers.WeightedModule" href="../layers/#refiners.fluxion.layers.WeightedModule">WeightedModule</a>]</code></p>
|
|||
|
|
|||
|
|
|||
|
<p>Adapter for LoRA layers.</p>
|
|||
|
<p>This adapter simply sums the target layer with the given LoRA layers.</p>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>target</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.WeightedModule" href="../layers/#refiners.fluxion.layers.WeightedModule">WeightedModule</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The target layer.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>loras</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a>[<a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a>]</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The LoRA layers.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>()</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-389">389</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-390">390</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-391">391</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-392">392</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-393">393</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-394">394</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-395">395</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-396">396</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-397">397</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-389"><a id="__codelineno-0-389" name="__codelineno-0-389"></a><span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span> <span class="n">fl</span><span class="o">.</span><span class="n">WeightedModule</span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="o">*</span><span class="n">loras</span><span class="p">:</span> <span class="n">Lora</span><span class="p">[</span><span class="n">Any</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-390"><a id="__codelineno-0-390" name="__codelineno-0-390"></a><span class="w"> </span><span class="sd">"""Initialize the adapter.</span>
|
|||
|
</span><span id="__span-0-391"><a id="__codelineno-0-391" name="__codelineno-0-391"></a>
|
|||
|
</span><span id="__span-0-392"><a id="__codelineno-0-392" name="__codelineno-0-392"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-393"><a id="__codelineno-0-393" name="__codelineno-0-393"></a><span class="sd"> target: The target layer.</span>
|
|||
|
</span><span id="__span-0-394"><a id="__codelineno-0-394" name="__codelineno-0-394"></a><span class="sd"> loras: The LoRA layers.</span>
|
|||
|
</span><span id="__span-0-395"><a id="__codelineno-0-395" name="__codelineno-0-395"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-396"><a id="__codelineno-0-396" name="__codelineno-0-396"></a> <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">setup_adapter</span><span class="p">(</span><span class="n">target</span><span class="p">):</span>
|
|||
|
</span><span id="__span-0-397"><a id="__codelineno-0-397" name="__codelineno-0-397"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">target</span><span class="p">,</span> <span class="o">*</span><span class="n">loras</span><span class="p">)</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-children">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.LoraAdapter.lora_layers" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">lora_layers</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.lora_layers" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">lora_layers</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" title="typing.Iterator" href="https://docs.python.org/3/library/typing.html#typing.Iterator">Iterator</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">]]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The LoRA layers.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.LoraAdapter.loras" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">loras</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.loras" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">loras</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#dict">dict</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">]]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The LoRA layers indexed by name.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.LoraAdapter.names" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">names</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.names" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">names</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The names of the LoRA layers.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-attribute">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.LoraAdapter.scales" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code> <span class="doc doc-object-name doc-attribute-name">scales</span>
|
|||
|
|
|||
|
|
|||
|
<span class="doc doc-labels">
|
|||
|
<small class="doc doc-label doc-label-property"><code>property</code></small>
|
|||
|
</span>
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.scales" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">scales</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#dict">dict</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#float">float</a></span><span class="p">]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>The scales of the LoRA layers indexed by names.</p>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.LoraAdapter.add_lora" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">add_lora</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.add_lora" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">add_lora</span><span class="p">(</span><span class="n">lora</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Add a LoRA layer to the adapter.</p>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Raises:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/exceptions.html#AssertionError">AssertionError</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>If the adapter already contains a LoRA layer with the same name.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>lora</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a>[<a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a>]</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The LoRA layer to add.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-424">424</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-425">425</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-426">426</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-427">427</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-428">428</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-429">429</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-430">430</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-431">431</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-432">432</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-433">433</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-434">434</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-424"><a id="__codelineno-0-424" name="__codelineno-0-424"></a><span class="k">def</span> <span class="nf">add_lora</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lora</span><span class="p">:</span> <span class="n">Lora</span><span class="p">[</span><span class="n">Any</span><span class="p">],</span> <span class="o">/</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-425"><a id="__codelineno-0-425" name="__codelineno-0-425"></a><span class="w"> </span><span class="sd">"""Add a LoRA layer to the adapter.</span>
|
|||
|
</span><span id="__span-0-426"><a id="__codelineno-0-426" name="__codelineno-0-426"></a>
|
|||
|
</span><span id="__span-0-427"><a id="__codelineno-0-427" name="__codelineno-0-427"></a><span class="sd"> Raises:</span>
|
|||
|
</span><span id="__span-0-428"><a id="__codelineno-0-428" name="__codelineno-0-428"></a><span class="sd"> AssertionError: If the adapter already contains a LoRA layer with the same name.</span>
|
|||
|
</span><span id="__span-0-429"><a id="__codelineno-0-429" name="__codelineno-0-429"></a>
|
|||
|
</span><span id="__span-0-430"><a id="__codelineno-0-430" name="__codelineno-0-430"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-431"><a id="__codelineno-0-431" name="__codelineno-0-431"></a><span class="sd"> lora: The LoRA layer to add.</span>
|
|||
|
</span><span id="__span-0-432"><a id="__codelineno-0-432" name="__codelineno-0-432"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-433"><a id="__codelineno-0-433" name="__codelineno-0-433"></a> <span class="k">assert</span> <span class="n">lora</span><span class="o">.</span><span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">names</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"LoRA layer with name </span><span class="si">{</span><span class="n">lora</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> already exists"</span>
|
|||
|
</span><span id="__span-0-434"><a id="__codelineno-0-434" name="__codelineno-0-434"></a> <span class="bp">self</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lora</span><span class="p">)</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h3 id="refiners.fluxion.adapters.LoraAdapter.remove_lora" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">remove_lora</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.LoraAdapter.remove_lora" class="headerlink" title="Permanent link">¶</a></h3>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">remove_lora</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">)</span> <span class="o">-></span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Remove a LoRA layer from the adapter.</p>
|
|||
|
|
|||
|
|
|||
|
<details class="note" open>
|
|||
|
<summary>Note</summary>
|
|||
|
<p>If the adapter doesn't contain a LoRA layer with the given name, nothing happens and <code>None</code> is returned.</p>
|
|||
|
</details>
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>name</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The name of the LoRA layer to remove.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-436">436</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-437">437</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-438">438</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-439">439</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-440">440</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-441">441</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-442">442</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-443">443</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-444">444</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-445">445</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-446">446</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-447">447</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-448">448</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-436"><a id="__codelineno-0-436" name="__codelineno-0-436"></a><span class="k">def</span> <span class="nf">remove_lora</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">/</span><span class="p">)</span> <span class="o">-></span> <span class="n">Lora</span><span class="p">[</span><span class="n">Any</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-437"><a id="__codelineno-0-437" name="__codelineno-0-437"></a><span class="w"> </span><span class="sd">"""Remove a LoRA layer from the adapter.</span>
|
|||
|
</span><span id="__span-0-438"><a id="__codelineno-0-438" name="__codelineno-0-438"></a>
|
|||
|
</span><span id="__span-0-439"><a id="__codelineno-0-439" name="__codelineno-0-439"></a><span class="sd"> Note:</span>
|
|||
|
</span><span id="__span-0-440"><a id="__codelineno-0-440" name="__codelineno-0-440"></a><span class="sd"> If the adapter doesn't contain a LoRA layer with the given name, nothing happens and `None` is returned.</span>
|
|||
|
</span><span id="__span-0-441"><a id="__codelineno-0-441" name="__codelineno-0-441"></a>
|
|||
|
</span><span id="__span-0-442"><a id="__codelineno-0-442" name="__codelineno-0-442"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-443"><a id="__codelineno-0-443" name="__codelineno-0-443"></a><span class="sd"> name: The name of the LoRA layer to remove.</span>
|
|||
|
</span><span id="__span-0-444"><a id="__codelineno-0-444" name="__codelineno-0-444"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-445"><a id="__codelineno-0-445" name="__codelineno-0-445"></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">names</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-446"><a id="__codelineno-0-446" name="__codelineno-0-446"></a> <span class="n">lora</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">loras</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
|
|||
|
</span><span id="__span-0-447"><a id="__codelineno-0-447" name="__codelineno-0-447"></a> <span class="bp">self</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">lora</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-448"><a id="__codelineno-0-448" name="__codelineno-0-448"></a> <span class="k">return</span> <span class="n">lora</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<div class="doc doc-object doc-function">
|
|||
|
|
|||
|
|
|||
|
<h2 id="refiners.fluxion.adapters.auto_attach_loras" class="doc doc-heading">
|
|||
|
<code class="doc-symbol doc-symbol-heading doc-symbol-function"></code> <span class="doc doc-object-name doc-function-name">auto_attach_loras</span>
|
|||
|
|
|||
|
|
|||
|
<a href="#refiners.fluxion.adapters.auto_attach_loras" class="headerlink" title="Permanent link">¶</a></h2>
|
|||
|
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">auto_attach_loras</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">loras</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#dict">dict</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a></span><span class="p">]],</span>
|
|||
|
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a> <span class="n">target</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Chain" href="../layers/#refiners.fluxion.layers.Chain">Chain</a></span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a> <span class="n">include</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a> <span class="n">exclude</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a> <span class="n">sanity_check</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#bool">bool</a></span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a> <span class="n">debug_map</span><span class="p">:</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">,</span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">]]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-9"><a id="__codelineno-0-9" name="__codelineno-0-9" href="#__codelineno-0-9"></a><span class="p">)</span> <span class="o">-></span> <span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a></span><span class="p">[</span><span class="n"><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a></span><span class="p">]</span>
|
|||
|
</span></code></pre></div>
|
|||
|
|
|||
|
<div class="doc doc-contents ">
|
|||
|
|
|||
|
<p>Auto-attach several LoRA layers to a Chain.</p>
|
|||
|
|
|||
|
|
|||
|
<p><span class="doc-section-title">Parameters:</span></p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>Name</th>
|
|||
|
<th>Type</th>
|
|||
|
<th>Description</th>
|
|||
|
<th>Default</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>loras</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#dict">dict</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a>, <a class="autorefs autorefs-internal" title="refiners.fluxion.adapters.lora.Lora" href="#refiners.fluxion.adapters.Lora">Lora</a>[<a class="autorefs autorefs-external" title="typing.Any" href="https://docs.python.org/3/library/typing.html#typing.Any">Any</a>]]</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>A dictionary of LoRA layers associated to their respective key. The keys are typically
|
|||
|
derived from the state dict and only used for <code>debug_map</code> and the return value.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>target</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-internal" title="refiners.fluxion.layers.Chain" href="../layers/#refiners.fluxion.layers.Chain">Chain</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>The target Chain.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<em>required</em>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>include</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a>] | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>A list of layer names, only layers with such a layer in their ancestors will be considered.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>exclude</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a>] | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>A list of layer names, layers with such a layer in their ancestors will not be considered.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>sanity_check</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#bool">bool</a></code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>Check that LoRAs passed are correctly attached.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>True</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="doc-section-item">
|
|||
|
<td>
|
|||
|
<code>debug_map</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#list">list</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#tuple">tuple</a>[<a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a>, <a class="autorefs autorefs-external" href="https://docs.python.org/3/library/stdtypes.html#str">str</a>]] | None</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<div class="doc-md-description">
|
|||
|
<p>Pass a list to get a debug mapping of key - path pairs of attached points.</p>
|
|||
|
</div>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>None</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
<p>Returns:
|
|||
|
A list of keys of LoRA layers which failed to attach.</p>
|
|||
|
|
|||
|
<details class="quote">
|
|||
|
<summary>Source code in <code>src/refiners/fluxion/adapters/lora.py</code></summary>
|
|||
|
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-479">479</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-480">480</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-481">481</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-482">482</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-483">483</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-484">484</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-485">485</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-486">486</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-487">487</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-488">488</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-489">489</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-490">490</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-491">491</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-492">492</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-493">493</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-494">494</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-495">495</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-496">496</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-497">497</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-498">498</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-499">499</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-500">500</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-501">501</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-502">502</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-503">503</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-504">504</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-505">505</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-506">506</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-507">507</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-508">508</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-509">509</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-510">510</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-511">511</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-512">512</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-513">513</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-514">514</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-515">515</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-516">516</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-517">517</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-518">518</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-519">519</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-520">520</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-521">521</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-522">522</a></span>
|
|||
|
<span class="normal"><a href="#__codelineno-0-523">523</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-479"><a id="__codelineno-0-479" name="__codelineno-0-479"></a><span class="k">def</span> <span class="nf">auto_attach_loras</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-480"><a id="__codelineno-0-480" name="__codelineno-0-480"></a> <span class="n">loras</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Lora</span><span class="p">[</span><span class="n">Any</span><span class="p">]],</span>
|
|||
|
</span><span id="__span-0-481"><a id="__codelineno-0-481" name="__codelineno-0-481"></a> <span class="n">target</span><span class="p">:</span> <span class="n">fl</span><span class="o">.</span><span class="n">Chain</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-482"><a id="__codelineno-0-482" name="__codelineno-0-482"></a> <span class="o">/</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-483"><a id="__codelineno-0-483" name="__codelineno-0-483"></a> <span class="n">include</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-484"><a id="__codelineno-0-484" name="__codelineno-0-484"></a> <span class="n">exclude</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-485"><a id="__codelineno-0-485" name="__codelineno-0-485"></a> <span class="n">sanity_check</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-486"><a id="__codelineno-0-486" name="__codelineno-0-486"></a> <span class="n">debug_map</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
|
|||
|
</span><span id="__span-0-487"><a id="__codelineno-0-487" name="__codelineno-0-487"></a><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
|
|||
|
</span><span id="__span-0-488"><a id="__codelineno-0-488" name="__codelineno-0-488"></a><span class="w"> </span><span class="sd">"""Auto-attach several LoRA layers to a Chain.</span>
|
|||
|
</span><span id="__span-0-489"><a id="__codelineno-0-489" name="__codelineno-0-489"></a>
|
|||
|
</span><span id="__span-0-490"><a id="__codelineno-0-490" name="__codelineno-0-490"></a><span class="sd"> Args:</span>
|
|||
|
</span><span id="__span-0-491"><a id="__codelineno-0-491" name="__codelineno-0-491"></a><span class="sd"> loras: A dictionary of LoRA layers associated to their respective key. The keys are typically</span>
|
|||
|
</span><span id="__span-0-492"><a id="__codelineno-0-492" name="__codelineno-0-492"></a><span class="sd"> derived from the state dict and only used for `debug_map` and the return value.</span>
|
|||
|
</span><span id="__span-0-493"><a id="__codelineno-0-493" name="__codelineno-0-493"></a><span class="sd"> target: The target Chain.</span>
|
|||
|
</span><span id="__span-0-494"><a id="__codelineno-0-494" name="__codelineno-0-494"></a><span class="sd"> include: A list of layer names, only layers with such a layer in their ancestors will be considered.</span>
|
|||
|
</span><span id="__span-0-495"><a id="__codelineno-0-495" name="__codelineno-0-495"></a><span class="sd"> exclude: A list of layer names, layers with such a layer in their ancestors will not be considered.</span>
|
|||
|
</span><span id="__span-0-496"><a id="__codelineno-0-496" name="__codelineno-0-496"></a><span class="sd"> sanity_check: Check that LoRAs passed are correctly attached.</span>
|
|||
|
</span><span id="__span-0-497"><a id="__codelineno-0-497" name="__codelineno-0-497"></a><span class="sd"> debug_map: Pass a list to get a debug mapping of key - path pairs of attached points.</span>
|
|||
|
</span><span id="__span-0-498"><a id="__codelineno-0-498" name="__codelineno-0-498"></a><span class="sd"> Returns:</span>
|
|||
|
</span><span id="__span-0-499"><a id="__codelineno-0-499" name="__codelineno-0-499"></a><span class="sd"> A list of keys of LoRA layers which failed to attach.</span>
|
|||
|
</span><span id="__span-0-500"><a id="__codelineno-0-500" name="__codelineno-0-500"></a><span class="sd"> """</span>
|
|||
|
</span><span id="__span-0-501"><a id="__codelineno-0-501" name="__codelineno-0-501"></a>
|
|||
|
</span><span id="__span-0-502"><a id="__codelineno-0-502" name="__codelineno-0-502"></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sanity_check</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-503"><a id="__codelineno-0-503" name="__codelineno-0-503"></a> <span class="k">return</span> <span class="n">_auto_attach_loras</span><span class="p">(</span><span class="n">loras</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">include</span><span class="o">=</span><span class="n">include</span><span class="p">,</span> <span class="n">exclude</span><span class="o">=</span><span class="n">exclude</span><span class="p">,</span> <span class="n">debug_map</span><span class="o">=</span><span class="n">debug_map</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-504"><a id="__codelineno-0-504" name="__codelineno-0-504"></a>
|
|||
|
</span><span id="__span-0-505"><a id="__codelineno-0-505" name="__codelineno-0-505"></a> <span class="n">loras_copy</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">Lora</span><span class="o">.</span><span class="n">from_weights</span><span class="p">(</span><span class="n">lora</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">lora</span><span class="o">.</span><span class="n">down</span><span class="o">.</span><span class="n">weight</span><span class="p">,</span> <span class="n">lora</span><span class="o">.</span><span class="n">up</span><span class="o">.</span><span class="n">weight</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">lora</span> <span class="ow">in</span> <span class="n">loras</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>
|
|||
|
</span><span id="__span-0-506"><a id="__codelineno-0-506" name="__codelineno-0-506"></a> <span class="n">debug_map_1</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span>
|
|||
|
</span><span id="__span-0-507"><a id="__codelineno-0-507" name="__codelineno-0-507"></a> <span class="n">failed_keys_1</span> <span class="o">=</span> <span class="n">_auto_attach_loras</span><span class="p">(</span><span class="n">loras</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">include</span><span class="o">=</span><span class="n">include</span><span class="p">,</span> <span class="n">exclude</span><span class="o">=</span><span class="n">exclude</span><span class="p">,</span> <span class="n">debug_map</span><span class="o">=</span><span class="n">debug_map_1</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-508"><a id="__codelineno-0-508" name="__codelineno-0-508"></a> <span class="k">if</span> <span class="n">debug_map</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-509"><a id="__codelineno-0-509" name="__codelineno-0-509"></a> <span class="n">debug_map</span> <span class="o">+=</span> <span class="n">debug_map_1</span>
|
|||
|
</span><span id="__span-0-510"><a id="__codelineno-0-510" name="__codelineno-0-510"></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">debug_map_1</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">loras</span><span class="p">)</span> <span class="ow">or</span> <span class="n">failed_keys_1</span><span class="p">:</span>
|
|||
|
</span><span id="__span-0-511"><a id="__codelineno-0-511" name="__codelineno-0-511"></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-512"><a id="__codelineno-0-512" name="__codelineno-0-512"></a> <span class="sa">f</span><span class="s2">"sanity check failed: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">debug_map_1</span><span class="p">)</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">loras</span><span class="p">)</span><span class="si">}</span><span class="s2"> LoRA layers attached, </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">failed_keys_1</span><span class="p">)</span><span class="si">}</span><span class="s2"> failed"</span>
|
|||
|
</span><span id="__span-0-513"><a id="__codelineno-0-513" name="__codelineno-0-513"></a> <span class="p">)</span>
|
|||
|
</span><span id="__span-0-514"><a id="__codelineno-0-514" name="__codelineno-0-514"></a>
|
|||
|
</span><span id="__span-0-515"><a id="__codelineno-0-515" name="__codelineno-0-515"></a> <span class="c1"># Extra sanity check: if we re-run the attach, all layers should fail.</span>
|
|||
|
</span><span id="__span-0-516"><a id="__codelineno-0-516" name="__codelineno-0-516"></a> <span class="n">debug_map_2</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span>
|
|||
|
</span><span id="__span-0-517"><a id="__codelineno-0-517" name="__codelineno-0-517"></a> <span class="n">failed_keys_2</span> <span class="o">=</span> <span class="n">_auto_attach_loras</span><span class="p">(</span><span class="n">loras_copy</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">include</span><span class="o">=</span><span class="n">include</span><span class="p">,</span> <span class="n">exclude</span><span class="o">=</span><span class="n">exclude</span><span class="p">,</span> <span class="n">debug_map</span><span class="o">=</span><span class="n">debug_map_2</span><span class="p">)</span>
|
|||
|
</span><span id="__span-0-518"><a id="__codelineno-0-518" name="__codelineno-0-518"></a> <span class="k">if</span> <span class="n">debug_map_2</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">failed_keys_2</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">loras</span><span class="p">):</span>
|
|||
|
</span><span id="__span-0-519"><a id="__codelineno-0-519" name="__codelineno-0-519"></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
|
|||
|
</span><span id="__span-0-520"><a id="__codelineno-0-520" name="__codelineno-0-520"></a> <span class="sa">f</span><span class="s2">"sanity check failed: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">debug_map_2</span><span class="p">)</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">loras</span><span class="p">)</span><span class="si">}</span><span class="s2"> LoRA layers attached twice, </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">failed_keys_2</span><span class="p">)</span><span class="si">}</span><span class="s2"> skipped"</span>
|
|||
|
</span><span id="__span-0-521"><a id="__codelineno-0-521" name="__codelineno-0-521"></a> <span class="p">)</span>
|
|||
|
</span><span id="__span-0-522"><a id="__codelineno-0-522" name="__codelineno-0-522"></a>
|
|||
|
</span><span id="__span-0-523"><a id="__codelineno-0-523" name="__codelineno-0-523"></a> <span class="k">return</span> <span class="n">failed_keys_1</span>
|
|||
|
</span></code></pre></div></td></tr></table></div>
|
|||
|
</details>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</article>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
|
|||
|
</div>
|
|||
|
|
|||
|
<button type="button" class="md-top md-icon" data-md-component="top" hidden>
|
|||
|
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
|
|||
|
Back to top
|
|||
|
</button>
|
|||
|
|
|||
|
</main>
|
|||
|
|
|||
|
<footer class="md-footer">
|
|||
|
|
|||
|
<div class="md-footer-meta md-typeset">
|
|||
|
<div class="md-footer-meta__inner md-grid">
|
|||
|
<div class="md-copyright">
|
|||
|
|
|||
|
<div class="md-copyright__highlight">
|
|||
|
© Lagon Technologies
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
Made with
|
|||
|
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
|
|||
|
Material for MkDocs
|
|||
|
</a>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="md-social">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<a href="https://discord.gg/mCmjNUVV7d" target="_blank" rel="noopener" title="discord.gg" class="md-social__link">
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M524.531 69.836a1.5 1.5 0 0 0-.764-.7A485 485 0 0 0 404.081 32.03a1.82 1.82 0 0 0-1.923.91 338 338 0 0 0-14.9 30.6 447.9 447.9 0 0 0-134.426 0 310 310 0 0 0-15.135-30.6 1.89 1.89 0 0 0-1.924-.91 483.7 483.7 0 0 0-119.688 37.107 1.7 1.7 0 0 0-.788.676C39.068 183.651 18.186 294.69 28.43 404.354a2.02 2.02 0 0 0 .765 1.375 487.7 487.7 0 0 0 146.825 74.189 1.9 1.9 0 0 0 2.063-.676A348 348 0 0 0 208.12 430.4a1.86 1.86 0 0 0-1.019-2.588 321 321 0 0 1-45.868-21.853 1.885 1.885 0 0 1-.185-3.126 251 251 0 0 0 9.109-7.137 1.82 1.82 0 0 1 1.9-.256c96.229 43.917 200.41 43.917 295.5 0a1.81 1.81 0 0 1 1.924.233 235 235 0 0 0 9.132 7.16 1.884 1.884 0 0 1-.162 3.126 301.4 301.4 0 0 1-45.89 21.83 1.875 1.875 0 0 0-1 2.611 391 391 0 0 0 30.014 48.815 1.86 1.86 0 0 0 2.063.7A486 486 0 0 0 610.7 405.729a1.88 1.88 0 0 0 .765-1.352c12.264-126.783-20.532-236.912-86.934-334.541M222.491 337.58c-28.972 0-52.844-26.587-52.844-59.239s23.409-59.241 52.844-59.241c29.665 0 53.306 26.82 52.843 59.239 0 32.654-23.41 59.241-52.843 59.241m195.38 0c-28.971 0-52.843-26.587-52.843-59.239s23.409-59.241 52.843-59.241c29.667 0 53.307 26.82 52.844 59.239 0 32.654-23.177 59.241-52.844 59.241"/></svg>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<a href="https://github.com/finegrain-ai/refiners" target="_blank" rel="noopener" title="github.com" class="md-social__link">
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<a href="https://twitter.com/finegrain_ai" target="_blank" rel="noopener" title="twitter.com" class="md-social__link">
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253"/></svg>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<a href="https://www.linkedin.com/company/finegrain-ai/" target="_blank" rel="noopener" title="www.linkedin.com" class="md-social__link">
|
|||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3M135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5m282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9z"/></svg>
|
|||
|
</a>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</footer>
|
|||
|
|
|||
|
</div>
|
|||
|
<div class="md-dialog" data-md-component="dialog">
|
|||
|
<div class="md-dialog__inner md-typeset"></div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<script id="__config" type="application/json">{"base": "../../..", "features": ["navigation.tabs", "navigation.sections", "navigation.top", "navigation.tracking", "navigation.expand", "navigation.path", "toc.follow", "navigation.tabs.sticky", "content.code.copy", "announce.dismiss"], "search": "../../../assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
|
|||
|
|
|||
|
|
|||
|
<script src="../../../assets/javascripts/bundle.83f73b43.min.js"></script>
|
|||
|
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|