Buckets:
| import{s as Mn,n as wn,o as $n}from"../chunks/scheduler.f3b1e791.js";import{S as bn,i as Jn,e as i,s,c as r,h as vn,a as o,d as l,b as a,f as Tl,g as c,j as p,k as yn,l as y,m as n,n as d,t as m,o as u,p as h}from"../chunks/index.d8b6a549.js";import{C as jn}from"../chunks/CopyLLMTxtMenu.1edf0ddf.js";import{C as $}from"../chunks/CodeBlock.05c913ee.js";import{H as f,E as Cn}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.a742978a.js";function In(vl){let b,Xe,Fe,Ye,J,De,v,Ke,j,jl=`Kernels on the Hub must fulfill the requirements outlined on this page. By | |
| ensuring kernels are compliant, they can be used on a wide range of Linux | |
| systems and Torch builds.`,Oe,C,Cl=`<a href="https://discord.gg/H6Tkmd88N3" rel="nofollow">Join us on Discord</a> for questions and discussions | |
| about building kernels!`,et,I,tt,g,Il=`A kernel repository on the Hub must contain a <code>build</code> directory. This | |
| directory contains build variants of a kernel in the form of directories | |
| following the template | |
| <code><framework><version>-cxx<abiver>-<cu><cudaver>-<arch>-<os></code>. | |
| For example <code>build/torch26-cxx98-cu118-x86_64-linux</code>.`,lt,U,gl=`The kernel is in the build variant directory and must contain a | |
| <code>__init__.py</code> file. For compatibility with older versions of the | |
| <code>kernels</code> package, each variant directory must also contain a single | |
| directory with the same name as the repository (replacing <code>-</code> by <code>_</code>). | |
| For instance, kernels in the <code>kernels-community/activation</code> repository | |
| have a directory like <code>build/<variant>/activation</code>. This directory | |
| must contain an <code>__init__.py</code> file that exports the same symbols as | |
| <code>__init__.py</code> in the build variant directory <code>build/<variant></code>. | |
| <a href="https://huggingface.co/kernels-test/flattened-build/blob/main/build/torch-universal/flattened_build/__init__.py" rel="nofollow">This example</a> | |
| shows how this can be done. This compatibility directory is | |
| automatically created by <code>kernel-builder</code>.`,nt,x,st,k,Ul=`A kernel can be compliant for a specific compute framework (e.g. CUDA) or | |
| architecture (e.g. x86_64). For compliance with a compute framework and | |
| architecture combination, all the variants from the <a href="builder/build-variants">build variant list</a> | |
| must be available for that combination.`,at,_,it,H,xl=`The build variant directory can optionally contain a <code>metadata.json</code> file. | |
| Currently the metadata specifies the kernel’s version and Python dependencies, | |
| for example:`,ot,L,pt,B,rt,A,kl="You can specify Python dependencies that your kernel requires. Dependencies can be either general (required for all backends) or backend-specific (required only for certain compute backends like CUDA, ROCm, XPU, Metal, or CPU).",ct,G,dt,P,_l="For dependencies required regardless of the backend, use the <code>python-depends</code> field:",mt,q,ut,E,ht,Z,Hl="For dependencies that are only needed for specific backends, use the <code>python-depends-backends</code> field:",ft,S,Tt,N,yt,W,Ll="You can specify both general and backend-specific dependencies:",Mt,Q,wt,z,$t,V,Bl="The following dependencies are currently allowed:",bt,F,Al="<strong>General dependencies:</strong>",Jt,R,Gl="<li><code>einops</code></li>",vt,X,Pl="<strong>Backend-specific dependencies:</strong>",jt,Y,ql="<li>CUDA: <code>nvidia-cutlass-dsl</code></li> <li>XPU: <code>onednn</code></li>",Ct,D,El="Dependencies are validated based on the backend being used. When a kernel is loaded, only the dependencies relevant to the active backend are checked.",It,K,gt,O,Zl=`Kernels are versioned using a major version. The kernel revisions of a | |
| version are stored in a branch of the form <code>v<version></code>. Each build | |
| variant will also have the kernel version in <code>metadata.json</code>.`,Ut,ee,Sl="The version <strong>must</strong> be bumped in the following cases:",xt,te,Nl=`<li>The kernel API is changed in an incompatible way.</li> <li>The API is extended in a compatible way, but not all build variants | |
| receive the extension (e.g. because they are for older Torch versions | |
| that are not supported by <code>kernel-builder</code> anymore).</li>`,kt,le,Wl=`In both cases, build variants that are not updated must be removed from | |
| the new version’s branch.`,_t,ne,Ht,se,Ql=`Kernels will typically contain a native Python module with precompiled | |
| compute kernels and bindings. This module must fulfill the requirements | |
| outlined in this section. For all operating systems, a kernel must not | |
| have dynamic library dependencies outside:`,Lt,ae,zl="<li>Torch;</li> <li>CUDA/ROCm libraries installed as dependencies of Torch.</li>",Bt,ie,At,oe,Vl=`The Kernel Hub also encourages to write the kernels in a <code>torch.compile</code> | |
| compliant way. This helps to ensure that the kernels are compatible with | |
| <code>torch.compile</code> without introducing any graph breaks and triggering | |
| recompilation which can limit the benefits of compilation.`,Gt,pe,Fl=`<a href="https://github.com/huggingface/kernels/blob/f83b4da6b7f6b171b47bb9bf96271ae2273bc9d3/builder/examples/relu-backprop-compile/tests/test_relu.py#L162" rel="nofollow">Here</a> | |
| is a simple test example which checks for graph breaks and | |
| recompilation triggers during <code>torch.compile</code>.`,Pt,re,qt,ce,Rl=`<li>Use <a href="https://docs.python.org/3/c-api/stable.html#stable-application-binary-interface" rel="nofollow">ABI3/Limited API</a> | |
| for compatibility with Python 3.9 and later.</li> <li>Compatible with <a href="https://github.com/pypa/manylinux?tab=readme-ov-file#manylinux_2_28-almalinux-8-based" rel="nofollow"><code>manylinux_2_28</code></a>. | |
| This means that the extension <strong>must not</strong> use symbols versions higher than: | |
| <ul><li>GLIBC 2.28</li> <li>GLIBCXX 3.4.24</li> <li>CXXABI 1.3.11</li> <li>GCC 7.0.0</li></ul></li>`,Et,de,Xl="These requirements can be checked with the ABI checker (see below).",Zt,me,St,ue,Yl=`<li>Use <a href="https://docs.python.org/3/c-api/stable.html#stable-application-binary-interface" rel="nofollow">ABI3/Limited API</a> | |
| for compatibility with Python 3.9 and later.</li> <li>macOS deployment target 15.0.</li> <li>Metal 3.0 (<code>-std=metal3.0</code>).</li>`,Nt,he,Dl="The ABI3 requirement can be checked with the ABI checker (see below).",Wt,fe,Qt,Te,Kl=`The manylinux_2_28 and Python ABI 3.9 version requirements can be checked with | |
| <a href="https://crates.io/crates/kernel-abi-check" rel="nofollow"><code>kernel-abi-check</code></a>:`,zt,ye,Vt,Me,Ft,we,Ol=`Torch native extension functions must be <a href="https://pytorch.org/tutorials/advanced/cpp_custom_ops.html#cpp-custom-ops-tutorial" rel="nofollow">registered</a> | |
| in <code>torch.ops.<namespace></code>. Since we allow loading of multiple versions of | |
| a module in the same Python process, <code>namespace</code> must be unique for each | |
| version of a kernel. Failing to do so will create clashes when different | |
| versions of the same kernel are loaded. Two suggested ways of doing this | |
| are:`,Rt,$e,en=`<li>Appending a truncated SHA-1 hash of the git commit that the kernel was | |
| built from to the name of the extension.</li> <li>Appending random material to the name of the extension.</li>`,Xt,be,tn=`<strong>Note:</strong> we recommend against appending a version number or git tag. | |
| Version numbers are typically not bumped on each commit, so users | |
| might use two different commits that happen to have the same version | |
| number. Git tags are not stable, so they do not provide a good way | |
| of guaranteeing uniqueness of the namespace.`,Yt,Je,Dt,ve,ln=`A kernel can provide layers in addition to kernel functions. A layer from | |
| the Hub can replace the <code>forward</code> method of an existing layer for a certain | |
| device type. This makes it possible to provide more performant kernels for | |
| existing layers. See the <a href="layers">layers documentation</a> for more information | |
| on how to use layers.`,Kt,je,Ot,Ce,nn=`To make the extension of layers safe, the layers must fulfill the following | |
| requirements:`,el,Ie,sn=`<li>The layers are subclasses of <code>torch.nn.Module</code>.</li> <li>The layers are pure, meaning that they do not have their own state. This | |
| means that: | |
| <ul><li>The layer must not define its own constructor.</li> <li>The layer must not use class variables.</li></ul></li> <li>No other methods must be defined than <code>forward</code>.</li> <li>The <code>forward</code> method has a signature that is compatible with the | |
| <code>forward</code> method that it is extending.</li>`,tl,ge,an="There are two exceptions to the <em>no class variables rule</em>:",ll,Ue,on=`<li>The <code>has_backward</code> variable can be used to indicate whether the layer has | |
| a backward pass implemented (<code>True</code> when absent).</li> <li>The <code>can_torch_compile</code> variable can be used to indicate whether the layer | |
| supports <code>torch.compile</code> (<code>False</code> when absent).</li>`,nl,xe,pn="This is an example of a pure layer:",sl,ke,al,_e,rn=`For some layers, the <code>forward</code> method has to use state from the adopting class. | |
| In these cases, we recommend to use type annotations to indicate what member | |
| variables are expected. For instance:`,il,He,ol,Le,cn=`This layer expects the adopting layer to have <code>weight</code> and <code>variance_epsilon</code> | |
| member variables and uses them in the <code>forward</code> method.`,pl,Be,rl,Ae,dn=`To accommodate portable loading, <code>layers</code> must be defined in the main | |
| <code>__init__.py</code> file. For example:`,cl,Ge,dl,Pe,ml,M,Se,mn="<p>Python code must be compatible with Python 3.9 and later.</p>",yl,T,Ne,un=`All Python code imports from the kernel itself must be relative. So, | |
| for instance if in the example kernel <code>example</code>, | |
| <code>module_b</code> needs a function from <code>module_a</code>, import as:`,Ml,qe,wl,We,hn="<strong>Never use:</strong>",$l,Ee,bl,Qe,fn=`The latter would import from the module <code>example</code> that is in Python’s | |
| global module dict. However, since we allow loading multiple versions | |
| of a module, we uniquely name the module.`,Jl,ze,Tn=`<p>Only modules from the Python standard library, Torch, or the kernel itself | |
| can be imported.</p>`,ul,Ze,hl,Re,fl;return J=new jn({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),v=new f({props:{title:"Kernel requirements",local:"kernel-requirements",headingTag:"h1"}}),I=new f({props:{title:"Directory layout",local:"directory-layout",headingTag:"h2"}}),x=new f({props:{title:"Build variants",local:"build-variants",headingTag:"h2"}}),_=new f({props:{title:"Kernel metadata",local:"kernel-metadata",headingTag:"h2"}}),L=new $({props:{code:"JTdCJTBBJTIwJTIwJTIycHl0aG9uLWRlcGVuZHMlMjIlM0ElMjAlNUIlMjJlaW5vcHMlMjIlNUQlMkMlMEElMjAlMjAlMjJ2ZXJzaW9uJTIyJTNBJTIwMQ==",highlighted:`<span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"python-depends"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"einops"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span> | |
| <span class="hljs-attr">"version"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span>`,wrap:!1}}),B=new f({props:{title:"Python dependencies",local:"python-dependencies",headingTag:"h3"}}),G=new f({props:{title:"General dependencies",local:"general-dependencies",headingTag:"h4"}}),q=new $({props:{code:"JTdCJTBBJTIwJTIwJTIycHl0aG9uLWRlcGVuZHMlMjIlM0ElMjAlNUIlMjJlaW5vcHMlMjIlNUQlMEElN0Q=",highlighted:`<span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"python-depends"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"einops"</span><span class="hljs-punctuation">]</span> | |
| <span class="hljs-punctuation">}</span>`,wrap:!1}}),E=new f({props:{title:"Backend-specific dependencies",local:"backend-specific-dependencies",headingTag:"h4"}}),S=new $({props:{code:"JTdCJTBBJTIwJTIwJTIycHl0aG9uLWRlcGVuZHMtYmFja2VuZHMlMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJjdWRhJTIyJTNBJTIwJTVCJTIybnZpZGlhLWN1dGxhc3MtZHNsJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIyeHB1JTIyJTNBJTIwJTVCJTIyb25lZG5uJTIyJTVEJTBBJTIwJTIwJTdEJTBBJTdE",highlighted:`<span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"python-depends-backends"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"cuda"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"nvidia-cutlass-dsl"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span> | |
| <span class="hljs-attr">"xpu"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"onednn"</span><span class="hljs-punctuation">]</span> | |
| <span class="hljs-punctuation">}</span> | |
| <span class="hljs-punctuation">}</span>`,wrap:!1}}),N=new f({props:{title:"Combined example",local:"combined-example",headingTag:"h4"}}),Q=new $({props:{code:"JTdCJTBBJTIwJTIwJTIycHl0aG9uLWRlcGVuZHMlMjIlM0ElMjAlNUIlMjJlaW5vcHMlMjIlNUQlMkMlMEElMjAlMjAlMjJweXRob24tZGVwZW5kcy1iYWNrZW5kcyUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmN1ZGElMjIlM0ElMjAlNUIlMjJudmlkaWEtY3V0bGFzcy1kc2wlMjIlNUQlMEElMjAlMjAlN0QlMkMlMEElMjAlMjAlMjJ2ZXJzaW9uJTIyJTNBJTIwMSUwQSU3RA==",highlighted:`<span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"python-depends"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"einops"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span> | |
| <span class="hljs-attr">"python-depends-backends"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"cuda"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"nvidia-cutlass-dsl"</span><span class="hljs-punctuation">]</span> | |
| <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span> | |
| <span class="hljs-attr">"version"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span> | |
| <span class="hljs-punctuation">}</span>`,wrap:!1}}),z=new f({props:{title:"Allowed dependencies",local:"allowed-dependencies",headingTag:"h4"}}),K=new f({props:{title:"Versioning",local:"versioning",headingTag:"h2"}}),ne=new f({props:{title:"Native Python module",local:"native-python-module",headingTag:"h2"}}),ie=new f({props:{title:"Compatibility with torch.compile",local:"compatibility-with-torchcompile",headingTag:"h2"}}),re=new f({props:{title:"Linux",local:"linux",headingTag:"h3"}}),me=new f({props:{title:"macOS",local:"macos",headingTag:"h3"}}),fe=new f({props:{title:"ABI checker",local:"abi-checker",headingTag:"h3"}}),ye=new $({props:{code:"JTBBJTI0JTIwY2FyZ28lMjBpbnN0YWxsJTIwa2VybmVsLWFiaS1jaGVjayUwQSUyNCUyMGtlcm5lbC1hYmktY2hlY2slMjByZXN1bHQlMkZyZWx1JTJGX3JlbHVfZTg3ZTBjYV9kaXJ0eS5hYmkzLnNvJTBBJUYwJTlGJTkwJThEJTIwQ2hlY2tpbmclMjBmb3IlMjBjb21wYXRpYmlsaXR5JTIwd2l0aCUyMG1hbnlsaW51eF8yXzI4JTIwYW5kJTIwUHl0aG9uJTIwQUJJJTIwdmVyc2lvbiUyMDMuOSUwQSVFMiU5QyU4NSUyME5vJTIwY29tcGF0aWJpbGl0eSUyMGlzc3VlcyUyMGZvdW5k",highlighted:` | |
| $ cargo install kernel-abi-check | |
| $ kernel-abi-check result/relu/_relu_e87e0ca_dirty.abi3.so | |
| 🐍 Checking <span class="hljs-keyword">for</span> compatibility with manylinux_2_28 and Python ABI version 3.9 | |
| ✅ No compatibility issues found`,wrap:!1}}),Me=new f({props:{title:"Torch extension",local:"torch-extension",headingTag:"h2"}}),Je=new f({props:{title:"Layers",local:"layers",headingTag:"h2"}}),je=new f({props:{title:"Writing layers",local:"writing-layers",headingTag:"h3"}}),ke=new $({props:{code:"Y2xhc3MlMjBTaWx1QW5kTXVsKG5uLk1vZHVsZSklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjBUaGlzJTIwbGF5ZXIlMjBkb2VzJTIwbm90JTIwaW1wbGVtZW50JTIwYmFja3dhcmQuJTBBJTIwJTIwJTIwJTIwaGFzX2JhY2t3YXJkJTNBJTIwYm9vbCUyMCUzRCUyMEZhbHNlJTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwZm9yd2FyZChzZWxmJTJDJTIweCUzQSUyMHRvcmNoLlRlbnNvciklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkJTIwJTNEJTIweC5zaGFwZSU1Qi0xJTVEJTIwJTJGJTJGJTIwMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dHB1dF9zaGFwZSUyMCUzRCUyMHguc2hhcGUlNUIlM0EtMSU1RCUyMCUyQiUyMChkJTJDKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dCUyMCUzRCUyMHRvcmNoLmVtcHR5KG91dHB1dF9zaGFwZSUyQyUyMGR0eXBlJTNEeC5kdHlwZSUyQyUyMGRldmljZSUzRHguZGV2aWNlKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG9wcy5zaWx1X2FuZF9tdWwob3V0JTJDJTIweCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBvdXQ=",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">SiluAndMul</span>(nn.Module): | |
| <span class="hljs-comment"># This layer does not implement backward.</span> | |
| has_backward: <span class="hljs-built_in">bool</span> = <span class="hljs-literal">False</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, x: torch.Tensor</span>): | |
| d = x.shape[-<span class="hljs-number">1</span>] // <span class="hljs-number">2</span> | |
| output_shape = x.shape[:-<span class="hljs-number">1</span>] + (d,) | |
| out = torch.empty(output_shape, dtype=x.dtype, device=x.device) | |
| ops.silu_and_mul(out, x) | |
| <span class="hljs-keyword">return</span> out`,wrap:!1}}),He=new $({props:{code:"Y2xhc3MlMjBMbGFtYVJNU05vcm0obm4uTW9kdWxlKSUzQSUwQSUyMCUyMCUyMCUyMHdlaWdodCUzQSUyMHRvcmNoLlRlbnNvciUwQSUyMCUyMCUyMCUyMHZhcmlhbmNlX2Vwc2lsb24lM0ElMjBmbG9hdCUwQSUwQSUyMCUyMCUyMCUyMGRlZiUyMGZvcndhcmQoc2VsZiUyQyUyMGhpZGRlbl9zdGF0ZXMlM0ElMjB0b3JjaC5UZW5zb3IpJTIwLSUzRSUyMHRvcmNoLlRlbnNvciUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMHJtc19ub3JtX2ZuKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGhpZGRlbl9zdGF0ZXMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzZWxmLndlaWdodCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJpYXMlM0ROb25lJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVzaWR1YWwlM0ROb25lJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZXBzJTNEc2VsZi52YXJpYW5jZV9lcHNpbG9uJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZHJvcG91dF9wJTNEMC4wJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJlbm9ybSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVzaWR1YWxfaW5fZnAzMiUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKQ==",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">LlamaRMSNorm</span>(nn.Module): | |
| weight: torch.Tensor | |
| variance_epsilon: <span class="hljs-built_in">float</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, hidden_states: torch.Tensor</span>) -> torch.Tensor: | |
| <span class="hljs-keyword">return</span> rms_norm_fn( | |
| hidden_states, | |
| self.weight, | |
| bias=<span class="hljs-literal">None</span>, | |
| residual=<span class="hljs-literal">None</span>, | |
| eps=self.variance_epsilon, | |
| dropout_p=<span class="hljs-number">0.0</span>, | |
| prenorm=<span class="hljs-literal">False</span>, | |
| residual_in_fp32=<span class="hljs-literal">False</span>, | |
| )`,wrap:!1}}),Be=new f({props:{title:"Exporting layers",local:"exporting-layers",headingTag:"h3"}}),Ge=new $({props:{code:"ZnJvbSUyMC4lMjBpbXBvcnQlMjBsYXllcnMlMEElMEFfX2FsbF9fJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIzJTIwLi4uJTBBJTIwJTIwJTIybGF5ZXJzJTIyJTBBJTIwJTIwJTIzJTIwLi4uJTBBJTVE",highlighted:`<span class="hljs-keyword">from</span> . <span class="hljs-keyword">import</span> layers | |
| __all__ = [ | |
| <span class="hljs-comment"># ...</span> | |
| <span class="hljs-string">"layers"</span> | |
| <span class="hljs-comment"># ...</span> | |
| ]`,wrap:!1}}),Pe=new f({props:{title:"Python requirements",local:"python-requirements",headingTag:"h2"}}),qe=new $({props:{code:"ZnJvbSUyMC5tb2R1bGVfYSUyMGltcG9ydCUyMGZvbw==",highlighted:'<span class="hljs-keyword">from</span> .module_a <span class="hljs-keyword">import</span> foo',wrap:!1}}),Ee=new $({props:{code:"JTIzJTIwRE8lMjBOT1QlMjBETyUyMFRISVMhJTBBJTBBZnJvbSUyMGV4YW1wbGUubW9kdWxlX2ElMjBpbXBvcnQlMjBmb28=",highlighted:`<span class="hljs-comment"># DO NOT DO THIS!</span> | |
| <span class="hljs-keyword">from</span> example.module_a <span class="hljs-keyword">import</span> foo`,wrap:!1}}),Ze=new Cn({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/kernel-requirements.md"}}),{c(){b=i("meta"),Xe=s(),Fe=i("p"),Ye=s(),r(J.$$.fragment),De=s(),r(v.$$.fragment),Ke=s(),j=i("p"),j.textContent=jl,Oe=s(),C=i("p"),C.innerHTML=Cl,et=s(),r(I.$$.fragment),tt=s(),g=i("p"),g.innerHTML=Il,lt=s(),U=i("p"),U.innerHTML=gl,nt=s(),r(x.$$.fragment),st=s(),k=i("p"),k.innerHTML=Ul,at=s(),r(_.$$.fragment),it=s(),H=i("p"),H.innerHTML=xl,ot=s(),r(L.$$.fragment),pt=s(),r(B.$$.fragment),rt=s(),A=i("p"),A.textContent=kl,ct=s(),r(G.$$.fragment),dt=s(),P=i("p"),P.innerHTML=_l,mt=s(),r(q.$$.fragment),ut=s(),r(E.$$.fragment),ht=s(),Z=i("p"),Z.innerHTML=Hl,ft=s(),r(S.$$.fragment),Tt=s(),r(N.$$.fragment),yt=s(),W=i("p"),W.textContent=Ll,Mt=s(),r(Q.$$.fragment),wt=s(),r(z.$$.fragment),$t=s(),V=i("p"),V.textContent=Bl,bt=s(),F=i("p"),F.innerHTML=Al,Jt=s(),R=i("ul"),R.innerHTML=Gl,vt=s(),X=i("p"),X.innerHTML=Pl,jt=s(),Y=i("ul"),Y.innerHTML=ql,Ct=s(),D=i("p"),D.textContent=El,It=s(),r(K.$$.fragment),gt=s(),O=i("p"),O.innerHTML=Zl,Ut=s(),ee=i("p"),ee.innerHTML=Sl,xt=s(),te=i("ul"),te.innerHTML=Nl,kt=s(),le=i("p"),le.textContent=Wl,_t=s(),r(ne.$$.fragment),Ht=s(),se=i("p"),se.textContent=Ql,Lt=s(),ae=i("ul"),ae.innerHTML=zl,Bt=s(),r(ie.$$.fragment),At=s(),oe=i("p"),oe.innerHTML=Vl,Gt=s(),pe=i("p"),pe.innerHTML=Fl,Pt=s(),r(re.$$.fragment),qt=s(),ce=i("ul"),ce.innerHTML=Rl,Et=s(),de=i("p"),de.textContent=Xl,Zt=s(),r(me.$$.fragment),St=s(),ue=i("ul"),ue.innerHTML=Yl,Nt=s(),he=i("p"),he.textContent=Dl,Wt=s(),r(fe.$$.fragment),Qt=s(),Te=i("p"),Te.innerHTML=Kl,zt=s(),r(ye.$$.fragment),Vt=s(),r(Me.$$.fragment),Ft=s(),we=i("p"),we.innerHTML=Ol,Rt=s(),$e=i("ul"),$e.innerHTML=en,Xt=s(),be=i("p"),be.innerHTML=tn,Yt=s(),r(Je.$$.fragment),Dt=s(),ve=i("p"),ve.innerHTML=ln,Kt=s(),r(je.$$.fragment),Ot=s(),Ce=i("p"),Ce.textContent=nn,el=s(),Ie=i("ul"),Ie.innerHTML=sn,tl=s(),ge=i("p"),ge.innerHTML=an,ll=s(),Ue=i("ol"),Ue.innerHTML=on,nl=s(),xe=i("p"),xe.textContent=pn,sl=s(),r(ke.$$.fragment),al=s(),_e=i("p"),_e.innerHTML=rn,il=s(),r(He.$$.fragment),ol=s(),Le=i("p"),Le.innerHTML=cn,pl=s(),r(Be.$$.fragment),rl=s(),Ae=i("p"),Ae.innerHTML=dn,cl=s(),r(Ge.$$.fragment),dl=s(),r(Pe.$$.fragment),ml=s(),M=i("ul"),Se=i("li"),Se.innerHTML=mn,yl=s(),T=i("li"),Ne=i("p"),Ne.innerHTML=un,Ml=s(),r(qe.$$.fragment),wl=s(),We=i("p"),We.innerHTML=hn,$l=s(),r(Ee.$$.fragment),bl=s(),Qe=i("p"),Qe.innerHTML=fn,Jl=s(),ze=i("li"),ze.innerHTML=Tn,ul=s(),r(Ze.$$.fragment),hl=s(),Re=i("p"),this.h()},l(e){const t=vn("svelte-u9bgzb",document.head);b=o(t,"META",{name:!0,content:!0}),t.forEach(l),Xe=a(e),Fe=o(e,"P",{}),Tl(Fe).forEach(l),Ye=a(e),c(J.$$.fragment,e),De=a(e),c(v.$$.fragment,e),Ke=a(e),j=o(e,"P",{"data-svelte-h":!0}),p(j)!=="svelte-omjx4j"&&(j.textContent=jl),Oe=a(e),C=o(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-yaa16r"&&(C.innerHTML=Cl),et=a(e),c(I.$$.fragment,e),tt=a(e),g=o(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-1j93b1m"&&(g.innerHTML=Il),lt=a(e),U=o(e,"P",{"data-svelte-h":!0}),p(U)!=="svelte-lxb45a"&&(U.innerHTML=gl),nt=a(e),c(x.$$.fragment,e),st=a(e),k=o(e,"P",{"data-svelte-h":!0}),p(k)!=="svelte-1hncd2g"&&(k.innerHTML=Ul),at=a(e),c(_.$$.fragment,e),it=a(e),H=o(e,"P",{"data-svelte-h":!0}),p(H)!=="svelte-1c33u59"&&(H.innerHTML=xl),ot=a(e),c(L.$$.fragment,e),pt=a(e),c(B.$$.fragment,e),rt=a(e),A=o(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-1pdg251"&&(A.textContent=kl),ct=a(e),c(G.$$.fragment,e),dt=a(e),P=o(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-dqzi4g"&&(P.innerHTML=_l),mt=a(e),c(q.$$.fragment,e),ut=a(e),c(E.$$.fragment,e),ht=a(e),Z=o(e,"P",{"data-svelte-h":!0}),p(Z)!=="svelte-uq0jdp"&&(Z.innerHTML=Hl),ft=a(e),c(S.$$.fragment,e),Tt=a(e),c(N.$$.fragment,e),yt=a(e),W=o(e,"P",{"data-svelte-h":!0}),p(W)!=="svelte-9otw7q"&&(W.textContent=Ll),Mt=a(e),c(Q.$$.fragment,e),wt=a(e),c(z.$$.fragment,e),$t=a(e),V=o(e,"P",{"data-svelte-h":!0}),p(V)!=="svelte-kluci1"&&(V.textContent=Bl),bt=a(e),F=o(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-1rr3jv8"&&(F.innerHTML=Al),Jt=a(e),R=o(e,"UL",{"data-svelte-h":!0}),p(R)!=="svelte-1qqxtz8"&&(R.innerHTML=Gl),vt=a(e),X=o(e,"P",{"data-svelte-h":!0}),p(X)!=="svelte-1yeojtn"&&(X.innerHTML=Pl),jt=a(e),Y=o(e,"UL",{"data-svelte-h":!0}),p(Y)!=="svelte-hilu6n"&&(Y.innerHTML=ql),Ct=a(e),D=o(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-18gtut1"&&(D.textContent=El),It=a(e),c(K.$$.fragment,e),gt=a(e),O=o(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-291nyo"&&(O.innerHTML=Zl),Ut=a(e),ee=o(e,"P",{"data-svelte-h":!0}),p(ee)!=="svelte-p4w3tj"&&(ee.innerHTML=Sl),xt=a(e),te=o(e,"UL",{"data-svelte-h":!0}),p(te)!=="svelte-1lnxf46"&&(te.innerHTML=Nl),kt=a(e),le=o(e,"P",{"data-svelte-h":!0}),p(le)!=="svelte-xiq7bp"&&(le.textContent=Wl),_t=a(e),c(ne.$$.fragment,e),Ht=a(e),se=o(e,"P",{"data-svelte-h":!0}),p(se)!=="svelte-17te4hc"&&(se.textContent=Ql),Lt=a(e),ae=o(e,"UL",{"data-svelte-h":!0}),p(ae)!=="svelte-17x1sgf"&&(ae.innerHTML=zl),Bt=a(e),c(ie.$$.fragment,e),At=a(e),oe=o(e,"P",{"data-svelte-h":!0}),p(oe)!=="svelte-f057os"&&(oe.innerHTML=Vl),Gt=a(e),pe=o(e,"P",{"data-svelte-h":!0}),p(pe)!=="svelte-d91b09"&&(pe.innerHTML=Fl),Pt=a(e),c(re.$$.fragment,e),qt=a(e),ce=o(e,"UL",{"data-svelte-h":!0}),p(ce)!=="svelte-1z0ex63"&&(ce.innerHTML=Rl),Et=a(e),de=o(e,"P",{"data-svelte-h":!0}),p(de)!=="svelte-vq3k4i"&&(de.textContent=Xl),Zt=a(e),c(me.$$.fragment,e),St=a(e),ue=o(e,"UL",{"data-svelte-h":!0}),p(ue)!=="svelte-nrm36c"&&(ue.innerHTML=Yl),Nt=a(e),he=o(e,"P",{"data-svelte-h":!0}),p(he)!=="svelte-1xbbttu"&&(he.textContent=Dl),Wt=a(e),c(fe.$$.fragment,e),Qt=a(e),Te=o(e,"P",{"data-svelte-h":!0}),p(Te)!=="svelte-16l01xm"&&(Te.innerHTML=Kl),zt=a(e),c(ye.$$.fragment,e),Vt=a(e),c(Me.$$.fragment,e),Ft=a(e),we=o(e,"P",{"data-svelte-h":!0}),p(we)!=="svelte-1z00i8l"&&(we.innerHTML=Ol),Rt=a(e),$e=o(e,"UL",{"data-svelte-h":!0}),p($e)!=="svelte-1n44n6m"&&($e.innerHTML=en),Xt=a(e),be=o(e,"P",{"data-svelte-h":!0}),p(be)!=="svelte-vo8uhp"&&(be.innerHTML=tn),Yt=a(e),c(Je.$$.fragment,e),Dt=a(e),ve=o(e,"P",{"data-svelte-h":!0}),p(ve)!=="svelte-whdu77"&&(ve.innerHTML=ln),Kt=a(e),c(je.$$.fragment,e),Ot=a(e),Ce=o(e,"P",{"data-svelte-h":!0}),p(Ce)!=="svelte-ew142v"&&(Ce.textContent=nn),el=a(e),Ie=o(e,"UL",{"data-svelte-h":!0}),p(Ie)!=="svelte-d986sl"&&(Ie.innerHTML=sn),tl=a(e),ge=o(e,"P",{"data-svelte-h":!0}),p(ge)!=="svelte-17brked"&&(ge.innerHTML=an),ll=a(e),Ue=o(e,"OL",{"data-svelte-h":!0}),p(Ue)!=="svelte-1a9mvrx"&&(Ue.innerHTML=on),nl=a(e),xe=o(e,"P",{"data-svelte-h":!0}),p(xe)!=="svelte-mthj86"&&(xe.textContent=pn),sl=a(e),c(ke.$$.fragment,e),al=a(e),_e=o(e,"P",{"data-svelte-h":!0}),p(_e)!=="svelte-1xsl1kb"&&(_e.innerHTML=rn),il=a(e),c(He.$$.fragment,e),ol=a(e),Le=o(e,"P",{"data-svelte-h":!0}),p(Le)!=="svelte-9hcs08"&&(Le.innerHTML=cn),pl=a(e),c(Be.$$.fragment,e),rl=a(e),Ae=o(e,"P",{"data-svelte-h":!0}),p(Ae)!=="svelte-1jwjnkj"&&(Ae.innerHTML=dn),cl=a(e),c(Ge.$$.fragment,e),dl=a(e),c(Pe.$$.fragment,e),ml=a(e),M=o(e,"UL",{});var Ve=Tl(M);Se=o(Ve,"LI",{"data-svelte-h":!0}),p(Se)!=="svelte-1yjmw8t"&&(Se.innerHTML=mn),yl=a(Ve),T=o(Ve,"LI",{});var w=Tl(T);Ne=o(w,"P",{"data-svelte-h":!0}),p(Ne)!=="svelte-1xx048c"&&(Ne.innerHTML=un),Ml=a(w),c(qe.$$.fragment,w),wl=a(w),We=o(w,"P",{"data-svelte-h":!0}),p(We)!=="svelte-ca1g42"&&(We.innerHTML=hn),$l=a(w),c(Ee.$$.fragment,w),bl=a(w),Qe=o(w,"P",{"data-svelte-h":!0}),p(Qe)!=="svelte-1v83762"&&(Qe.innerHTML=fn),w.forEach(l),Jl=a(Ve),ze=o(Ve,"LI",{"data-svelte-h":!0}),p(ze)!=="svelte-wkdo8"&&(ze.innerHTML=Tn),Ve.forEach(l),ul=a(e),c(Ze.$$.fragment,e),hl=a(e),Re=o(e,"P",{}),Tl(Re).forEach(l),this.h()},h(){yn(b,"name","hf:doc:metadata"),yn(b,"content",gn)},m(e,t){y(document.head,b),n(e,Xe,t),n(e,Fe,t),n(e,Ye,t),d(J,e,t),n(e,De,t),d(v,e,t),n(e,Ke,t),n(e,j,t),n(e,Oe,t),n(e,C,t),n(e,et,t),d(I,e,t),n(e,tt,t),n(e,g,t),n(e,lt,t),n(e,U,t),n(e,nt,t),d(x,e,t),n(e,st,t),n(e,k,t),n(e,at,t),d(_,e,t),n(e,it,t),n(e,H,t),n(e,ot,t),d(L,e,t),n(e,pt,t),d(B,e,t),n(e,rt,t),n(e,A,t),n(e,ct,t),d(G,e,t),n(e,dt,t),n(e,P,t),n(e,mt,t),d(q,e,t),n(e,ut,t),d(E,e,t),n(e,ht,t),n(e,Z,t),n(e,ft,t),d(S,e,t),n(e,Tt,t),d(N,e,t),n(e,yt,t),n(e,W,t),n(e,Mt,t),d(Q,e,t),n(e,wt,t),d(z,e,t),n(e,$t,t),n(e,V,t),n(e,bt,t),n(e,F,t),n(e,Jt,t),n(e,R,t),n(e,vt,t),n(e,X,t),n(e,jt,t),n(e,Y,t),n(e,Ct,t),n(e,D,t),n(e,It,t),d(K,e,t),n(e,gt,t),n(e,O,t),n(e,Ut,t),n(e,ee,t),n(e,xt,t),n(e,te,t),n(e,kt,t),n(e,le,t),n(e,_t,t),d(ne,e,t),n(e,Ht,t),n(e,se,t),n(e,Lt,t),n(e,ae,t),n(e,Bt,t),d(ie,e,t),n(e,At,t),n(e,oe,t),n(e,Gt,t),n(e,pe,t),n(e,Pt,t),d(re,e,t),n(e,qt,t),n(e,ce,t),n(e,Et,t),n(e,de,t),n(e,Zt,t),d(me,e,t),n(e,St,t),n(e,ue,t),n(e,Nt,t),n(e,he,t),n(e,Wt,t),d(fe,e,t),n(e,Qt,t),n(e,Te,t),n(e,zt,t),d(ye,e,t),n(e,Vt,t),d(Me,e,t),n(e,Ft,t),n(e,we,t),n(e,Rt,t),n(e,$e,t),n(e,Xt,t),n(e,be,t),n(e,Yt,t),d(Je,e,t),n(e,Dt,t),n(e,ve,t),n(e,Kt,t),d(je,e,t),n(e,Ot,t),n(e,Ce,t),n(e,el,t),n(e,Ie,t),n(e,tl,t),n(e,ge,t),n(e,ll,t),n(e,Ue,t),n(e,nl,t),n(e,xe,t),n(e,sl,t),d(ke,e,t),n(e,al,t),n(e,_e,t),n(e,il,t),d(He,e,t),n(e,ol,t),n(e,Le,t),n(e,pl,t),d(Be,e,t),n(e,rl,t),n(e,Ae,t),n(e,cl,t),d(Ge,e,t),n(e,dl,t),d(Pe,e,t),n(e,ml,t),n(e,M,t),y(M,Se),y(M,yl),y(M,T),y(T,Ne),y(T,Ml),d(qe,T,null),y(T,wl),y(T,We),y(T,$l),d(Ee,T,null),y(T,bl),y(T,Qe),y(M,Jl),y(M,ze),n(e,ul,t),d(Ze,e,t),n(e,hl,t),n(e,Re,t),fl=!0},p:wn,i(e){fl||(m(J.$$.fragment,e),m(v.$$.fragment,e),m(I.$$.fragment,e),m(x.$$.fragment,e),m(_.$$.fragment,e),m(L.$$.fragment,e),m(B.$$.fragment,e),m(G.$$.fragment,e),m(q.$$.fragment,e),m(E.$$.fragment,e),m(S.$$.fragment,e),m(N.$$.fragment,e),m(Q.$$.fragment,e),m(z.$$.fragment,e),m(K.$$.fragment,e),m(ne.$$.fragment,e),m(ie.$$.fragment,e),m(re.$$.fragment,e),m(me.$$.fragment,e),m(fe.$$.fragment,e),m(ye.$$.fragment,e),m(Me.$$.fragment,e),m(Je.$$.fragment,e),m(je.$$.fragment,e),m(ke.$$.fragment,e),m(He.$$.fragment,e),m(Be.$$.fragment,e),m(Ge.$$.fragment,e),m(Pe.$$.fragment,e),m(qe.$$.fragment,e),m(Ee.$$.fragment,e),m(Ze.$$.fragment,e),fl=!0)},o(e){u(J.$$.fragment,e),u(v.$$.fragment,e),u(I.$$.fragment,e),u(x.$$.fragment,e),u(_.$$.fragment,e),u(L.$$.fragment,e),u(B.$$.fragment,e),u(G.$$.fragment,e),u(q.$$.fragment,e),u(E.$$.fragment,e),u(S.$$.fragment,e),u(N.$$.fragment,e),u(Q.$$.fragment,e),u(z.$$.fragment,e),u(K.$$.fragment,e),u(ne.$$.fragment,e),u(ie.$$.fragment,e),u(re.$$.fragment,e),u(me.$$.fragment,e),u(fe.$$.fragment,e),u(ye.$$.fragment,e),u(Me.$$.fragment,e),u(Je.$$.fragment,e),u(je.$$.fragment,e),u(ke.$$.fragment,e),u(He.$$.fragment,e),u(Be.$$.fragment,e),u(Ge.$$.fragment,e),u(Pe.$$.fragment,e),u(qe.$$.fragment,e),u(Ee.$$.fragment,e),u(Ze.$$.fragment,e),fl=!1},d(e){e&&(l(Xe),l(Fe),l(Ye),l(De),l(Ke),l(j),l(Oe),l(C),l(et),l(tt),l(g),l(lt),l(U),l(nt),l(st),l(k),l(at),l(it),l(H),l(ot),l(pt),l(rt),l(A),l(ct),l(dt),l(P),l(mt),l(ut),l(ht),l(Z),l(ft),l(Tt),l(yt),l(W),l(Mt),l(wt),l($t),l(V),l(bt),l(F),l(Jt),l(R),l(vt),l(X),l(jt),l(Y),l(Ct),l(D),l(It),l(gt),l(O),l(Ut),l(ee),l(xt),l(te),l(kt),l(le),l(_t),l(Ht),l(se),l(Lt),l(ae),l(Bt),l(At),l(oe),l(Gt),l(pe),l(Pt),l(qt),l(ce),l(Et),l(de),l(Zt),l(St),l(ue),l(Nt),l(he),l(Wt),l(Qt),l(Te),l(zt),l(Vt),l(Ft),l(we),l(Rt),l($e),l(Xt),l(be),l(Yt),l(Dt),l(ve),l(Kt),l(Ot),l(Ce),l(el),l(Ie),l(tl),l(ge),l(ll),l(Ue),l(nl),l(xe),l(sl),l(al),l(_e),l(il),l(ol),l(Le),l(pl),l(rl),l(Ae),l(cl),l(dl),l(ml),l(M),l(ul),l(hl),l(Re)),l(b),h(J,e),h(v,e),h(I,e),h(x,e),h(_,e),h(L,e),h(B,e),h(G,e),h(q,e),h(E,e),h(S,e),h(N,e),h(Q,e),h(z,e),h(K,e),h(ne,e),h(ie,e),h(re,e),h(me,e),h(fe,e),h(ye,e),h(Me,e),h(Je,e),h(je,e),h(ke,e),h(He,e),h(Be,e),h(Ge,e),h(Pe,e),h(qe),h(Ee),h(Ze,e)}}}const gn='{"title":"Kernel requirements","local":"kernel-requirements","sections":[{"title":"Directory layout","local":"directory-layout","sections":[],"depth":2},{"title":"Build variants","local":"build-variants","sections":[],"depth":2},{"title":"Kernel metadata","local":"kernel-metadata","sections":[{"title":"Python dependencies","local":"python-dependencies","sections":[{"title":"General dependencies","local":"general-dependencies","sections":[],"depth":4},{"title":"Backend-specific dependencies","local":"backend-specific-dependencies","sections":[],"depth":4},{"title":"Combined example","local":"combined-example","sections":[],"depth":4},{"title":"Allowed dependencies","local":"allowed-dependencies","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"Versioning","local":"versioning","sections":[],"depth":2},{"title":"Native Python module","local":"native-python-module","sections":[],"depth":2},{"title":"Compatibility with torch.compile","local":"compatibility-with-torchcompile","sections":[{"title":"Linux","local":"linux","sections":[],"depth":3},{"title":"macOS","local":"macos","sections":[],"depth":3},{"title":"ABI checker","local":"abi-checker","sections":[],"depth":3}],"depth":2},{"title":"Torch extension","local":"torch-extension","sections":[],"depth":2},{"title":"Layers","local":"layers","sections":[{"title":"Writing layers","local":"writing-layers","sections":[],"depth":3},{"title":"Exporting layers","local":"exporting-layers","sections":[],"depth":3}],"depth":2},{"title":"Python requirements","local":"python-requirements","sections":[],"depth":2}],"depth":1}';function Un(vl){return $n(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bn extends bn{constructor(b){super(),Jn(this,b,Un,In,Mn,{})}}export{Bn as component}; | |
Xet Storage Details
- Size:
- 33.7 kB
- Xet hash:
- afec53bb3266ed3dc8e7b53248f662e4f64437c8c7bd478b424f6264bc2df915
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.