import{s as Me,n as ue,o as ye}from"../chunks/scheduler.f3b1e791.js";import{S as ke,i as je,e as o,s,c as i,h as we,a as r,d as t,b as a,f as de,g as p,j as X,k as me,l as Te,m as n,n as c,t as d,o as m,p as M}from"../chunks/index.023a9934.js";import{C as fe}from"../chunks/CopyLLMTxtMenu.ee636735.js";import{C as E}from"../chunks/CodeBlock.5aa52fca.js";import{H as te,E as Je}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9b009efe.js";function be(ne){let u,V,W,Z,y,L,k,x,j,se=`Projects that use <code>setuptools</code> can lock the kernel versions that should be
used. First specify the accepted versions in <code>pyproject.toml</code> and make
sure that <code>kernels</code> is a build dependency:`,q,w,H,T,ae=`Then run <code>kernels lock .</code> in the project directory. This generates a <code>kernels.lock</code> file with
the locked revisions. The locked revision will be used when loading a kernel with
<code>get_locked_kernel</code>:`,R,f,Q,J,oe=`<strong>Note:</strong> the lock file is included in the package metadata, so it will only be visible
to <code>kernels</code> after doing an (editable or regular) installation of your project.`,G,b,F,$,ie=`Locking is also supported for kernel layers. To use locked layers, register them
with the <code>LockedLayerRepository</code> class:`,N,g,S,h,re=`Similarly, you can use the <code>LockedFuncRepository</code> class to lock kernel function
versions:`,z,I,P,_,Y,A,pe=`Locked kernels can be pre-downloaded by running <code>kernels download .</code> in your
project directory. This will download the kernels to your local Hugging Face
Hub cache.`,D,U,ce=`The pre-downloaded kernels are used by the <code>get_locked_kernel</code> function.
<code>get_locked_kernel</code> will download a kernel when it is not pre-downloaded. If you
want kernel loading to error when a kernel is not pre-downloaded, you can use
the <code>load_kernel</code> function instead:`,O,v,K,C,ee,B,le;return y=new fe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),k=new te({props:{title:"Locking kernel/layer versions",local:"locking-kernellayer-versions",headingTag:"h1"}}),w=new E({props:{code:"JTVCYnVpbGQtc3lzdGVtJTVEJTBBcmVxdWlyZXMlMjAlM0QlMjAlNUIlMjJrZXJuZWxzJTIyJTJDJTIwJTIyc2V0dXB0b29scyUyMiU1RCUwQWJ1aWxkLWJhY2tlbmQlMjAlM0QlMjAlMjJzZXR1cHRvb2xzLmJ1aWxkX21ldGElMjIlMEElMEElNUJ0b29sLmtlcm5lbHMuZGVwZW5kZW5jaWVzJTVEJTBBJTIya2VybmVscy1jb21tdW5pdHklMkZhY3RpdmF0aW9uJTIyJTIwJTNEJTIwMQ==",highlighted:`<span class="hljs-section">[build-system]</span>
<span class="hljs-attr">requires</span> = [<span class="hljs-string">&quot;kernels&quot;</span>, <span class="hljs-string">&quot;setuptools&quot;</span>]
<span class="hljs-attr">build-backend</span> = <span class="hljs-string">&quot;setuptools.build_meta&quot;</span>

<span class="hljs-section">[tool.kernels.dependencies]</span>
<span class="hljs-attr">&quot;kernels-community/activation&quot;</span> = <span class="hljs-number">1</span>`,wrap:!1}}),f=new E({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBnZXRfbG9ja2VkX2tlcm5lbCUwQSUwQWFjdGl2YXRpb24lMjAlM0QlMjBnZXRfbG9ja2VkX2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIp",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> get_locked_kernel

activation = get_locked_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>)`,wrap:!1}}),b=new te({props:{title:"Locked kernel layers",local:"locked-kernel-layers",headingTag:"h2"}}),g=new E({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTaWx1QW5kTXVsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMExvY2tlZExheWVyUmVwb3NpdG9yeSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXBvX2lkJTNEJTIya2VybmVscy1jb21tdW5pdHklMkZhY3RpdmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJfbmFtZSUzRCUyMlNpbHVBbmRNdWwlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTdEJTBBJTBBcmVnaXN0ZXJfa2VybmVsX21hcHBpbmcoa2VybmVsX2xheWVyX21hcHBpbmcp",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: LockedLayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
        )
    }
}

register_kernel_mapping(kernel_layer_mapping)`,wrap:!1}}),I=new E({props:{code:"a2VybmVsX2xheWVyX21hcHBpbmclMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJzaWx1X2FuZF9tdWwlMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJjdWRhJTIyJTNBJTIwTG9ja2VkRnVuY1JlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZ1bmNfbmFtZSUzRCUyMnNpbHVfYW5kX211bCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlN0QlMEElN0QlMEElMEFyZWdpc3Rlcl9rZXJuZWxfbWFwcGluZyhrZXJuZWxfbGF5ZXJfbWFwcGluZyk=",highlighted:`kernel_layer_mapping = {
    <span class="hljs-string">&quot;silu_and_mul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: LockedFuncRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            func_name=<span class="hljs-string">&quot;silu_and_mul&quot;</span>,
        )
    }
}

register_kernel_mapping(kernel_layer_mapping)`,wrap:!1}}),_=new te({props:{title:"Pre-downloading locked kernels",local:"pre-downloading-locked-kernels",headingTag:"h2"}}),v=new E({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBsb2FkX2tlcm5lbCUwQSUwQWFjdGl2YXRpb24lMjAlM0QlMjBsb2FkX2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIp",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> load_kernel

activation = load_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>)`,wrap:!1}}),C=new Je({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/locking.md"}}),{c(){u=o("meta"),V=s(),W=o("p"),Z=s(),i(y.$$.fragment),L=s(),i(k.$$.fragment),x=s(),j=o("p"),j.innerHTML=se,q=s(),i(w.$$.fragment),H=s(),T=o("p"),T.innerHTML=ae,R=s(),i(f.$$.fragment),Q=s(),J=o("p"),J.innerHTML=oe,G=s(),i(b.$$.fragment),F=s(),$=o("p"),$.innerHTML=ie,N=s(),i(g.$$.fragment),S=s(),h=o("p"),h.innerHTML=re,z=s(),i(I.$$.fragment),P=s(),i(_.$$.fragment),Y=s(),A=o("p"),A.innerHTML=pe,D=s(),U=o("p"),U.innerHTML=ce,O=s(),i(v.$$.fragment),K=s(),i(C.$$.fragment),ee=s(),B=o("p"),this.h()},l(e){const l=we("svelte-u9bgzb",document.head);u=r(l,"META",{name:!0,content:!0}),l.forEach(t),V=a(e),W=r(e,"P",{}),de(W).forEach(t),Z=a(e),p(y.$$.fragment,e),L=a(e),p(k.$$.fragment,e),x=a(e),j=r(e,"P",{"data-svelte-h":!0}),X(j)!=="svelte-1u8xcar"&&(j.innerHTML=se),q=a(e),p(w.$$.fragment,e),H=a(e),T=r(e,"P",{"data-svelte-h":!0}),X(T)!=="svelte-dbqj7y"&&(T.innerHTML=ae),R=a(e),p(f.$$.fragment,e),Q=a(e),J=r(e,"P",{"data-svelte-h":!0}),X(J)!=="svelte-1kzu0g5"&&(J.innerHTML=oe),G=a(e),p(b.$$.fragment,e),F=a(e),$=r(e,"P",{"data-svelte-h":!0}),X($)!=="svelte-gvb4v0"&&($.innerHTML=ie),N=a(e),p(g.$$.fragment,e),S=a(e),h=r(e,"P",{"data-svelte-h":!0}),X(h)!=="svelte-tyd286"&&(h.innerHTML=re),z=a(e),p(I.$$.fragment,e),P=a(e),p(_.$$.fragment,e),Y=a(e),A=r(e,"P",{"data-svelte-h":!0}),X(A)!=="svelte-1xujnj6"&&(A.innerHTML=pe),D=a(e),U=r(e,"P",{"data-svelte-h":!0}),X(U)!=="svelte-eftoni"&&(U.innerHTML=ce),O=a(e),p(v.$$.fragment,e),K=a(e),p(C.$$.fragment,e),ee=a(e),B=r(e,"P",{}),de(B).forEach(t),this.h()},h(){me(u,"name","hf:doc:metadata"),me(u,"content",$e)},m(e,l){Te(document.head,u),n(e,V,l),n(e,W,l),n(e,Z,l),c(y,e,l),n(e,L,l),c(k,e,l),n(e,x,l),n(e,j,l),n(e,q,l),c(w,e,l),n(e,H,l),n(e,T,l),n(e,R,l),c(f,e,l),n(e,Q,l),n(e,J,l),n(e,G,l),c(b,e,l),n(e,F,l),n(e,$,l),n(e,N,l),c(g,e,l),n(e,S,l),n(e,h,l),n(e,z,l),c(I,e,l),n(e,P,l),c(_,e,l),n(e,Y,l),n(e,A,l),n(e,D,l),n(e,U,l),n(e,O,l),c(v,e,l),n(e,K,l),c(C,e,l),n(e,ee,l),n(e,B,l),le=!0},p:ue,i(e){le||(d(y.$$.fragment,e),d(k.$$.fragment,e),d(w.$$.fragment,e),d(f.$$.fragment,e),d(b.$$.fragment,e),d(g.$$.fragment,e),d(I.$$.fragment,e),d(_.$$.fragment,e),d(v.$$.fragment,e),d(C.$$.fragment,e),le=!0)},o(e){m(y.$$.fragment,e),m(k.$$.fragment,e),m(w.$$.fragment,e),m(f.$$.fragment,e),m(b.$$.fragment,e),m(g.$$.fragment,e),m(I.$$.fragment,e),m(_.$$.fragment,e),m(v.$$.fragment,e),m(C.$$.fragment,e),le=!1},d(e){e&&(t(V),t(W),t(Z),t(L),t(x),t(j),t(q),t(H),t(T),t(R),t(Q),t(J),t(G),t(F),t($),t(N),t(S),t(h),t(z),t(P),t(Y),t(A),t(D),t(U),t(O),t(K),t(ee),t(B)),t(u),M(y,e),M(k,e),M(w,e),M(f,e),M(b,e),M(g,e),M(I,e),M(_,e),M(v,e),M(C,e)}}}const $e='{"title":"Locking kernel/layer versions","local":"locking-kernellayer-versions","sections":[{"title":"Locked kernel layers","local":"locked-kernel-layers","sections":[],"depth":2},{"title":"Pre-downloading locked kernels","local":"pre-downloading-locked-kernels","sections":[],"depth":2}],"depth":1}';function ge(ne){return ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ve extends ke{constructor(u){super(),je(this,u,ge,be,Me,{})}}export{ve as component};
