import{s as Je,n as Me,o as Le}from"../chunks/scheduler.f3b1e791.js";import{S as Ie,i as Ce,e as o,s as i,c as s,h as _e,a,d as l,b as r,f as ve,g as p,j as c,k as ke,l as xe,m as n,n as d,t as m,o as f,p as u}from"../chunks/index.023a9934.js";import{C as Ge}from"../chunks/CopyLLMTxtMenu.ee636735.js";import{C as V}from"../chunks/CodeBlock.5aa52fca.js";import{H as de,E as He}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9b009efe.js";function Ue(me){let $,Z,R,Y,h,E,b,S,w,q,y,fe=`<code>kernel-builder</code> builds kernels in a sandbox. This has various benefits,
such as building kernels for a wide range of Torch versions, compatibility
with older C library versions and avoiding accidental dependencies.`,N,T,ue=`However, this is not ideal during kernel development, since language
servers and IDEs do not interpret the <code>build.toml</code> file. As a result,
code completion will typically not work. <code>kernel-builder</code> provides the
<code>kernel-builder</code> utility to generate CMake files to build native code and
setuptools files for building the kernel as a regular Python package.
Since CMake and setuptools are widely supported by IDEs, this provides
a much-improved development experience.`,z,g,B,v,ce=`<code>kernel-builder</code> can create CMake/Python project files for a kernel with
a <a href="./writing-kernels"><code>build.toml</code></a> file. The <code>create-pyproject</code>
command will create the files for the kernel in the current directory:`,D,k,Q,J,$e=`The <code>-f</code> flag is optional and instructs <code>kernel-builder</code> to overwrite
existing files.`,A,M,he=`It is recommended to do an editable install of the generated project into
your Python virtual environment for development:`,F,L,K,I,be="You can also create a Python project for a kernel in another directory:",O,C,ee,_,we="<strong>Warnings:</strong>",te,x,ye=`<li>Kernels built in this way should <strong>not</strong> be published on the Kernel
Hub. They do not fulfill the <a href="../kernel-requirements">kernel requirements</a>.</li> <li>Do not add the generated files to Git. <code>kernel-builder</code> has regular updates
and you generally want to use files generated by the latest version.</li>`,le,G,ne,H,Te=`Once you have built a kernel with kernel builder, you may want to test it
locally with software that uses <code>get_kernel</code> or <code>LayerRepository</code> before
publishing. This can be done using the <code>LOCAL_KERNELS</code> variable, which
maps a repository ID to a local kernel directory. For example, you could
use the kernel in <code>devel/activation</code> for any use of the
<code>kernels-community/activation</code> repository with:`,ie,U,re,j,ge=`It is also possible to map multiple repositories to local kernel directories
by separating the entries with a colon (<code>:</code>):`,oe,W,ae,P,se,X,pe;return h=new Ge({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new de({props:{title:"Local development of kernels",local:"local-development-of-kernels",headingTag:"h1"}}),w=new de({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),g=new de({props:{title:"Generating a Python project with kernel-builder",local:"generating-a-python-project-with-kernel-builder",headingTag:"h2"}}),k=new V({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBjcmVhdGUtcHlwcm9qZWN0JTIwLWY=",highlighted:"$ kernel-builder create-pyproject -f",wrap:!1}}),L=new V({props:{code:"JTI0JTIwcGlwJTIwaW5zdGFsbCUyMHdoZWVsJTIwJTIzJTIwTmVlZGVkJTIwb25jZSUyMHRvJTIwZW5hYmxlJTIwYmRpc3Rfd2hlZWwuJTBBJTI0JTIwcGlwJTIwaW5zdGFsbCUyMC0tbm8tYnVpbGQtaXNvbGF0aW9uJTIwLWUlMjAu",highlighted:`$ pip install wheel <span class="hljs-comment"># Needed once to enable bdist_wheel.</span>
$ pip install --no-build-isolation -e .`,wrap:!1}}),C=new V({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBjcmVhdGUtcHlwcm9qZWN0JTIwLWYlMjBwYXRoJTJGdG8lMkZrZXJuZWw=",highlighted:"$ kernel-builder create-pyproject -f path/to/kernel",wrap:!1}}),G=new de({props:{title:"Testing kernel builds before publishing",local:"testing-kernel-builds-before-publishing",headingTag:"h2"}}),U=new V({props:{code:"JTI0JTIwTE9DQUxfS0VSTkVMUyUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUzRGRldmVsJTJGYWN0aXZhdGlvbiUyMiUyMCU1QyUwQSUyMCUyMHB5dGhvbiUyMG15X2FwcC5weQ==",highlighted:`$ LOCAL_KERNELS=<span class="hljs-string">&quot;kernels-community/activation=devel/activation&quot;</span> \\
  python my_app.py`,wrap:!1}}),W=new V({props:{code:"JTI0JTIwTE9DQUxfS0VSTkVMUyUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUzRGRldmVsJTJGYWN0aXZhdGlvbiUzQWtlcm5lbHMtY29tbXVuaXR5JTJGZmxhc2gtYXR0bjIlM0RkZXZlbCUyRmZsYXNoLWF0dG4yJTIyJTIwJTVDJTBBJTIwJTIwcHl0aG9uJTIwbXlfYXBwLnB5",highlighted:`$ LOCAL_KERNELS=<span class="hljs-string">&quot;kernels-community/activation=devel/activation:kernels-community/flash-attn2=devel/flash-attn2&quot;</span> \\
  python my_app.py`,wrap:!1}}),P=new He({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/local-dev.md"}}),{c(){$=o("meta"),Z=i(),R=o("p"),Y=i(),s(h.$$.fragment),E=i(),s(b.$$.fragment),S=i(),s(w.$$.fragment),q=i(),y=o("p"),y.innerHTML=fe,N=i(),T=o("p"),T.innerHTML=ue,z=i(),s(g.$$.fragment),B=i(),v=o("p"),v.innerHTML=ce,D=i(),s(k.$$.fragment),Q=i(),J=o("p"),J.innerHTML=$e,A=i(),M=o("p"),M.textContent=he,F=i(),s(L.$$.fragment),K=i(),I=o("p"),I.textContent=be,O=i(),s(C.$$.fragment),ee=i(),_=o("p"),_.innerHTML=we,te=i(),x=o("ul"),x.innerHTML=ye,le=i(),s(G.$$.fragment),ne=i(),H=o("p"),H.innerHTML=Te,ie=i(),s(U.$$.fragment),re=i(),j=o("p"),j.innerHTML=ge,oe=i(),s(W.$$.fragment),ae=i(),s(P.$$.fragment),se=i(),X=o("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);$=a(t,"META",{name:!0,content:!0}),t.forEach(l),Z=r(e),R=a(e,"P",{}),ve(R).forEach(l),Y=r(e),p(h.$$.fragment,e),E=r(e),p(b.$$.fragment,e),S=r(e),p(w.$$.fragment,e),q=r(e),y=a(e,"P",{"data-svelte-h":!0}),c(y)!=="svelte-rs46k0"&&(y.innerHTML=fe),N=r(e),T=a(e,"P",{"data-svelte-h":!0}),c(T)!=="svelte-k18632"&&(T.innerHTML=ue),z=r(e),p(g.$$.fragment,e),B=r(e),v=a(e,"P",{"data-svelte-h":!0}),c(v)!=="svelte-1a27bcp"&&(v.innerHTML=ce),D=r(e),p(k.$$.fragment,e),Q=r(e),J=a(e,"P",{"data-svelte-h":!0}),c(J)!=="svelte-1argkq5"&&(J.innerHTML=$e),A=r(e),M=a(e,"P",{"data-svelte-h":!0}),c(M)!=="svelte-17new3z"&&(M.textContent=he),F=r(e),p(L.$$.fragment,e),K=r(e),I=a(e,"P",{"data-svelte-h":!0}),c(I)!=="svelte-1oav1so"&&(I.textContent=be),O=r(e),p(C.$$.fragment,e),ee=r(e),_=a(e,"P",{"data-svelte-h":!0}),c(_)!=="svelte-1u66aq8"&&(_.innerHTML=we),te=r(e),x=a(e,"UL",{"data-svelte-h":!0}),c(x)!=="svelte-2khbd3"&&(x.innerHTML=ye),le=r(e),p(G.$$.fragment,e),ne=r(e),H=a(e,"P",{"data-svelte-h":!0}),c(H)!=="svelte-1fqf7j9"&&(H.innerHTML=Te),ie=r(e),p(U.$$.fragment,e),re=r(e),j=a(e,"P",{"data-svelte-h":!0}),c(j)!=="svelte-5f7yaa"&&(j.innerHTML=ge),oe=r(e),p(W.$$.fragment,e),ae=r(e),p(P.$$.fragment,e),se=r(e),X=a(e,"P",{}),ve(X).forEach(l),this.h()},h(){ke($,"name","hf:doc:metadata"),ke($,"content",je)},m(e,t){xe(document.head,$),n(e,Z,t),n(e,R,t),n(e,Y,t),d(h,e,t),n(e,E,t),d(b,e,t),n(e,S,t),d(w,e,t),n(e,q,t),n(e,y,t),n(e,N,t),n(e,T,t),n(e,z,t),d(g,e,t),n(e,B,t),n(e,v,t),n(e,D,t),d(k,e,t),n(e,Q,t),n(e,J,t),n(e,A,t),n(e,M,t),n(e,F,t),d(L,e,t),n(e,K,t),n(e,I,t),n(e,O,t),d(C,e,t),n(e,ee,t),n(e,_,t),n(e,te,t),n(e,x,t),n(e,le,t),d(G,e,t),n(e,ne,t),n(e,H,t),n(e,ie,t),d(U,e,t),n(e,re,t),n(e,j,t),n(e,oe,t),d(W,e,t),n(e,ae,t),d(P,e,t),n(e,se,t),n(e,X,t),pe=!0},p:Me,i(e){pe||(m(h.$$.fragment,e),m(b.$$.fragment,e),m(w.$$.fragment,e),m(g.$$.fragment,e),m(k.$$.fragment,e),m(L.$$.fragment,e),m(C.$$.fragment,e),m(G.$$.fragment,e),m(U.$$.fragment,e),m(W.$$.fragment,e),m(P.$$.fragment,e),pe=!0)},o(e){f(h.$$.fragment,e),f(b.$$.fragment,e),f(w.$$.fragment,e),f(g.$$.fragment,e),f(k.$$.fragment,e),f(L.$$.fragment,e),f(C.$$.fragment,e),f(G.$$.fragment,e),f(U.$$.fragment,e),f(W.$$.fragment,e),f(P.$$.fragment,e),pe=!1},d(e){e&&(l(Z),l(R),l(Y),l(E),l(S),l(q),l(y),l(N),l(T),l(z),l(B),l(v),l(D),l(Q),l(J),l(A),l(M),l(F),l(K),l(I),l(O),l(ee),l(_),l(te),l(x),l(le),l(ne),l(H),l(ie),l(re),l(j),l(oe),l(ae),l(se),l(X)),l($),u(h,e),u(b,e),u(w,e),u(g,e),u(k,e),u(L,e),u(C,e),u(G,e),u(U,e),u(W,e),u(P,e)}}}const je='{"title":"Local development of kernels","local":"local-development-of-kernels","sections":[{"title":"Introduction","local":"introduction","sections":[],"depth":2},{"title":"Generating a Python project with kernel-builder","local":"generating-a-python-project-with-kernel-builder","sections":[],"depth":2},{"title":"Testing kernel builds before publishing","local":"testing-kernel-builds-before-publishing","sections":[],"depth":2}],"depth":1}';function We(me){return Le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ye extends Ie{constructor($){super(),Ce(this,$,We,Ue,Je,{})}}export{Ye as component};
