Buckets:
| import{s as ke,n as Te,o as Ce}from"../chunks/scheduler.f3b1e791.js";import{S as Ue,i as $e,e as s,s as a,c as d,h as _e,a as o,d as i,b as n,f as we,g as c,j as r,k as ve,l as Je,m as l,n as m,t as u,o as h,p as y}from"../chunks/index.023a9934.js";import{C as Be}from"../chunks/CopyLLMTxtMenu.c780467c.js";import{C as je}from"../chunks/CodeBlock.fc650646.js";import{H as Z,E as Ee}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.fb377ec3.js";function Ie(re){let p,P,S,Q,b,G,f,Y,M,F,x,pe=`kernel-builder uses a Nix-based builder that orchestrates the build. The Nix | |
| builder provides:`,H,g,de=`<li>Reproducible evaluation. The same Nix builder version will always produce | |
| the same derivations (build recipes).</li> <li>Largely reproducible builds by using a build sandbox that only has the | |
| dependencies specified in a derivation.</li> <li>Seamless creation of different build environments (e.g. different Torch | |
| and CUDA combinations).</li>`,R,w,A,v,ce="A kernel derivation builds a kernel in the following steps:",X,k,me=`<li>Generate CMake files for the kernel using | |
| <code>kernel-builder create-pyproject</code>.</li> <li>Generate Ninja build files using CMake.</li> <li>Build the kernel using Ninja.</li> <li>Perform various checks on the compiled kernel, such as: | |
| <ul><li>Verify that the kernel only uses ABI3/<code>manylinux_2_28</code> symbols.</li> <li>Verify that the kernel can be loaded by the <code>kernels</code> Python package.</li></ul></li> <li>Strip runpaths (ELF-embedded library directories) from kernel binaries | |
| to make the kernel distribution-independent.</li>`,V,T,z,C,ue=`To achieve <code>manylinux_2_28</code> compatibility, kernels are built using a | |
| toolchain similar to the <code>manylinux_2_28</code> Docker images. This toolchain | |
| is based on the gcc toolsets from AlmaLinux 8. <code>manylinux_2_28</code> <a href="https://github.com/pypa/manylinux#manylinux_2_28-almalinux-8-based" rel="nofollow">uses | |
| AlmaLinux 8 as its base</a>, | |
| so we have to compile against the same glibc/libstdc++ versions to | |
| ensure compatibility.`,O,U,he=`We repackage the AlmaLinux 8 toolsets and libstdc++ as Nix derivations (see | |
| the <code>nix-builder/packages/manylinux_2_28</code> source directory). Then we merge | |
| various toolset packages to an unwrapped gcc that resembles unwrapped gcc in | |
| nixpkgs. Finally, we wrap binutils and gcc to combine them into a stdenv.`,K,$,ye=`The stdenv does not reuse glibc from AlmaLinux, since its dynamic loader has | |
| hardcoded FHS paths (<code>/lib64</code> etc.) that are not valid in Nix. Using this | |
| dynamic loader results in linking errors, since the paths in the dynamic | |
| loader are used as a last resort (to link glibc libraries). So, instead we | |
| build our own glibc 2.28 package | |
| (see <code>nix-builder/pkgs/manylinux_2_28/stdenv.nix</code>) and use that.`,q,_,D,J,be=`We repackage various existing package sets as Nix derivations. For instance, | |
| this is done for ROCm, XPU, and manylinux_2_28 packages. We do this because | |
| we want these libraries to be as close as what the user would install. This | |
| avoids compatibility issues between the kernels and the official vendor | |
| packages. For instance, suppose that we built a ROCm library as a shared | |
| library and ROCm provides the same library as a static library, then compiled | |
| kernels could use symbols that cannot be resolved when installing the official | |
| ROCm packages. Similarly, using the official packages allows us to test | |
| against the official upstream packages.`,ee,B,fe="These package sets all follow the same pattern:",te,j,ie,E,Me=`We use a fixed point to build up the package set as a list of | |
| <a href="https://nixos.org/manual/nixpkgs/stable/#sec-overlays-definition" rel="nofollow">overlays</a>. | |
| This has various benefits. For instance, it allows us to refine the | |
| package set incrementally and we can refer to the final versions of | |
| packages in intermediate overlays.`,le,I,xe="The package sets all use a similar list of overlays:",ae,N,ge=`<li>An initial overlay (<code>components.nix</code>) that applies a generic builder | |
| to the package set metadata. The metadata typically comes from a Yum/DNF | |
| repository that contains RPM packages.The generic builder will extract the | |
| RPMs and move binaries, libraries, and headers to the right location. This | |
| results in a set of Nix derivations that may or may not build.</li> <li>The next overlay (<code>overrides.nix</code>) fixes up derivations generated by the | |
| generic builder in the previous overlay that do not build. Fixing the | |
| derivations typically consists of adding missing dependencies and changing | |
| embedded FHS paths to Nix store paths.</li> <li>Additional overlays with derivations that combine outputs from previous | |
| overlays. One typical example are derivations that construct a full compiler | |
| toolchain (e.g. <code>nix-builder/pkgs/manylinux_2_28/gcc-unwrapped.nix</code>).</li>`,ne,L,se,W,oe;return b=new Be({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new Z({props:{title:"Nix Builder design",local:"nix-builder-design",headingTag:"h1"}}),M=new Z({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),w=new Z({props:{title:"Kernel build steps",local:"kernel-build-steps",headingTag:"h2"}}),T=new Z({props:{title:"manylinux_2_28 compatibility",local:"manylinux228-compatibility",headingTag:"h2"}}),_=new Z({props:{title:"The package set pattern",local:"the-package-set-pattern",headingTag:"h2"}}),j=new je({props:{code:"JTdCJTBBJTIwJTIwbGliJTJDJTBBJTIwJTIwY2FsbFBhY2thZ2UlMkMlMEElMjAlMjBuZXdTY29wZSUyQyUwQSUyMCUyMHBrZ3MlMkMlMEElN0QlM0ElMEElMEElN0IlMEElMjAlMjBwYWNrYWdlTWV0YWRhdGElMkMlMEElN0QlM0ElMEElMEFsZXQlMEElMjAlMjBpbmhlcml0JTIwKGxpYi5maXhlZFBvaW50cyklMjBleHRlbmRzJTIwY29tcG9zZU1hbnlFeHRlbnNpb25zJTNCJTBBJTBBJTIwJTIwZml4ZWRQb2ludCUyMCUzRCUyMGZpbmFsJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwaW5oZXJpdCUyMGxpYiUzQiUwQSUyMCUyMCU3RCUzQiUwQSUyMCUyMGNvbXBvc2VkJTIwJTNEJTIwbGliLmNvbXBvc2VNYW55RXh0ZW5zaW9ucyUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMyUyMEJhc2UlMjBwYWNrYWdlJTIwc2V0LiUwQSUyMCUyMCUyMCUyMChpbXBvcnQlMjAuJTJGY29tcG9uZW50cy5uaXglMjAlN0IlMjBpbmhlcml0JTIwcGFja2FnZU1ldGFkYXRhJTNCJTIwJTdEKSUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyMFBhY2thZ2Utc3BlY2lmaWMlMjBvdmVycmlkZXMuJTBBJTIwJTIwJTIwJTIwKGltcG9ydCUyMC4lMkZvdmVycmlkZXMubml4KSUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyMEFkZGl0aW9uYWwlMjBvdmVybGF5cyUyMHRoYXQlMjBleHRlbmQlMjB0aGUlMjBwYWNrYWdlJTIwc2V0LiUwQSUyMCUyMCUyMCUyMChpbXBvcnQlMjAuJTJGc29tZS1vdmVybGF5Lm5peCklMEElMjAlMjAlNUQlM0IlMEFpbiUwQWxpYi5tYWtlU2NvcGUlMjBuZXdTY29wZSUyMChsaWIuZXh0ZW5kcyUyMGNvbXBvc2VkJTIwZml4ZWRQb2ludCk=",highlighted:`{ | |
| lib, | |
| callPackage, | |
| newScope, | |
| pkgs, | |
| }: | |
| { | |
| packageMetadata, | |
| }: | |
| <span class="hljs-keyword">let</span> | |
| <span class="hljs-keyword">inherit</span> (lib.fixedPoints) extends composeManyExtensions; | |
| <span class="hljs-attr">fixedPoint</span> = final: { | |
| <span class="hljs-keyword">inherit</span> lib; | |
| }; | |
| <span class="hljs-attr">composed</span> = lib.composeManyExtensions [ | |
| <span class="hljs-comment"># Base package set.</span> | |
| (<span class="hljs-built_in">import</span> ./components.nix { <span class="hljs-keyword">inherit</span> packageMetadata; }) | |
| <span class="hljs-comment"># Package-specific overrides.</span> | |
| (<span class="hljs-built_in">import</span> ./overrides.nix) | |
| <span class="hljs-comment"># Additional overlays that extend the package set.</span> | |
| (<span class="hljs-built_in">import</span> ./some-overlay.nix) | |
| ]; | |
| <span class="hljs-keyword">in</span> | |
| lib.makeScope newScope (lib.extends composed fixedPoint)`,lang:"nix",wrap:!1}}),L=new Ee({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/design-nix-builder.md"}}),{c(){p=s("meta"),P=a(),S=s("p"),Q=a(),d(b.$$.fragment),G=a(),d(f.$$.fragment),Y=a(),d(M.$$.fragment),F=a(),x=s("p"),x.textContent=pe,H=a(),g=s("ul"),g.innerHTML=de,R=a(),d(w.$$.fragment),A=a(),v=s("p"),v.textContent=ce,X=a(),k=s("ol"),k.innerHTML=me,V=a(),d(T.$$.fragment),z=a(),C=s("p"),C.innerHTML=ue,O=a(),U=s("p"),U.innerHTML=he,K=a(),$=s("p"),$.innerHTML=ye,q=a(),d(_.$$.fragment),D=a(),J=s("p"),J.textContent=be,ee=a(),B=s("p"),B.textContent=fe,te=a(),d(j.$$.fragment),ie=a(),E=s("p"),E.innerHTML=Me,le=a(),I=s("p"),I.textContent=xe,ae=a(),N=s("ul"),N.innerHTML=ge,ne=a(),d(L.$$.fragment),se=a(),W=s("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(i),P=n(e),S=o(e,"P",{}),we(S).forEach(i),Q=n(e),c(b.$$.fragment,e),G=n(e),c(f.$$.fragment,e),Y=n(e),c(M.$$.fragment,e),F=n(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-10m3qhc"&&(x.textContent=pe),H=n(e),g=o(e,"UL",{"data-svelte-h":!0}),r(g)!=="svelte-k9b528"&&(g.innerHTML=de),R=n(e),c(w.$$.fragment,e),A=n(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-wtbtic"&&(v.textContent=ce),X=n(e),k=o(e,"OL",{"data-svelte-h":!0}),r(k)!=="svelte-18gvsag"&&(k.innerHTML=me),V=n(e),c(T.$$.fragment,e),z=n(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-dg7mnn"&&(C.innerHTML=ue),O=n(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1wrujd7"&&(U.innerHTML=he),K=n(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-mo1kwe"&&($.innerHTML=ye),q=n(e),c(_.$$.fragment,e),D=n(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-18b8mp1"&&(J.textContent=be),ee=n(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1x0q90t"&&(B.textContent=fe),te=n(e),c(j.$$.fragment,e),ie=n(e),E=o(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-11ywwcl"&&(E.innerHTML=Me),le=n(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-1o8pfoq"&&(I.textContent=xe),ae=n(e),N=o(e,"UL",{"data-svelte-h":!0}),r(N)!=="svelte-qhvlz7"&&(N.innerHTML=ge),ne=n(e),c(L.$$.fragment,e),se=n(e),W=o(e,"P",{}),we(W).forEach(i),this.h()},h(){ve(p,"name","hf:doc:metadata"),ve(p,"content",Ne)},m(e,t){Je(document.head,p),l(e,P,t),l(e,S,t),l(e,Q,t),m(b,e,t),l(e,G,t),m(f,e,t),l(e,Y,t),m(M,e,t),l(e,F,t),l(e,x,t),l(e,H,t),l(e,g,t),l(e,R,t),m(w,e,t),l(e,A,t),l(e,v,t),l(e,X,t),l(e,k,t),l(e,V,t),m(T,e,t),l(e,z,t),l(e,C,t),l(e,O,t),l(e,U,t),l(e,K,t),l(e,$,t),l(e,q,t),m(_,e,t),l(e,D,t),l(e,J,t),l(e,ee,t),l(e,B,t),l(e,te,t),m(j,e,t),l(e,ie,t),l(e,E,t),l(e,le,t),l(e,I,t),l(e,ae,t),l(e,N,t),l(e,ne,t),m(L,e,t),l(e,se,t),l(e,W,t),oe=!0},p:Te,i(e){oe||(u(b.$$.fragment,e),u(f.$$.fragment,e),u(M.$$.fragment,e),u(w.$$.fragment,e),u(T.$$.fragment,e),u(_.$$.fragment,e),u(j.$$.fragment,e),u(L.$$.fragment,e),oe=!0)},o(e){h(b.$$.fragment,e),h(f.$$.fragment,e),h(M.$$.fragment,e),h(w.$$.fragment,e),h(T.$$.fragment,e),h(_.$$.fragment,e),h(j.$$.fragment,e),h(L.$$.fragment,e),oe=!1},d(e){e&&(i(P),i(S),i(Q),i(G),i(Y),i(F),i(x),i(H),i(g),i(R),i(A),i(v),i(X),i(k),i(V),i(z),i(C),i(O),i(U),i(K),i($),i(q),i(D),i(J),i(ee),i(B),i(te),i(ie),i(E),i(le),i(I),i(ae),i(N),i(ne),i(se),i(W)),i(p),y(b,e),y(f,e),y(M,e),y(w,e),y(T,e),y(_,e),y(j,e),y(L,e)}}}const Ne='{"title":"Nix Builder design","local":"nix-builder-design","sections":[{"title":"Introduction","local":"introduction","sections":[],"depth":2},{"title":"Kernel build steps","local":"kernel-build-steps","sections":[],"depth":2},{"title":"manylinux_2_28 compatibility","local":"manylinux228-compatibility","sections":[],"depth":2},{"title":"The package set pattern","local":"the-package-set-pattern","sections":[],"depth":2}],"depth":1}';function Le(re){return Ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends Ue{constructor(p){super(),$e(this,p,Le,Ie,ke,{})}}export{Ge as component}; | |
Xet Storage Details
- Size:
- 11.4 kB
- Xet hash:
- fddf020bc1d8dd5faf5854f9b90ef07d931985a2d0bf024e9345f2b8b6ead044
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.