Buckets:

download
raw
39.3 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Pull request checks&quot;,&quot;local&quot;:&quot;pull-request-checks&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Fixing the CI&quot;,&quot;local&quot;:&quot;fixing-the-ci&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Code quality&quot;,&quot;local&quot;:&quot;code-quality&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Repository consistency&quot;,&quot;local&quot;:&quot;repository-consistency&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Tests&quot;,&quot;local&quot;:&quot;tests&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Test selection&quot;,&quot;local&quot;:&quot;test-selection&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Test job categories&quot;,&quot;local&quot;:&quot;test-job-categories&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Slow tests&quot;,&quot;local&quot;:&quot;slow-tests&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Documentation build&quot;,&quot;local&quot;:&quot;documentation-build&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;# Copied from syntax&quot;,&quot;local&quot;:&quot;-copied-from-syntax&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers/pr_41992/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/entry/start.6ac19d43.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/scheduler.0dad8db1.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/singletons.9505f7e3.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/index.595571e0.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/paths.a2014728.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/entry/app.42da82bd.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/preload-helper.43417560.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/index.855abf52.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/nodes/0.dc15b4bc.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/nodes/637.f1f9b56c.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/CopyLLMTxtMenu.9e1f0f49.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.bf05d4d8.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/IconCopy.ffdeebb6.js">
<link rel="modulepreload" href="/docs/transformers/pr_41992/en/_app/immutable/chunks/CodeBlock.b28b91fa.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Pull request checks&quot;,&quot;local&quot;:&quot;pull-request-checks&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Fixing the CI&quot;,&quot;local&quot;:&quot;fixing-the-ci&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Code quality&quot;,&quot;local&quot;:&quot;code-quality&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Repository consistency&quot;,&quot;local&quot;:&quot;repository-consistency&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Tests&quot;,&quot;local&quot;:&quot;tests&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Test selection&quot;,&quot;local&quot;:&quot;test-selection&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Test job categories&quot;,&quot;local&quot;:&quot;test-job-categories&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Slow tests&quot;,&quot;local&quot;:&quot;slow-tests&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Documentation build&quot;,&quot;local&quot;:&quot;documentation-build&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;# Copied from syntax&quot;,&quot;local&quot;:&quot;-copied-from-syntax&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="pull-request-checks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#pull-request-checks"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Pull request checks</span></h1> <p data-svelte-h="svelte-1rmpy7e">When you open a pull request, the Hugging Face CI runs several checks that must pass before your PR can be merged.</p> <ul data-svelte-h="svelte-dfddyl"><li><a href="#fixing-the-ci">Fixing the CI</a> lists the commands to run locally to pass the checks.</li> <li>The sections after that describe what each check validates, such as <a href="#code-quality">code quality</a> and <a href="#repository-consistency">repository consistency</a>.</li> <li><a href="#tests">Tests</a> describe which tests are run, test categories, and slow tests.</li></ul> <h2 class="relative group"><a id="fixing-the-ci" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#fixing-the-ci"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Fixing the CI</span></h2> <p data-svelte-h="svelte-ol0zx4">In most cases, <code>make style</code> is enough to clear the code quality check, which is the most common failure.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->make style<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-ilxrig">For failures in repository consistency, copies, or auto-generated files, run <code>make fix-repo</code>. It fixes style, copies, docstrings, and auto-generated files in one pass.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->make fix-repo<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-6vdypn">For a larger change, the three-command sequence below covers every check. It is heavier, but catches everything before you push.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->make fix-repo <span class="hljs-comment"># auto-fix everything that can be auto-fixed</span>
make typing <span class="hljs-comment"># check types and model structure, fix any errors manually</span>
make check-repo <span class="hljs-comment"># verify all checks pass, fix anything that remains</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1qb54jg"><code>make typing</code> catches type errors and model structure violations that you fix manually. <code>make check-repo</code> does a final read-only pass so you can confirm everything is ready.</p> <blockquote class="note" data-svelte-h="svelte-15ndwul"><p>The CI is occasionally flaky. If a check fails on something unrelated to your change, ping a maintainer to re-run it.</p></blockquote> <h2 class="relative group"><a id="code-quality" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#code-quality"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Code quality</span></h2> <p data-svelte-h="svelte-rm4a08">The code quality check covers formatting, imports, type checking, and model structure rules. It corresponds to <code>make fix-repo</code> and <code>make typing</code>.</p> <p data-svelte-h="svelte-i72rbq"><code>make style</code> (included in <code>make fix-repo</code>) auto-fixes <a href="https://docs.astral.sh/ruff/" rel="nofollow">Ruff</a> linting and formatting, <code>__init__.py</code> import sort order, and auto-mapping consistency.</p> <p data-svelte-h="svelte-xbsotu"><code>make typing</code> performs type checking with <a href="https://docs.astral.sh/ty/" rel="nofollow">ty</a> and validates TRansFormers (TRF) rules, which cover config class naming conventions and <code>forward()</code> signatures. Type errors and TRF violations report a specific rule number and must be fixed manually. The rules live in the <a href="https://github.com/huggingface/transformers-mlinter" rel="nofollow">mlinter</a> repository. Run <code>python -m utils.mlinter --list-rules</code> to see every TRF rule, or <code>python -m utils.mlinter --rule TRFXXX</code> to view the full documentation for a specific rule.</p> <p data-svelte-h="svelte-1vet7w5">If a TRF rule needs an exception, choose one of these options (see <a href="./modeling_rules#suppressing-violations">Suppressing violations</a> for more details).</p> <ul data-svelte-h="svelte-1aije6u"><li>Add your model name to the <code>allowlist_models</code> list for the relevant rule in <code>utils/mlinter/rules.toml</code>. Use this when the whole model file needs an exception.</li> <li>Add <code># trf-ignore: TRFXXX</code> on the same line as the flagged construct, or on the line immediately above it. Use this when only one flagged construct needs an exception.</li></ul> <h2 class="relative group"><a id="repository-consistency" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#repository-consistency"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Repository consistency</span></h2> <p data-svelte-h="svelte-xpru9i">The repository consistency check is similar to <code>make check-repo</code>, except it stops on the first failure. It keeps the repository internally consistent across the categories below: public objects stay importable, copied code stays in sync with its source, and auto-generated files (dummies, doctests, metadata) reflect the current state of the code. For new models, it also verifies every new model class is registered in the auto-mappings.</p> <table data-svelte-h="svelte-1oresfo"><thead><tr><th>Category</th> <th>What it validates</th> <th>Auto-fixed?</th></tr></thead> <tbody><tr><td>Init files</td> <td>Every new public object must appear in both <code>_import_structure</code> (lazy loading) and the <code>if TYPE_CHECKING</code> block (type checker imports) in <code>__init__.py</code></td> <td>Manual</td></tr> <tr><td>Copies and modular</td> <td><code># Copied from</code> blocks match their source and modular-generated files are up to date</td> <td><code>make fix-repo</code></td></tr> <tr><td>Docstrings and docs</td> <td>Argument docstrings match function signatures and documentation table of contents</td> <td><code>make fix-repo</code></td></tr> <tr><td>Auto-generated files</td> <td>Dummies, pipeline typing, doctest list, metadata, dependency table</td> <td><code>make fix-repo</code></td></tr> <tr><td>Config validation</td> <td>Config classes have valid checkpoints in docstrings and config attributes match modeling file</td> <td>Manual</td></tr></tbody></table> <h2 class="relative group"><a id="tests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tests"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tests</span></h2> <p data-svelte-h="svelte-ob7qz7">CI runs a targeted subset of tests based on what your PR changes. The CI runs tests in a slightly randomized order with <a href="https://github.com/jbasko/pytest-random-order" rel="nofollow">pytest-random-order</a> to catch coupled tests. The run prints the random seed at the start so you can replay the same order with <code>--random-order-seed=&lt;seed&gt;</code>.</p> <p data-svelte-h="svelte-koyfhv">If a test passes locally on GPU but fails in CI, set <code>TRANSFORMERS_TEST_DEVICE=&quot;cpu&quot;</code> to check whether you can reproduce the failure on CPU.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->TRANSFORMERS_TEST_DEVICE=<span class="hljs-string">&quot;cpu&quot;</span> pytest tests/models/my_model/ -v<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1g3wh1d">The sections below explain how test selection works, which jobs run, and how to handle slow tests.</p> <h3 class="relative group"><a id="test-selection" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#test-selection"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Test selection</span></h3> <p data-svelte-h="svelte-id5v05">CI doesn’t run the full test suite on every PR. CI skips tests decorated with <code>@slow</code> on every PR, and a maintainer triggers them on GPU once the PR is under review.</p> <p data-svelte-h="svelte-1hfkn3k"><code>utils/tests_fetcher.py</code> traces import dependencies from your changed files to identify affected tests, and only runs those. It also catches regressions in other models when you touch shared utilities. The fetcher prints which files changed and which tests are impacted, then writes the list to <code>tests_torch_test_list.txt</code>.</p> <p data-svelte-h="svelte-15k98ov">Use the fetcher to replicate exactly what CI runs.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->python utils/tests_fetcher.py
python -m pytest -n 8 --dist=loadfile -rA -s $(<span class="hljs-built_in">cat</span> test_preparation/tests_torch_test_list.txt)<!-- HTML_TAG_END --></pre></div> <blockquote class="tip" data-svelte-h="svelte-iwkakr"><p>Changing core files like <code>modeling_utils.py</code> or <code>generation/utils.py</code> triggers all model tests, not just the affected subset.</p></blockquote> <p data-svelte-h="svelte-196he71">You can also run every test for your model unconditionally. A direct run is a faster local sanity check, but it won’t catch regressions in other models caused by shared code you touched.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->pytest tests/models/my_model/ -v<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="test-job-categories" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#test-job-categories"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Test job categories</span></h3> <p data-svelte-h="svelte-16wa0zp">Tests are split across parallel CI jobs, and each job picks up files by path pattern. The relevant jobs for a model PR are:</p> <ul data-svelte-h="svelte-42lym9"><li><code>tests_torch</code>: modeling tests (<code>tests/models/*/test_modeling_*.py</code>)</li> <li><code>tests_tokenization</code>: tokenizer tests (<code>tests/models/*/test_tokenization_*.py</code>)</li> <li><code>tests_processors</code>: processor and feature extractor tests (<code>tests/models/*/test_(processing|image_processing|feature_extractor)_*.py</code>)</li> <li><code>tests_generate</code>: generation tests</li> <li><code>pipelines_torch</code>: pipeline tests</li> <li><code>tests_training_ci</code>: training loop tests</li> <li><code>tests_tensor_parallel_ci</code>: tensor parallel tests</li></ul> <h3 class="relative group"><a id="slow-tests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#slow-tests"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Slow tests</span></h3> <p data-svelte-h="svelte-ekgvmb">Regular CI runs skip tests decorated with <code>@slow</code>. They download real checkpoints or need significant compute, so they run on GPU instances, and maintainers trigger them once your PR is under review.</p> <p data-svelte-h="svelte-ms4zvk">Slow tests run on an NVIDIA A10, and numerical results can vary slightly between the CI hardware and your local machine. Maintainers usually adjusts those values on tests if needed when adding a new model.</p> <p data-svelte-h="svelte-1y4blco">Run slow tests locally with the command below.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->RUN_SLOW=1 python -m pytest tests/models/my_model/ -v<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="documentation-build" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#documentation-build"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Documentation build</span></h3> <p data-svelte-h="svelte-t63dk3">A <code>build_pr_documentation</code> job builds and generates a preview of the documentation. A bot posts a preview link in your PR, and the check must pass before merging. Most failures are a missing entry in the <code>toctree</code>. To build the documentation locally, see the <a href="https://github.com/huggingface/transformers/tree/main/docs" rel="nofollow">README.md</a> in the docs folder.</p> <h2 class="relative group"><a id="-copied-from-syntax" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#-copied-from-syntax"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span># Copied from syntax</span></h2> <blockquote class="warning" data-svelte-h="svelte-dgj0os"><p>For new models, always prefer the <a href="modular_transformers">modular workflow</a> (<code>modular_*.py</code>) over <code># Copied from</code>. Avoid <code># Copied from</code> whenever possible.</p></blockquote> <p data-svelte-h="svelte-1d438p8">The <code># Copied from</code> mechanism keeps copied code in sync with its source. When <code>make fix-repo</code> runs, it checks every <code># Copied from</code> block and updates it to match the original, so edits inside a <code># Copied from</code> block are overwritten. Edit the source instead and let <code>make fix-repo</code> propagate the change.</p> <p data-svelte-h="svelte-1cbhye3">The basic forms of <code># Copied from</code> include the following.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-py "><!-- HTML_TAG_START --><span class="hljs-comment"># Copied from transformers.models.bert.modeling_bert.BertSelfOutput</span>
<span class="hljs-comment"># Copied from transformers.models.bert.modeling_bert.BertAttention with Bert-&gt;Roberta</span>
<span class="hljs-comment"># Copied from transformers.models.bert.modeling_bert.BertForSequenceClassification with Bert-&gt;MobileBert all-casing</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-eimtox">The <code>with model-&gt;newModel</code> syntax applies string replacements after copying. Separate multiple replacements with commas, which are applied from left to right. The <code>all-casing</code> option replaces every casing variant at once (<code>Bert</code>, <code>bert</code>, <code>BERT</code> become <code>MobileBert</code>, <code>mobilebert</code>, <code>MOBILEBERT</code>).</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers/blob/main/docs/source/en/pr_checks.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_1cvdjju = {
assets: "/docs/transformers/pr_41992/en",
base: "/docs/transformers/pr_41992/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers/pr_41992/en/_app/immutable/entry/start.6ac19d43.js"),
import("/docs/transformers/pr_41992/en/_app/immutable/entry/app.42da82bd.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 637],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
39.3 kB
·
Xet hash:
d0db5a8b3e6f57a0075e101ab45c9f2920a538296a96d384f34cc50eae0ca047

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.