Buckets:

HuggingFaceDocBuilder's picture
download
raw
21.3 kB
import"../chunks/DsnmJJEf.js";import{i as b,h as I,C,H as t,a as l,E as m,s as f}from"../chunks/CyvF58-O.js";import{p as A,o as k,s,f as B,a as w,b as E,c as J,n as v}from"../chunks/DfHjNWj2.js";const G='{"title":"Building and testing kernels with GitHub Actions","local":"building-and-testing-kernels-with-github-actions","sections":[{"title":"Prerequisites","local":"prerequisites","sections":[],"depth":2},{"title":"Building on push","local":"building-on-push","sections":[{"title":"kernel-builder-job inputs","local":"kernel-builder-job-inputs","sections":[],"depth":3}],"depth":2},{"title":"Testing on a GPU","local":"testing-on-a-gpu","sections":[{"title":"hf-jobs-action inputs","local":"hf-jobs-action-inputs","sections":[],"depth":3}],"depth":2},{"title":"Choosing a flavor","local":"choosing-a-flavor","sections":[],"depth":2}],"depth":1}';var N=J('<meta name="hf:doc:metadata"/>'),S=J(`<p></p> <!> <!> <p>Compiling a kernel is CPU-intensive and testing it requires an accelerator (such as a GPU), two things that GitHub’s standard runners do not provide cheaply. Instead of maintaining self-hosted runners, you can offload both steps to <a href="https://huggingface.co/docs/huggingface_hub/guides/jobs" rel="nofollow">Hugging Face Jobs</a> directly from a GitHub Actions workflow.</p> <p>Two prebuilt actions make this possible:</p> <ul><li><a href="https://github.com/huggingface/kernel-builder-job" rel="nofollow"><code>huggingface/kernel-builder-job</code></a> runs the Nix kernel builder on a CPU flavor and publishes the built kernel to the Hub.</li> <li><a href="https://github.com/huggingface/hf-jobs-action" rel="nofollow"><code>huggingface/hf-jobs-action</code></a> runs an arbitrary script on any flavor (including GPUs), which is convenient for testing the kernel you just built. This also helps to test the kernel across different hardware.</li></ul> <p>A typical setup has two workflows: one that <strong>builds</strong> the kernel on push, and one that <strong>tests</strong> it on a GPU. They communicate through the Hub, the build uploads artifacts, the test pulls them back down.</p> <!> <ul><li>An <a href="https://huggingface.co/settings/tokens" rel="nofollow">HF access token</a> with the <code>job.write</code> permission. If the test job loads gated models, the token also needs read access to them.</li> <li>The token stored as a repository secret named <code>HF_TOKEN</code> (<strong>Settings → Secrets and variables → Actions</strong>).</li> <li>A kernel repository on the Hub to upload to, with kernel-creation access for the owning user or org (see <a href="build#uploading-your-kernel-to-the-hub">Building kernels</a>).</li></ul> <blockquote class="note"><p>Jobs run under the <code>namespace</code> you specify (your username or an org) and
count against that namespace’s compute quota.</p></blockquote> <!> <p>The build action checks out nothing by itself, your script clones the exact commit and invokes the Nix builder. Compilation happens on the HF Jobs CPU flavor, and <code>build-and-upload</code> pushes the finished variants to the Hub.</p> <!> <p>The path filter keeps the build from running on unrelated commits, and <code>workflow_dispatch</code> lets you trigger it by hand from the <strong>Actions</strong> tab. The upload destination is taken from <code>--repo-id</code> (or, if omitted, from the <code>repo-id</code>/<code>version</code> fields in <code>build.toml</code>).</p> <blockquote class="tip"><p>Builds can take a long time on the first run because every PyTorch and CUDA
variant is compiled. Set a generous <code>timeout</code> (the example allows six hours)
and rely on the <a href="build#using-the-hugging-face-binary-cache">Hugging Face binary cache</a> to keep subsequent builds fast.</p></blockquote> <p>You can speed up builds by tuning how much work runs in parallel. <code>--max-jobs</code> sets how many kernel variants are built concurrently, while <code>--cores</code> sets how
many CPU cores each of those jobs may use. Pick values that fit the chosen CPU <code>flavor</code>: a larger flavor (such as <code>cpu-xl</code>) has more cores to spread across
jobs, so raising <code>--max-jobs</code> and <code>--cores</code> together shortens the total build
time. Setting them too high for the flavor only adds scheduling overhead.</p> <!> <table><thead><tr><th>Input</th><th>Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>yes</td><td></td><td>HF token with <code>job.write</code> permission.</td></tr><tr><td><code>namespace</code></td><td>yes</td><td></td><td>HF namespace (username or org) that owns the job.</td></tr><tr><td><code>script</code></td><td>yes</td><td></td><td>Shell script to run in the container.</td></tr><tr><td><code>flavor</code></td><td>no</td><td><code>cpu-upgrade</code></td><td>Hardware flavor (e.g. <code>cpu-xl</code>).</td></tr><tr><td><code>image</code></td><td>no</td><td>Nix + cachix image</td><td>Container image to run the build in.</td></tr><tr><td><code>timeout</code></td><td>no</td><td><code>1200</code></td><td>Maximum seconds to wait for the job.</td></tr></tbody></table> <p>The action exposes <code>job_id</code> and <code>job_url</code> outputs that link to the run on huggingface.co.</p> <!> <p>Once the kernel is on the Hub, the generic jobs action runs a test script on a GPU flavor. The <code>files</code> input copies repository files into the container (under <code>/tmp/files</code> by default), and a <a href="https://docs.astral.sh/uv/guides/scripts/" rel="nofollow"><code>uv</code> script</a> with inline dependencies keeps the environment self-contained.</p> <!> <p>The test script pulls the kernel straight from the Hub with the <a href="../basic-usage"><code>kernels</code></a> library, so it always runs against the artifacts the build workflow just published:</p> <!> <p>Run the build workflow before the test workflow so the Hub has a fresh kernel to pull. For tightly coupled steps, you can also have one workflow trigger the other, or combine both jobs in a single workflow with a <code>needs:</code> dependency.</p> <!> <table><thead><tr><th>Input</th><th>Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>yes</td><td></td><td>HF token with <code>job.write</code> permission.</td></tr><tr><td><code>namespace</code></td><td>yes</td><td></td><td>HF namespace (username or org) that owns the job.</td></tr><tr><td><code>image</code></td><td>yes</td><td></td><td>Container image to run.</td></tr><tr><td><code>script</code></td><td>yes</td><td></td><td>Shell script to execute in the container.</td></tr><tr><td><code>flavor</code></td><td>no</td><td><code>cpu-basic</code></td><td>Hardware flavor (e.g. <code>rtx-pro-6000</code>).</td></tr><tr><td><code>files</code></td><td>no</td><td></td><td>Newline-separated repo files to copy into the job.</td></tr><tr><td><code>files_dest</code></td><td>no</td><td><code>/tmp/files</code></td><td>Directory the files are copied to inside the container.</td></tr><tr><td><code>env</code></td><td>no</td><td><code>&#123;&#125;</code></td><td>Environment variables as a JSON object.</td></tr><tr><td><code>timeout</code></td><td>no</td><td><code>1200</code></td><td>Maximum seconds to wait for the job.</td></tr></tbody></table> <!> <p>Flavors map to the machine types available on Hugging Face Jobs, CPU flavors such as <code>cpu-upgrade</code> and <code>cpu-xl</code> for builds, and GPU flavors such as <code>l4x1</code>, <code>a100-large</code>, <code>h200</code>, or <code>rtx-pro-6000</code> for tests. Pick the most reasonable GPU that fits your model to keep jobs low cost. The current list and pricing are in the <a href="https://huggingface.co/docs/huggingface_hub/guides/jobs" rel="nofollow">Hugging Face Jobs documentation</a>.</p> <blockquote class="note"><p>HF Jobs currently only offers a few CPU architectures, so the kernel is built
for whatever architecture the available CPU flavors provide. This is a current
limitation to keep in mind if you need to target a specific architecture.</p></blockquote> <blockquote class="warning"><p>HF Jobs containers start with shell tracing enabled (<code>set -x</code>). Always run <code>set +x</code> before exporting <code>HF_TOKEN</code> so the token does not leak into the
streamed build logs.</p></blockquote> <!> <p></p>`,1);function V(T,U){A(U,!1),k(()=>{new URLSearchParams(window.location.search).get("fw")}),b();var a=S();I("z3exm2",y=>{var u=N();f(u,"content",G),w(y,u)});var e=s(B(a),2);C(e,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var n=s(e,2);t(n,{title:"Building and testing kernels with GitHub Actions",local:"building-and-testing-kernels-with-github-actions",headingTag:"h1"});var o=s(n,10);t(o,{title:"Prerequisites",local:"prerequisites",headingTag:"h2"});var c=s(o,6);t(c,{title:"Building on push",local:"building-on-push",headingTag:"h2"});var i=s(c,4);l(i,{code:"JTIzJTIwLmdpdGh1YiUyRndvcmtmbG93cyUyRmJ1aWxkLWtlcm5lbC55bWwlMEFuYW1lJTNBJTIwQnVpbGQlMjBLZXJuZWwlMEElMEFvbiUzQSUwQSUyMCUyMHB1c2glM0ElMEElMjAlMjAlMjAlMjBicmFuY2hlcyUzQSUyMCU1Qm1haW4lNUQlMEElMjAlMjAlMjAlMjBwYXRocyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMC0lMjAlMjJjc3JjJTJGKiolMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAtJTIwJTIydG9yY2gtZXh0JTJGKiolMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAtJTIwYnVpbGQudG9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0IlN0IlMjBnaXRodWIuc2hhJTIwJTdEJTdEJTIyJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbml4JTIwcnVuJTIwZ2l0aHViJTNBaHVnZ2luZ2ZhY2UlMkZrZXJuZWxzJTIza2VybmVsLWJ1aWxkZXIlMjAtLSUyMGJ1aWxkLWFuZC11cGxvYWQlMjAlNUMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtLW1heC1qb2JzJTIwNCUyMCU1QyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC0tY29yZXMlMjA4JTIwJTVDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLS1yZXBvLWlkJTIweW91ci11c2VybmFtZSUyRnlvdXIta2VybmVs",highlighted:`<span class="hljs-comment"># .github/workflows/build-kernel.yml</span>
<span class="hljs-attr">name:</span> <span class="hljs-string">Build</span> <span class="hljs-string">Kernel</span>
<span class="hljs-attr">on:</span>
<span class="hljs-attr">push:</span>
<span class="hljs-attr">branches:</span> [<span class="hljs-string">main</span>]
<span class="hljs-attr">paths:</span>
<span class="hljs-bullet">-</span> <span class="hljs-string">&quot;csrc/**&quot;</span>
<span class="hljs-bullet">-</span> <span class="hljs-string">&quot;torch-ext/**&quot;</span>
<span class="hljs-bullet">-</span> <span class="hljs-string">build.toml</span>
<span class="hljs-bullet">-</span> <span class="hljs-string">flake.nix</span>
<span class="hljs-bullet">-</span> <span class="hljs-string">flake.lock</span>
<span class="hljs-attr">workflow_dispatch:</span>
<span class="hljs-attr">jobs:</span>
<span class="hljs-attr">build:</span>
<span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
<span class="hljs-attr">steps:</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v4</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Build</span> <span class="hljs-string">kernel</span> <span class="hljs-string">via</span> <span class="hljs-string">HF</span> <span class="hljs-string">Jobs</span>
<span class="hljs-attr">uses:</span> <span class="hljs-string">huggingface/kernel-builder-job@main</span>
<span class="hljs-attr">with:</span>
<span class="hljs-attr">token:</span> <span class="hljs-string">\${{</span> <span class="hljs-string">secrets.HF_TOKEN</span> <span class="hljs-string">}}</span>
<span class="hljs-attr">namespace:</span> <span class="hljs-string">your-username</span>
<span class="hljs-attr">flavor:</span> <span class="hljs-string">cpu-xl</span>
<span class="hljs-attr">timeout:</span> <span class="hljs-string">&quot;21600&quot;</span>
<span class="hljs-attr">script:</span> <span class="hljs-string">|
# The container starts with \`set -x\`; disable tracing so the
# token below is not echoed into the streamed logs.
set +x
export HF_TOKEN=&quot;\${{ secrets.HF_TOKEN }}&quot;
# Rebuild artifacts, so skip pulling existing LFS blobs.
export GIT_LFS_SKIP_SMUDGE=1
</span>
<span class="hljs-string">git</span> <span class="hljs-string">clone</span> <span class="hljs-string">&quot;$<span class="hljs-template-variable">{{ github.server_url }}</span>/$<span class="hljs-template-variable">{{ github.repository }}</span>&quot;</span> <span class="hljs-string">kernel</span>
<span class="hljs-string">cd</span> <span class="hljs-string">kernel</span>
<span class="hljs-string">git</span> <span class="hljs-string">checkout</span> <span class="hljs-string">&quot;$<span class="hljs-template-variable">{{ github.sha }}</span>&quot;</span>
<span class="hljs-string">nix</span> <span class="hljs-string">run</span> <span class="hljs-string">github:huggingface/kernels#kernel-builder</span> <span class="hljs-string">--</span> <span class="hljs-string">build-and-upload</span> <span class="hljs-string">\\</span>
<span class="hljs-string">--max-jobs</span> <span class="hljs-number">4</span> <span class="hljs-string">\\</span>
<span class="hljs-string">--cores</span> <span class="hljs-number">8</span> <span class="hljs-string">\\</span>
<span class="hljs-string">--repo-id</span> <span class="hljs-string">your-username/your-kernel</span>`,lang:"yaml",wrap:!1});var r=s(i,8);t(r,{title:"kernel-builder-job inputs",local:"kernel-builder-job-inputs",headingTag:"h3"});var d=s(r,6);t(d,{title:"Testing on a GPU",local:"testing-on-a-gpu",headingTag:"h2"});var p=s(d,4);l(p,{code:"JTIzJTIwLmdpdGh1YiUyRndvcmtmbG93cyUyRnJ1bi10ZXN0cy55bWwlMEFuYW1lJTNBJTIwUnVuJTIwdGVzdHMlMEElMEFvbiUzQSUwQSUyMCUyMHB1c2glM0ElMEElMjAlMjAlMjAlMjBicmFuY2hlcyUzQSUyMCU1Qm1haW4lNUQlMEElMjAlMjAlMjAlMjBwYXRocyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMC0lMjBzY3JpcHRzJTJGdGVzdC5weSUwQSUyMCUyMHdvcmtmbG93X2Rpc3BhdGNoJTNBJTBBJTBBam9icyUzQSUwQSUyMCUyMHJ1biUzQSUwQSUyMCUyMCUyMCUyMHJ1bnMtb24lM0ElMjB1YnVudHUtbGF0ZXN0JTBBJTIwJTIwJTIwJTIwc3RlcHMlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAtJTIwdXNlcyUzQSUyMGFjdGlvbnMlMkZjaGVja291dCU0MHY0JTBBJTIwJTIwJTIwJTIwJTIwJTIwLSUyMG5hbWUlM0ElMjBSdW4lMjB0ZXN0LnB5JTIwb24lMjBhbiUyMEhGJTIwSm9icyUyMEdQVSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHVzZXMlM0ElMjBodWdnaW5nZmFjZSUyRmhmLWpvYnMtYWN0aW9uJTQwbWFpbiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHdpdGglM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b2tlbiUzQSUyMCUyNCU3QiU3QiUyMHNlY3JldHMuSEZfVE9LRU4lMjAlN0QlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBuYW1lc3BhY2UlM0ElMjB5b3VyLXVzZXJuYW1lJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZmxhdm9yJTNBJTIwcnR4LXByby02MDAwJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaW1hZ2UlM0ElMjBnaGNyLmlvJTJGYXN0cmFsLXNoJTJGdXYlM0FweXRob24zLjEwLWJvb2t3b3JtJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGltZW91dCUzQSUyMCUyMjM2MDAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmaWxlcyUzQSUyMHNjcmlwdHMlMkZ0ZXN0LnB5JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2NyaXB0JTNBJTIwJTdDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2V0JTIwJTJCeCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGV4cG9ydCUyMEhGX1RPS0VOJTNEJTIyJTI0JTdCJTdCJTIwc2VjcmV0cy5IRl9UT0tFTiUyMCU3RCU3RCUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHV2JTIwcnVuJTIwJTJGdG1wJTJGZmlsZXMlMkZ0ZXN0LnB5",highlighted:`<span class="hljs-comment"># .github/workflows/run-tests.yml</span>
<span class="hljs-attr">name:</span> <span class="hljs-string">Run</span> <span class="hljs-string">tests</span>
<span class="hljs-attr">on:</span>
<span class="hljs-attr">push:</span>
<span class="hljs-attr">branches:</span> [<span class="hljs-string">main</span>]
<span class="hljs-attr">paths:</span>
<span class="hljs-bullet">-</span> <span class="hljs-string">scripts/test.py</span>
<span class="hljs-attr">workflow_dispatch:</span>
<span class="hljs-attr">jobs:</span>
<span class="hljs-attr">run:</span>
<span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
<span class="hljs-attr">steps:</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v4</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Run</span> <span class="hljs-string">test.py</span> <span class="hljs-string">on</span> <span class="hljs-string">an</span> <span class="hljs-string">HF</span> <span class="hljs-string">Jobs</span> <span class="hljs-string">GPU</span>
<span class="hljs-attr">uses:</span> <span class="hljs-string">huggingface/hf-jobs-action@main</span>
<span class="hljs-attr">with:</span>
<span class="hljs-attr">token:</span> <span class="hljs-string">\${{</span> <span class="hljs-string">secrets.HF_TOKEN</span> <span class="hljs-string">}}</span>
<span class="hljs-attr">namespace:</span> <span class="hljs-string">your-username</span>
<span class="hljs-attr">flavor:</span> <span class="hljs-string">rtx-pro-6000</span>
<span class="hljs-attr">image:</span> <span class="hljs-string">ghcr.io/astral-sh/uv:python3.10-bookworm</span>
<span class="hljs-attr">timeout:</span> <span class="hljs-string">&quot;3600&quot;</span>
<span class="hljs-attr">files:</span> <span class="hljs-string">scripts/test.py</span>
<span class="hljs-attr">script:</span> <span class="hljs-string">|
set +x
export HF_TOKEN=&quot;\${{ secrets.HF_TOKEN }}&quot;
uv run /tmp/files/test.py</span>`,lang:"yaml",wrap:!1});var M=s(p,4);l(M,{code:"JTIzJTIwc2NyaXB0cyUyRnRlc3QucHklMEElMjMlMjAlMkYlMkYlMkYlMjBzY3JpcHQlMEElMjMlMjBkZXBlbmRlbmNpZXMlMjAlM0QlMjAlNUIlMjJrZXJuZWxzJTIyJTJDJTIwJTIydG9yY2glMjIlNUQlMEElMjMlMjAlMkYlMkYlMkYlMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMGdldF9rZXJuZWwlMEElMEFrZXJuZWwlMjAlM0QlMjBnZXRfa2VybmVsKCUyMnlvdXItdXNlcm5hbWUlMkZ5b3VyLWtlcm5lbCUyMiklMEElMjMlMjAuLi4lMjBleGVyY2lzZSUyMHRoZSUyMGtlcm5lbCUyMGFuZCUyMGFzc2VydCUyMG9uJTIwdGhlJTIwcmVzdWx0cyUyMC4uLg==",highlighted:`<span class="hljs-comment"># scripts/test.py</span>
<span class="hljs-comment"># /// script</span>
<span class="hljs-comment"># dependencies = [&quot;kernels&quot;, &quot;torch&quot;]</span>
<span class="hljs-comment"># ///</span>
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> get_kernel
kernel = get_kernel(<span class="hljs-string">&quot;your-username/your-kernel&quot;</span>)
<span class="hljs-comment"># ... exercise the kernel and assert on the results ...</span>`,lang:"python",wrap:!1});var h=s(M,4);t(h,{title:"hf-jobs-action inputs",local:"hf-jobs-action-inputs",headingTag:"h3"});var j=s(h,4);t(j,{title:"Choosing a flavor",local:"choosing-a-flavor",headingTag:"h2"});var g=s(j,8);m(g,{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/github-actions.md"}),v(2),w(T,a),E()}export{V as component};

Xet Storage Details

Size:
21.3 kB
·
Xet hash:
3fb6672b667e566d11f23b172413bd533e7f60b3aec8bfbf1c6c812802bd78c6

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