import{s as Wt,n as Gt,o as St}from"../chunks/scheduler.f3b1e791.js";import{S as Ht,i as Qt,e as i,s as M,c as o,h as Lt,a,d as t,b as n,f as Bt,g as y,j as r,k as Zt,l as Vt,m as s,n as T,t as p,o as U,p as J}from"../chunks/index.023a9934.js";import{C as xt}from"../chunks/CopyLLMTxtMenu.ee636735.js";import{C as w}from"../chunks/CodeBlock.5aa52fca.js";import{H as c,E as Xt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9b009efe.js";function zt(Dl){let m,Be,_e,Ze,d,We,u,Ge,j,et=`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.`,Se,C,lt=`See <a href="kernel-requirements">Kernel requirements</a> for more information on the
requirements of Hub layers.`,He,I,Qe,f,Le,h,tt=`A layer can be made extensible with the <code>use_kernel_forward_from_hub</code>
decorator. For example:`,Ve,A,xe,b,st=`The decorator does not change the behavior of the class — it annotates
the class with the given name (here <code>SiluAndMul</code>). The <code>kernelize</code> function
described below uses this name to look up kernels for the layer.`,Xe,k,ze,g,Mt=`An existing layer that does not (yet) have the <code>use_kernel_forward_from_hub</code>
decorator can be made extensible using the <code>replace_kernel_forward_from_hub</code>
function:`,Fe,$,qe,E,nt=`<strong>Warning:</strong> we strongly recommend using layers with a decorator, since
it signifies that the maintainer intends to keep the <code>forward</code> signature
compatible with layers from the hub.`,Ye,R,Pe,v,it=`Sometimes it can be useful to make a function extensible, for example
because the function cannot be replaced by a layer. In such cases, you
can annotate the function with the <code>use_kernel_func_from_hub</code> decorator:`,Ke,_,Oe,N,at=`This will replace the function by an instantiated <code>torch.nn.Module</code>
(singleton) that calls the function itself in its forward method.`,De,B,rt=`<strong>Note:</strong> for kernelization to see the function, it must be a member of
another <code>torch.nn.Module</code> that is part of the model. For example:`,el,Z,ll,W,tl,G,ot=`A model will not use Hub kernels by default, even if it contains extensible
layers. To enable the use of Hub kernels in the model, it needs to be
‘kernelized’ using the <code>kernelize</code> function. This function traverses the
model graph and replaces the <code>forward</code> methods of extensible layers for which
Hub kernels are registered. <code>kernelize</code> can be used as follows:`,sl,S,Ml,H,yt=`The <code>kernelize</code> function modifies the model in-place, the model itself is
returned as a convenience. The <code>mode</code> specifies that the model will be used
in inference. Similarly, you can ask <code>kernelize</code> to prepare the model for
training:`,nl,Q,il,L,Tt=`A model that is kernelized for training can also be used for inference, but
not the other way around. If you want to change the mode of the kernelized
model, you can just run <code>kernelize</code> on the model again with the new mode.`,al,V,pt=`If you want to compile a model with <code>torch.compile</code>, this should be indicated
in the mode as well. You can do this by combining <code>Mode.INFERENCE</code> or
<code>Mode.TRAINING</code> with <code>Mode.TORCH_COMPILE</code> using the set union (<code>|</code>) operator:`,rl,x,ol,X,yl,z,Ut=`Kernels can be registered per device type. For instance, separate <code>cuda</code> and
<code>metal</code> kernels could be registered for the name <code>SiluAndMul</code>. By default,
<code>kernelize</code> will try to infer the device type from the model’s parameters.
You can pass the device type to <code>kernelize</code> if the device type cannot be
inferred (e.g. because the model has no parameters):`,Tl,F,pl,q,Ul,Y,Jt=`If the <code>TRAINING</code> and/or <code>TORCH_COMPILE</code> modes are used, but a registered
kernel does not support backward passes or <code>torch.compile</code> respectively,
<code>kernelize</code> will fall back to the original, non-kernelized, layer. You
can let <code>kernelize</code> raise an exception instead by using <code>use_fallback=False</code>:`,Jl,P,wl,K,wt="This can be useful if you want to guarantee that Hub kernels are used.",cl,O,ml,D,ct=`The kernels that are used are logged at the <code>INFO</code> level by <code>kernelize</code>.
See the <a href="https://docs.python.org/3/library/logging.html" rel="nofollow">Python logging</a>
documentation for information on how to configure logging.`,dl,ee,ul,le,mt=`<code>kernelize</code> relies on kernel mappings to find Hub kernels for layers.
Kernel mappings map a kernel name such as <code>SiluAndMul</code> to a kernel on
the Hub. For example:`,jl,te,Cl,se,dt=`This uses version <code>1</code> of the <code>SiluAndMul</code> kernel layer from
<code>kernels-community/activation</code> for the <code>cuda</code> and <code>rocm</code> backends. Kernel
layers are versioned using a major version number. Using <code>version=1</code>
will get the latest kernel build from the <code>v1</code> branch. Kernel layers
within a version branch must never break the API or remove builds for
older PyTorch versions. This ensures that your code will continue to
work.`,Il,Me,ut=`Some kernels have not yet been updated to use versioning yet. In these cases,
you can use <code>LayerRepository</code> without the <code>version</code> argument.`,fl,ne,jt="You can register a mapping, like the one above, using <code>register_kernel_mapping</code>:",hl,ie,Al,ae,Ct=`This will register the kernel mapping in the current context, which is
normally global. It is recommended to scope the mapping to where it is
used with the <code>use_kernel_mapping</code> context manager:`,bl,re,kl,oe,It=`This ensures that the mapping is not active anymore outside the
<code>with</code>-scope.`,gl,ye,ft=`If the layer is stateless (it does not use member variables in its forward <em>or</em> it was
originally a function that was converted into a kernel layer with
<code>use_kernel_func_from_hub</code>), it can also be mapped to a kernel function:`,$l,Te,El,pe,Rl,Ue,ht=`You might want to register two different kernels for a particular layer,
where one kernel is optimized for a specific mode. You can do so by
registering layer repositories for specific modes. For example:`,vl,Je,_l,we,At=`The <code>kernelize</code> function will attempt to use the following registered
kernels for a given mode:`,Nl,ce,bt=`<li><code>INFERENCE</code>: <code>INFERENCE</code> → <code>INFERENCE | TORCH_COMPILE</code> → <code>TRAINING</code> →
<code>TRAINING | TORCH_COMPILE</code> → <code>FALLBACK</code></li> <li><code>INFERENCE | TORCH_COMPILE</code>: <code>INFERENCE | TORCH_COMPILE</code> →
<code>TRAINING | TORCH_COMPILE</code> → <code>FALLBACK</code></li> <li><code>TRAINING</code>: <code>TRAINING</code> → <code>TRAINING | TORCH_COMPILE</code> → <code>FALLBACK</code></li> <li><code>TRAINING | TORCH_COMPILE</code>: <code>TRAINING | TORCH_COMPILE</code> → <code>FALLBACK</code></li>`,Bl,me,kt=`<code>Mode.FALLBACK</code> is a special mode that is used when no other mode matches. It
is also used when a kernel is registered without a mode, as described in the
previous section.`,Zl,de,Wl,ue,gt=`In this case, both <code>Mode.INFERENCE | Mode.TORCH_COMPILE</code> and
<code>Mode.TRAINING | Mode.TORCH_COMPILE</code> will use the <code>Mode.FALLBACK</code> kernel,
since the other kernels do not support <code>torch.compile</code>.`,Gl,je,Sl,Ce,$t=`Some kernels only work with newer CUDA architectures. For instance, some
kernels require capability 9.0 for the TMA unit on Hopper GPUs. <code>kernels</code>
supports registering layers for a range of CUDA capabilities. To do so,
you need to register the layer for a <code>Device</code> with type <code>cuda</code> and
set the supported range of CUDA capabilities with using <code>CUDAProperties</code>:`,Hl,Ie,Ql,fe,Et="Capabilities behave as follows:",Ll,he,Rt=`<li><p>The minimum and maximum capabilities are inclusive.</p></li> <li><p>When a new kernel is registered with the same min/max capabilities as
an existing kernel, the new kernel will replace the old kernel.</p></li> <li><p>When there are multiple kernels that support a capability, the kernel
with the smaller capability interval will be used. E.g. given:</p> <ul><li><code>KernelA</code> with <code>min_capability=80</code> and <code>max_capability=89</code>;</li> <li><code>KernelB</code> with <code>min_capability=75</code> and <code>max_capability=89</code>;</li> <li><code>kernelize</code> runs on a system with capability 8.6.</li></ul> <p>Then <code>KernelA</code> will be used because the interval 80..89 is smaller
than 75..89. The motivation is that kernels with smaller ranges
tend to be more optimized for a specific set of GPUs. <strong>This behavior
might still change in the future.</strong></p></li>`,Vl,Ae,xl,be,vt=`Registering kernels for the ROCm architecture follows the exact same
pattern as CUDA kernels, using <code>min_capability</code> and <code>max_capability</code> to restrict
a kernel to a range of ROCm capabilities.`,Xl,ke,zl,ge,_t=`The <code>LocalLayerRepository</code> class is provided to load a repository from
a local directory. For example:`,Fl,$e,ql,Ee,Nt=`Similarly, the <code>LocalFuncRepository</code> class can be used to load a kernel
function from a local directory:`,Yl,Re,Pl,ve,Kl,Ne,Ol;return d=new xt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),u=new c({props:{title:"Layers",local:"layers",headingTag:"h1"}}),I=new c({props:{title:"Making a layer extensible with kernels from the hub",local:"making-a-layer-extensible-with-kernels-from-the-hub",headingTag:"h2"}}),f=new c({props:{title:"Using a decorator",local:"using-a-decorator",headingTag:"h3"}}),A=new w({props:{code:"JTQwdXNlX2tlcm5lbF9mb3J3YXJkX2Zyb21faHViKCUyMlNpbHVBbmRNdWwlMjIpJTBBY2xhc3MlMjBTaWx1QW5kTXVsKG5uLk1vZHVsZSklM0ElMEElMjAlMjAlMjAlMjBkZWYlMjBmb3J3YXJkKHNlbGYlMkMlMjBpbnB1dCUzQSUyMHRvcmNoLlRlbnNvciklMjAtJTNFJTIwdG9yY2guVGVuc29yJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZCUyMCUzRCUyMGlucHV0LnNoYXBlJTVCLTElNUQlMjAlMkYlMkYlMjAyJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwRi5zaWx1KGlucHV0JTVCLi4uJTJDJTIwJTNBZCU1RCklMjAqJTIwaW5wdXQlNUIuLi4lMkMlMjBkJTNBJTVE",highlighted:`<span class="hljs-meta">@use_kernel_forward_from_hub(<span class="hljs-params"><span class="hljs-string">&quot;SiluAndMul&quot;</span></span>)</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">SiluAndMul</span>(nn.Module):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, <span class="hljs-built_in">input</span>: torch.Tensor</span>) -&gt; torch.Tensor:
        d = <span class="hljs-built_in">input</span>.shape[-<span class="hljs-number">1</span>] // <span class="hljs-number">2</span>
        <span class="hljs-keyword">return</span> F.silu(<span class="hljs-built_in">input</span>[..., :d]) * <span class="hljs-built_in">input</span>[..., d:]`,wrap:!1}}),k=new c({props:{title:"External layers",local:"external-layers",headingTag:"h3"}}),$=new w({props:{code:"ZnJvbSUyMHNvbWVsaWJyYXJ5JTIwaW1wb3J0JTIwU2lsdUFuZE11bCUwQSUwQXJlcGxhY2Vfa2VybmVsX2ZvcndhcmRfZnJvbV9odWIoU2lsdUFuZE11bCUyQyUyMCUyMlNpbHVBbmRNdWwlMjIp",highlighted:`<span class="hljs-keyword">from</span> somelibrary <span class="hljs-keyword">import</span> SiluAndMul

replace_kernel_forward_from_hub(SiluAndMul, <span class="hljs-string">&quot;SiluAndMul&quot;</span>)`,wrap:!1}}),R=new c({props:{title:"Using a function as a layer",local:"using-a-function-as-a-layer",headingTag:"h3"}}),_=new w({props:{code:"JTQwdXNlX2tlcm5lbF9mdW5jX2Zyb21faHViKCUyMnNpbHVfYW5kX211bCUyMiklMEFkZWYlMjBzaWx1X2FuZF9tdWwoeCUzQSUyMHRvcmNoLlRlbnNvciklMjAtJTNFJTIwdG9yY2guVGVuc29yJTNBJTBBJTIwJTIwJTIwJTIwZCUyMCUzRCUyMHguc2hhcGUlNUItMSU1RCUyMCUyRiUyRiUyMDIlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBGLnNpbHUoeCU1Qi4uLiUyQyUyMCUzQWQlNUQpJTIwKiUyMHglNUIuLi4lMkMlMjBkJTNBJTVE",highlighted:`<span class="hljs-meta">@use_kernel_func_from_hub(<span class="hljs-params"><span class="hljs-string">&quot;silu_and_mul&quot;</span></span>)</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">silu_and_mul</span>(<span class="hljs-params">x: torch.Tensor</span>) -&gt; torch.Tensor:
    d = x.shape[-<span class="hljs-number">1</span>] // <span class="hljs-number">2</span>
    <span class="hljs-keyword">return</span> F.silu(x[..., :d]) * x[..., d:]`,wrap:!1}}),Z=new w({props:{code:"Y2xhc3MlMjBGZWVkRm9yd2FyZChubi5Nb2R1bGUpJTNBJTBBJTIwJTIwZGVmJTIwX19pbml0X18oc2VsZiUyQyUyMGluX2ZlYXR1cmVzJTNBJTIwaW50JTJDJTIwb3V0X2ZlYXR1cmVzJTNBJTIwaW50KSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMHNlbGYubGluZWFyJTIwJTNEJTIwbm4uTGluZWFyKGluX2ZlYXR1cmVzJTJDJTIwb3V0X2ZlYXR1cmVzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyME5vdGUlM0ElMjBzaWx1X2FuZF9tdWwlMjBpcyUyMGElMjBUb3JjaCUyMG1vZHVsZS4lMEElMjAlMjAlMjAlMjAlMjAlMjBzZWxmLnNpbHVfYW5kX211bCUyMCUzRCUyMHNpbHVfYW5kX211bCUwQSUwQSUyMCUyMGRlZiUyMGZvcndhcmQoc2VsZiUyQyUyMHglM0ElMjB0b3JjaC5UZW5zb3IpJTIwLSUzRSUyMHRvcmNoLlRlbnNvciUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMHNlbGYuc2lsdV9hbmRfbXVsKHNlbGYubGluZWFyKHgpKQ==",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">FeedForward</span>(nn.Module):
  <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, in_features: <span class="hljs-built_in">int</span>, out_features: <span class="hljs-built_in">int</span></span>):
      self.linear = nn.Linear(in_features, out_features)
      <span class="hljs-comment"># Note: silu_and_mul is a Torch module.</span>
      self.silu_and_mul = silu_and_mul

  <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, x: torch.Tensor</span>) -&gt; torch.Tensor:
      <span class="hljs-keyword">return</span> self.silu_and_mul(self.linear(x))`,wrap:!1}}),W=new c({props:{title:"Kernelizing a model",local:"kernelizing-a-model",headingTag:"h2"}}),S=new w({props:{code:"bW9kZWwlMjAlM0QlMjBNeU1vZGVsKC4uLiklMEFtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLklORkVSRU5DRSk=",highlighted:`model = MyModel(...)
model = kernelize(model, mode=Mode.INFERENCE)`,wrap:!1}}),Q=new w({props:{code:"bW9kZWwlMjAlM0QlMjBNeU1vZGVsKC4uLiklMEFtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLlRSQUlOSU5HKQ==",highlighted:`model = MyModel(...)
model = kernelize(model, mode=Mode.TRAINING)`,wrap:!1}}),x=new w({props:{code:"bW9kZWwlMjAlM0QlMjBNeU1vZGVsKC4uLiklMEElMEElMjMlMjBJbmZlcmVuY2UlMEFtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLklORkVSRU5DRSUyMCU3QyUyME1vZGUuVE9SQ0hfQ09NUElMRSklMEElMEElMjMlMjBUcmFpbmluZyUwQW1vZGVsJTIwJTNEJTIwa2VybmVsaXplKG1vZGVsJTJDJTIwbW9kZSUzRE1vZGUuVFJBSU5JTkclMjAlN0MlMjBNb2RlLlRPUkNIX0NPTVBJTEUp",highlighted:`model = MyModel(...)

<span class="hljs-comment"># Inference</span>
model = kernelize(model, mode=Mode.INFERENCE | Mode.TORCH_COMPILE)

<span class="hljs-comment"># Training</span>
model = kernelize(model, mode=Mode.TRAINING | Mode.TORCH_COMPILE)`,wrap:!1}}),X=new c({props:{title:"Kernel device",local:"kernel-device",headingTag:"h3"}}),F=new w({props:{code:"bW9kZWwlMjAlM0QlMjBNeU1vZGVsKC4uLiklMEFtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIlMkMlMjBtb2RlJTNETW9kZS5JTkZFUkVOQ0Up",highlighted:`model = MyModel(...)
model = kernelize(model, device=<span class="hljs-string">&quot;cuda&quot;</span>, mode=Mode.INFERENCE)`,wrap:!1}}),q=new c({props:{title:"Fallback forward",local:"fallback-forward",headingTag:"h3"}}),P=new w({props:{code:"bW9kZWwlMjAlM0QlMjBNeU1vZGVsKC4uLiklMEFtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLklORkVSRU5DRSUyMCU3QyUyME1vZGUuVE9SQ0hfQ09NUElMRSUyQyUyMHVzZV9mYWxsYmFjayUzREZhbHNlKQ==",highlighted:`model = MyModel(...)
model = kernelize(model, mode=Mode.INFERENCE | Mode.TORCH_COMPILE, use_fallback=<span class="hljs-literal">False</span>)`,wrap:!1}}),O=new c({props:{title:"Inspecting which kernels are used",local:"inspecting-which-kernels-are-used",headingTag:"h3"}}),ee=new c({props:{title:"Registering a hub kernel for a layer",local:"registering-a-hub-kernel-for-a-layer",headingTag:"h2"}}),te=new w({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMExheWVyUmVwb3NpdG9yeSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXBvX2lkJTNEJTIya2VybmVscy1jb21tdW5pdHklMkZhY3RpdmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJfbmFtZSUzRCUyMlNpbHVBbmRNdWwlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2ZXJzaW9uJTNEMSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyb2NtJTIyJTNBJTIwTGF5ZXJSZXBvc2l0b3J5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXllcl9uYW1lJTNEJTIyU2lsdUFuZE11bCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHZlcnNpb24lM0QxJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            version=<span class="hljs-number">1</span>,
        ),
        <span class="hljs-string">&quot;rocm&quot;</span>: LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            version=<span class="hljs-number">1</span>,
        )
    }
}`,wrap:!1}}),ie=new w({props:{code:"cmVnaXN0ZXJfa2VybmVsX21hcHBpbmcoa2VybmVsX2xheWVyX21hcHBpbmcp",highlighted:"register_kernel_mapping(kernel_layer_mapping)",wrap:!1}}),re=new w({props:{code:"d2l0aCUyMHVzZV9rZXJuZWxfbWFwcGluZyhrZXJuZWxfbGF5ZXJfbWFwcGluZyklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjBVc2UlMjB0aGUlMjBsYXllciUyMGZvciUyMHdoaWNoJTIwdGhlJTIwbWFwcGluZyUyMGlzJTIwYXBwbGllZC4lMEElMjAlMjAlMjAlMjBtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLlRSQUlOSU5HJTIwJTdDJTIwTW9kZS5UT1JDSF9DT01QSUxFKQ==",highlighted:`<span class="hljs-keyword">with</span> use_kernel_mapping(kernel_layer_mapping):
    <span class="hljs-comment"># Use the layer for which the mapping is applied.</span>
    model = kernelize(model, mode=Mode.TRAINING | Mode.TORCH_COMPILE)`,wrap:!1}}),Te=new w({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMEZ1bmNSZXBvc2l0b3J5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmdW5jX25hbWUlM0QlMjJzaWx1X2FuZF9tdWwlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTdE",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: FuncRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            func_name=<span class="hljs-string">&quot;silu_and_mul&quot;</span>,
        ),
    }
}`,wrap:!1}}),pe=new c({props:{title:"Registering kernels for specific modes",local:"registering-kernels-for-specific-modes",headingTag:"h3"}}),Je=new w({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME1vZGUuSU5GRVJFTkNFJTNBJTIwTGF5ZXJSZXBvc2l0b3J5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24taW5mZXJlbmNlLW9wdGltaXplZCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxheWVyX25hbWUlM0QlMjJTaWx1QW5kTXVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmVyc2lvbiUzRDElMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwTW9kZS5UUkFJTklORyUyMCU3QyUyME1vZGUuVE9SQ0hfQ09NUElMRSUzQSUyMExheWVyUmVwb3NpdG9yeSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXBvX2lkJTNEJTIya2VybmVscy1jb21tdW5pdHklMkZhY3RpdmF0aW9uLXRyYWluaW5nLW9wdGltaXplZCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxheWVyX25hbWUlM0QlMjJTaWx1QW5kTXVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmVyc2lvbiUzRDElMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTdE",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: {
          Mode.INFERENCE: LayerRepository(
              repo_id=<span class="hljs-string">&quot;kernels-community/activation-inference-optimized&quot;</span>,
              layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
              version=<span class="hljs-number">1</span>,
          ),
          Mode.TRAINING | Mode.TORCH_COMPILE: LayerRepository(
              repo_id=<span class="hljs-string">&quot;kernels-community/activation-training-optimized&quot;</span>,
              layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
              version=<span class="hljs-number">1</span>,
          ),
      }
    }
}`,wrap:!1}}),de=new w({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME1vZGUuRkFMTEJBQ0slM0ElMjBMYXllclJlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxheWVyX25hbWUlM0QlMjJTaWx1QW5kTXVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmVyc2lvbiUzRDElMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwTW9kZS5JTkZFUkVOQ0UlM0ElMjBMYXllclJlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbi1pbmZlcmVuY2Utb3B0aW1pemVkJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJfbmFtZSUzRCUyMlNpbHVBbmRNdWwlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2ZXJzaW9uJTNEMSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBNb2RlLlRSQUlOSU5HJTNBJTIwTGF5ZXJSZXBvc2l0b3J5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24tdHJhaW5pbmctb3B0aW1pemVkJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJfbmFtZSUzRCUyMlNpbHVBbmRNdWwlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2ZXJzaW9uJTNEMSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjAlN0QlMEElN0Q=",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: {
            Mode.FALLBACK: LayerRepository(
                repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
                layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
                version=<span class="hljs-number">1</span>,
            ),
            Mode.INFERENCE: LayerRepository(
                repo_id=<span class="hljs-string">&quot;kernels-community/activation-inference-optimized&quot;</span>,
                layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
                version=<span class="hljs-number">1</span>,
            ),
            Mode.TRAINING: LayerRepository(
                repo_id=<span class="hljs-string">&quot;kernels-community/activation-training-optimized&quot;</span>,
                layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
                version=<span class="hljs-number">1</span>,
            ),
        }
    }
}`,wrap:!1}}),je=new c({props:{title:"Registering kernels for specific CUDA capabilities",local:"registering-kernels-for-specific-cuda-capabilities",headingTag:"h3"}}),Ie=new w({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwRGV2aWNlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHR5cGUlM0QlMjJjdWRhJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJvcGVydGllcyUzRENVREFQcm9wZXJ0aWVzKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1pbl9jYXBhYmlsaXR5JTNENzUlMkMlMjBtYXhfY2FwYWJpbGl0eSUzRDg5JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklM0ElMjBMYXllclJlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxheWVyX25hbWUlM0QlMjJTaWx1QW5kTXVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmVyc2lvbiUzRDElMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwRGV2aWNlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHR5cGUlM0QlMjJjdWRhJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJvcGVydGllcyUzRENVREFQcm9wZXJ0aWVzKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1pbl9jYXBhYmlsaXR5JTNEOTAlMkMlMjBtYXhfY2FwYWJpbGl0eSUzRHN5cy5tYXhzaXplJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklM0ElMjBMYXllclJlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbi1ob3BwZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXllcl9uYW1lJTNEJTIyU2lsdUFuZE11bCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHZlcnNpb24lM0QxJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        Device(
            <span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;cuda&quot;</span>,
            properties=CUDAProperties(
                min_capability=<span class="hljs-number">75</span>, max_capability=<span class="hljs-number">89</span>
            ),
        ): LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            version=<span class="hljs-number">1</span>,
        ),
        Device(
            <span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;cuda&quot;</span>,
            properties=CUDAProperties(
                min_capability=<span class="hljs-number">90</span>, max_capability=sys.maxsize
            ),
        ): LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation-hopper&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            version=<span class="hljs-number">1</span>,
        ),
    }
}`,wrap:!1}}),Ae=new c({props:{title:"Registering kernels for specific ROCm capabilities",local:"registering-kernels-for-specific-rocm-capabilities",headingTag:"h3"}}),ke=new c({props:{title:"Loading from a local repository for testing",local:"loading-from-a-local-repository-for-testing",headingTag:"h3"}}),$e=new w({props:{code:"d2l0aCUyMHVzZV9rZXJuZWxfbWFwcGluZyglMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMExvY2FsTGF5ZXJSZXBvc2l0b3J5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlcG9fcGF0aCUzRCUyMiUyRmhvbWUlMkZkYW5pZWwlMkZrZXJuZWxzJTJGYWN0aXZhdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHBhY2thZ2VfbmFtZSUzRCUyMmFjdGl2YXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXllcl9uYW1lJTNEJTIyU2lsdUFuZE11bCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjBpbmhlcml0X21hcHBpbmclM0RGYWxzZSUyQyUwQSklM0ElMEElMjAlMjAlMjAlMjBrZXJuZWxpemUobGluZWFyJTJDJTIwbW9kZSUzRE1vZGUuSU5GRVJFTkNFKQ==",highlighted:`<span class="hljs-keyword">with</span> use_kernel_mapping(
    {
        <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
            <span class="hljs-string">&quot;cuda&quot;</span>: LocalLayerRepository(
                repo_path=<span class="hljs-string">&quot;/home/daniel/kernels/activation&quot;</span>,
                package_name=<span class="hljs-string">&quot;activation&quot;</span>,
                layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            )
        }
    },
    inherit_mapping=<span class="hljs-literal">False</span>,
):
    kernelize(linear, mode=Mode.INFERENCE)`,wrap:!1}}),Re=new w({props:{code:"d2l0aCUyMHVzZV9rZXJuZWxfbWFwcGluZyglMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzaWx1X2FuZF9tdWwlMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJjdWRhJTIyJTNBJTIwTG9jYWxGdW5jUmVwb3NpdG9yeSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXBvX3BhdGglM0QlMjIlMkZob21lJTJGZGFuaWVsJTJGa2VybmVscyUyRmFjdGl2YXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwYWNrYWdlX25hbWUlM0QlMjJhY3RpdmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZnVuY19uYW1lJTNEJTIyc2lsdV9hbmRfbXVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMGluaGVyaXRfbWFwcGluZyUzREZhbHNlJTJDJTBBKSUzQSUwQSUyMCUyMCUyMCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLklORkVSRU5DRSk=",highlighted:`<span class="hljs-keyword">with</span> use_kernel_mapping(
    {
        <span class="hljs-string">&quot;silu_and_mul&quot;</span>: {
            <span class="hljs-string">&quot;cuda&quot;</span>: LocalFuncRepository(
                repo_path=<span class="hljs-string">&quot;/home/daniel/kernels/activation&quot;</span>,
                package_name=<span class="hljs-string">&quot;activation&quot;</span>,
                func_name=<span class="hljs-string">&quot;silu_and_mul&quot;</span>,
            )
        }
    },
    inherit_mapping=<span class="hljs-literal">False</span>,
):
    kernelize(model, mode=Mode.INFERENCE)`,wrap:!1}}),ve=new Xt({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/layers.md"}}),{c(){m=i("meta"),Be=M(),_e=i("p"),Ze=M(),o(d.$$.fragment),We=M(),o(u.$$.fragment),Ge=M(),j=i("p"),j.innerHTML=et,Se=M(),C=i("p"),C.innerHTML=lt,He=M(),o(I.$$.fragment),Qe=M(),o(f.$$.fragment),Le=M(),h=i("p"),h.innerHTML=tt,Ve=M(),o(A.$$.fragment),xe=M(),b=i("p"),b.innerHTML=st,Xe=M(),o(k.$$.fragment),ze=M(),g=i("p"),g.innerHTML=Mt,Fe=M(),o($.$$.fragment),qe=M(),E=i("p"),E.innerHTML=nt,Ye=M(),o(R.$$.fragment),Pe=M(),v=i("p"),v.innerHTML=it,Ke=M(),o(_.$$.fragment),Oe=M(),N=i("p"),N.innerHTML=at,De=M(),B=i("p"),B.innerHTML=rt,el=M(),o(Z.$$.fragment),ll=M(),o(W.$$.fragment),tl=M(),G=i("p"),G.innerHTML=ot,sl=M(),o(S.$$.fragment),Ml=M(),H=i("p"),H.innerHTML=yt,nl=M(),o(Q.$$.fragment),il=M(),L=i("p"),L.innerHTML=Tt,al=M(),V=i("p"),V.innerHTML=pt,rl=M(),o(x.$$.fragment),ol=M(),o(X.$$.fragment),yl=M(),z=i("p"),z.innerHTML=Ut,Tl=M(),o(F.$$.fragment),pl=M(),o(q.$$.fragment),Ul=M(),Y=i("p"),Y.innerHTML=Jt,Jl=M(),o(P.$$.fragment),wl=M(),K=i("p"),K.textContent=wt,cl=M(),o(O.$$.fragment),ml=M(),D=i("p"),D.innerHTML=ct,dl=M(),o(ee.$$.fragment),ul=M(),le=i("p"),le.innerHTML=mt,jl=M(),o(te.$$.fragment),Cl=M(),se=i("p"),se.innerHTML=dt,Il=M(),Me=i("p"),Me.innerHTML=ut,fl=M(),ne=i("p"),ne.innerHTML=jt,hl=M(),o(ie.$$.fragment),Al=M(),ae=i("p"),ae.innerHTML=Ct,bl=M(),o(re.$$.fragment),kl=M(),oe=i("p"),oe.innerHTML=It,gl=M(),ye=i("p"),ye.innerHTML=ft,$l=M(),o(Te.$$.fragment),El=M(),o(pe.$$.fragment),Rl=M(),Ue=i("p"),Ue.textContent=ht,vl=M(),o(Je.$$.fragment),_l=M(),we=i("p"),we.innerHTML=At,Nl=M(),ce=i("ul"),ce.innerHTML=bt,Bl=M(),me=i("p"),me.innerHTML=kt,Zl=M(),o(de.$$.fragment),Wl=M(),ue=i("p"),ue.innerHTML=gt,Gl=M(),o(je.$$.fragment),Sl=M(),Ce=i("p"),Ce.innerHTML=$t,Hl=M(),o(Ie.$$.fragment),Ql=M(),fe=i("p"),fe.textContent=Et,Ll=M(),he=i("ul"),he.innerHTML=Rt,Vl=M(),o(Ae.$$.fragment),xl=M(),be=i("p"),be.innerHTML=vt,Xl=M(),o(ke.$$.fragment),zl=M(),ge=i("p"),ge.innerHTML=_t,Fl=M(),o($e.$$.fragment),ql=M(),Ee=i("p"),Ee.innerHTML=Nt,Yl=M(),o(Re.$$.fragment),Pl=M(),o(ve.$$.fragment),Kl=M(),Ne=i("p"),this.h()},l(e){const l=Lt("svelte-u9bgzb",document.head);m=a(l,"META",{name:!0,content:!0}),l.forEach(t),Be=n(e),_e=a(e,"P",{}),Bt(_e).forEach(t),Ze=n(e),y(d.$$.fragment,e),We=n(e),y(u.$$.fragment,e),Ge=n(e),j=a(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-178x673"&&(j.innerHTML=et),Se=n(e),C=a(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-35znf1"&&(C.innerHTML=lt),He=n(e),y(I.$$.fragment,e),Qe=n(e),y(f.$$.fragment,e),Le=n(e),h=a(e,"P",{"data-svelte-h":!0}),r(h)!=="svelte-1jd41lf"&&(h.innerHTML=tt),Ve=n(e),y(A.$$.fragment,e),xe=n(e),b=a(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-tily1x"&&(b.innerHTML=st),Xe=n(e),y(k.$$.fragment,e),ze=n(e),g=a(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-1hj9ahw"&&(g.innerHTML=Mt),Fe=n(e),y($.$$.fragment,e),qe=n(e),E=a(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-13coke1"&&(E.innerHTML=nt),Ye=n(e),y(R.$$.fragment,e),Pe=n(e),v=a(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-kwbso1"&&(v.innerHTML=it),Ke=n(e),y(_.$$.fragment,e),Oe=n(e),N=a(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-1w74xdp"&&(N.innerHTML=at),De=n(e),B=a(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-t3eq4x"&&(B.innerHTML=rt),el=n(e),y(Z.$$.fragment,e),ll=n(e),y(W.$$.fragment,e),tl=n(e),G=a(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-stkx9y"&&(G.innerHTML=ot),sl=n(e),y(S.$$.fragment,e),Ml=n(e),H=a(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1mdicvi"&&(H.innerHTML=yt),nl=n(e),y(Q.$$.fragment,e),il=n(e),L=a(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-xhc5xj"&&(L.innerHTML=Tt),al=n(e),V=a(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-195gdzl"&&(V.innerHTML=pt),rl=n(e),y(x.$$.fragment,e),ol=n(e),y(X.$$.fragment,e),yl=n(e),z=a(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-808tau"&&(z.innerHTML=Ut),Tl=n(e),y(F.$$.fragment,e),pl=n(e),y(q.$$.fragment,e),Ul=n(e),Y=a(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-yu926d"&&(Y.innerHTML=Jt),Jl=n(e),y(P.$$.fragment,e),wl=n(e),K=a(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-1lkusth"&&(K.textContent=wt),cl=n(e),y(O.$$.fragment,e),ml=n(e),D=a(e,"P",{"data-svelte-h":!0}),r(D)!=="svelte-161p6z8"&&(D.innerHTML=ct),dl=n(e),y(ee.$$.fragment,e),ul=n(e),le=a(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-1r5il31"&&(le.innerHTML=mt),jl=n(e),y(te.$$.fragment,e),Cl=n(e),se=a(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-135k7m5"&&(se.innerHTML=dt),Il=n(e),Me=a(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-62g4c"&&(Me.innerHTML=ut),fl=n(e),ne=a(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-1ax1kej"&&(ne.innerHTML=jt),hl=n(e),y(ie.$$.fragment,e),Al=n(e),ae=a(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-p5ro9n"&&(ae.innerHTML=Ct),bl=n(e),y(re.$$.fragment,e),kl=n(e),oe=a(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-z3xuuf"&&(oe.innerHTML=It),gl=n(e),ye=a(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-1uvzpxy"&&(ye.innerHTML=ft),$l=n(e),y(Te.$$.fragment,e),El=n(e),y(pe.$$.fragment,e),Rl=n(e),Ue=a(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-1ed3b6y"&&(Ue.textContent=ht),vl=n(e),y(Je.$$.fragment,e),_l=n(e),we=a(e,"P",{"data-svelte-h":!0}),r(we)!=="svelte-sek2d8"&&(we.innerHTML=At),Nl=n(e),ce=a(e,"UL",{"data-svelte-h":!0}),r(ce)!=="svelte-ewhtf4"&&(ce.innerHTML=bt),Bl=n(e),me=a(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-m4furw"&&(me.innerHTML=kt),Zl=n(e),y(de.$$.fragment,e),Wl=n(e),ue=a(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1oi4pcx"&&(ue.innerHTML=gt),Gl=n(e),y(je.$$.fragment,e),Sl=n(e),Ce=a(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-1wl92tu"&&(Ce.innerHTML=$t),Hl=n(e),y(Ie.$$.fragment,e),Ql=n(e),fe=a(e,"P",{"data-svelte-h":!0}),r(fe)!=="svelte-1k7nbkd"&&(fe.textContent=Et),Ll=n(e),he=a(e,"UL",{"data-svelte-h":!0}),r(he)!=="svelte-xyngc6"&&(he.innerHTML=Rt),Vl=n(e),y(Ae.$$.fragment,e),xl=n(e),be=a(e,"P",{"data-svelte-h":!0}),r(be)!=="svelte-1q9vv7t"&&(be.innerHTML=vt),Xl=n(e),y(ke.$$.fragment,e),zl=n(e),ge=a(e,"P",{"data-svelte-h":!0}),r(ge)!=="svelte-qa4iob"&&(ge.innerHTML=_t),Fl=n(e),y($e.$$.fragment,e),ql=n(e),Ee=a(e,"P",{"data-svelte-h":!0}),r(Ee)!=="svelte-f12z19"&&(Ee.innerHTML=Nt),Yl=n(e),y(Re.$$.fragment,e),Pl=n(e),y(ve.$$.fragment,e),Kl=n(e),Ne=a(e,"P",{}),Bt(Ne).forEach(t),this.h()},h(){Zt(m,"name","hf:doc:metadata"),Zt(m,"content",Ft)},m(e,l){Vt(document.head,m),s(e,Be,l),s(e,_e,l),s(e,Ze,l),T(d,e,l),s(e,We,l),T(u,e,l),s(e,Ge,l),s(e,j,l),s(e,Se,l),s(e,C,l),s(e,He,l),T(I,e,l),s(e,Qe,l),T(f,e,l),s(e,Le,l),s(e,h,l),s(e,Ve,l),T(A,e,l),s(e,xe,l),s(e,b,l),s(e,Xe,l),T(k,e,l),s(e,ze,l),s(e,g,l),s(e,Fe,l),T($,e,l),s(e,qe,l),s(e,E,l),s(e,Ye,l),T(R,e,l),s(e,Pe,l),s(e,v,l),s(e,Ke,l),T(_,e,l),s(e,Oe,l),s(e,N,l),s(e,De,l),s(e,B,l),s(e,el,l),T(Z,e,l),s(e,ll,l),T(W,e,l),s(e,tl,l),s(e,G,l),s(e,sl,l),T(S,e,l),s(e,Ml,l),s(e,H,l),s(e,nl,l),T(Q,e,l),s(e,il,l),s(e,L,l),s(e,al,l),s(e,V,l),s(e,rl,l),T(x,e,l),s(e,ol,l),T(X,e,l),s(e,yl,l),s(e,z,l),s(e,Tl,l),T(F,e,l),s(e,pl,l),T(q,e,l),s(e,Ul,l),s(e,Y,l),s(e,Jl,l),T(P,e,l),s(e,wl,l),s(e,K,l),s(e,cl,l),T(O,e,l),s(e,ml,l),s(e,D,l),s(e,dl,l),T(ee,e,l),s(e,ul,l),s(e,le,l),s(e,jl,l),T(te,e,l),s(e,Cl,l),s(e,se,l),s(e,Il,l),s(e,Me,l),s(e,fl,l),s(e,ne,l),s(e,hl,l),T(ie,e,l),s(e,Al,l),s(e,ae,l),s(e,bl,l),T(re,e,l),s(e,kl,l),s(e,oe,l),s(e,gl,l),s(e,ye,l),s(e,$l,l),T(Te,e,l),s(e,El,l),T(pe,e,l),s(e,Rl,l),s(e,Ue,l),s(e,vl,l),T(Je,e,l),s(e,_l,l),s(e,we,l),s(e,Nl,l),s(e,ce,l),s(e,Bl,l),s(e,me,l),s(e,Zl,l),T(de,e,l),s(e,Wl,l),s(e,ue,l),s(e,Gl,l),T(je,e,l),s(e,Sl,l),s(e,Ce,l),s(e,Hl,l),T(Ie,e,l),s(e,Ql,l),s(e,fe,l),s(e,Ll,l),s(e,he,l),s(e,Vl,l),T(Ae,e,l),s(e,xl,l),s(e,be,l),s(e,Xl,l),T(ke,e,l),s(e,zl,l),s(e,ge,l),s(e,Fl,l),T($e,e,l),s(e,ql,l),s(e,Ee,l),s(e,Yl,l),T(Re,e,l),s(e,Pl,l),T(ve,e,l),s(e,Kl,l),s(e,Ne,l),Ol=!0},p:Gt,i(e){Ol||(p(d.$$.fragment,e),p(u.$$.fragment,e),p(I.$$.fragment,e),p(f.$$.fragment,e),p(A.$$.fragment,e),p(k.$$.fragment,e),p($.$$.fragment,e),p(R.$$.fragment,e),p(_.$$.fragment,e),p(Z.$$.fragment,e),p(W.$$.fragment,e),p(S.$$.fragment,e),p(Q.$$.fragment,e),p(x.$$.fragment,e),p(X.$$.fragment,e),p(F.$$.fragment,e),p(q.$$.fragment,e),p(P.$$.fragment,e),p(O.$$.fragment,e),p(ee.$$.fragment,e),p(te.$$.fragment,e),p(ie.$$.fragment,e),p(re.$$.fragment,e),p(Te.$$.fragment,e),p(pe.$$.fragment,e),p(Je.$$.fragment,e),p(de.$$.fragment,e),p(je.$$.fragment,e),p(Ie.$$.fragment,e),p(Ae.$$.fragment,e),p(ke.$$.fragment,e),p($e.$$.fragment,e),p(Re.$$.fragment,e),p(ve.$$.fragment,e),Ol=!0)},o(e){U(d.$$.fragment,e),U(u.$$.fragment,e),U(I.$$.fragment,e),U(f.$$.fragment,e),U(A.$$.fragment,e),U(k.$$.fragment,e),U($.$$.fragment,e),U(R.$$.fragment,e),U(_.$$.fragment,e),U(Z.$$.fragment,e),U(W.$$.fragment,e),U(S.$$.fragment,e),U(Q.$$.fragment,e),U(x.$$.fragment,e),U(X.$$.fragment,e),U(F.$$.fragment,e),U(q.$$.fragment,e),U(P.$$.fragment,e),U(O.$$.fragment,e),U(ee.$$.fragment,e),U(te.$$.fragment,e),U(ie.$$.fragment,e),U(re.$$.fragment,e),U(Te.$$.fragment,e),U(pe.$$.fragment,e),U(Je.$$.fragment,e),U(de.$$.fragment,e),U(je.$$.fragment,e),U(Ie.$$.fragment,e),U(Ae.$$.fragment,e),U(ke.$$.fragment,e),U($e.$$.fragment,e),U(Re.$$.fragment,e),U(ve.$$.fragment,e),Ol=!1},d(e){e&&(t(Be),t(_e),t(Ze),t(We),t(Ge),t(j),t(Se),t(C),t(He),t(Qe),t(Le),t(h),t(Ve),t(xe),t(b),t(Xe),t(ze),t(g),t(Fe),t(qe),t(E),t(Ye),t(Pe),t(v),t(Ke),t(Oe),t(N),t(De),t(B),t(el),t(ll),t(tl),t(G),t(sl),t(Ml),t(H),t(nl),t(il),t(L),t(al),t(V),t(rl),t(ol),t(yl),t(z),t(Tl),t(pl),t(Ul),t(Y),t(Jl),t(wl),t(K),t(cl),t(ml),t(D),t(dl),t(ul),t(le),t(jl),t(Cl),t(se),t(Il),t(Me),t(fl),t(ne),t(hl),t(Al),t(ae),t(bl),t(kl),t(oe),t(gl),t(ye),t($l),t(El),t(Rl),t(Ue),t(vl),t(_l),t(we),t(Nl),t(ce),t(Bl),t(me),t(Zl),t(Wl),t(ue),t(Gl),t(Sl),t(Ce),t(Hl),t(Ql),t(fe),t(Ll),t(he),t(Vl),t(xl),t(be),t(Xl),t(zl),t(ge),t(Fl),t(ql),t(Ee),t(Yl),t(Pl),t(Kl),t(Ne)),t(m),J(d,e),J(u,e),J(I,e),J(f,e),J(A,e),J(k,e),J($,e),J(R,e),J(_,e),J(Z,e),J(W,e),J(S,e),J(Q,e),J(x,e),J(X,e),J(F,e),J(q,e),J(P,e),J(O,e),J(ee,e),J(te,e),J(ie,e),J(re,e),J(Te,e),J(pe,e),J(Je,e),J(de,e),J(je,e),J(Ie,e),J(Ae,e),J(ke,e),J($e,e),J(Re,e),J(ve,e)}}}const Ft='{"title":"Layers","local":"layers","sections":[{"title":"Making a layer extensible with kernels from the hub","local":"making-a-layer-extensible-with-kernels-from-the-hub","sections":[{"title":"Using a decorator","local":"using-a-decorator","sections":[],"depth":3},{"title":"External layers","local":"external-layers","sections":[],"depth":3},{"title":"Using a function as a layer","local":"using-a-function-as-a-layer","sections":[],"depth":3}],"depth":2},{"title":"Kernelizing a model","local":"kernelizing-a-model","sections":[{"title":"Kernel device","local":"kernel-device","sections":[],"depth":3},{"title":"Fallback forward","local":"fallback-forward","sections":[],"depth":3},{"title":"Inspecting which kernels are used","local":"inspecting-which-kernels-are-used","sections":[],"depth":3}],"depth":2},{"title":"Registering a hub kernel for a layer","local":"registering-a-hub-kernel-for-a-layer","sections":[{"title":"Registering kernels for specific modes","local":"registering-kernels-for-specific-modes","sections":[],"depth":3},{"title":"Registering kernels for specific CUDA capabilities","local":"registering-kernels-for-specific-cuda-capabilities","sections":[],"depth":3},{"title":"Registering kernels for specific ROCm capabilities","local":"registering-kernels-for-specific-rocm-capabilities","sections":[],"depth":3},{"title":"Loading from a local repository for testing","local":"loading-from-a-local-repository-for-testing","sections":[],"depth":3}],"depth":2}],"depth":1}';function qt(Dl){return St(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class es extends Ht{constructor(m){super(),Qt(this,m,qt,zt,Wt,{})}}export{es as component};
