Buckets:

download
raw
8.9 kB
import{s as Je,n as Me,o as Le}from"../chunks/scheduler.f3b1e791.js";import{S as Ie,i as Ce,e as r,s as i,c as s,h as _e,a as o,d as l,b as a,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.6a283b74.js";import{C as V}from"../chunks/CodeBlock.0b4f9732.js";import{H as de,E as He}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.69a3f880.js";function Ue(me){let h,Z,R,Y,$,E,b,S,w,q,g,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,y,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,T,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,he=`The <code>-f</code> flag is optional and instructs <code>kernel-builder</code> to overwrite
existing files.`,A,M,$e=`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,ge=`<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,ye=`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,ae,j,Te=`It is also possible to map multiple repositories to local kernel directories
by separating the entries with a colon (<code>:</code>):`,re,W,oe,P,se,X,pe;return $=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"}}),T=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",lang:"bash",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 .`,lang:"bash",wrap:!1}}),C=new V({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBjcmVhdGUtcHlwcm9qZWN0JTIwLWYlMjBwYXRoJTJGdG8lMkZrZXJuZWw=",highlighted:"$ kernel-builder create-pyproject -f path/to/kernel",lang:"bash",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`,lang:"bash",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`,lang:"bash",wrap:!1}}),P=new He({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/local-dev.md"}}),{c(){h=r("meta"),Z=i(),R=r("p"),Y=i(),s($.$$.fragment),E=i(),s(b.$$.fragment),S=i(),s(w.$$.fragment),q=i(),g=r("p"),g.innerHTML=fe,N=i(),y=r("p"),y.innerHTML=ue,z=i(),s(T.$$.fragment),B=i(),v=r("p"),v.innerHTML=ce,D=i(),s(k.$$.fragment),Q=i(),J=r("p"),J.innerHTML=he,A=i(),M=r("p"),M.textContent=$e,F=i(),s(L.$$.fragment),K=i(),I=r("p"),I.textContent=be,O=i(),s(C.$$.fragment),ee=i(),_=r("p"),_.innerHTML=we,te=i(),x=r("ul"),x.innerHTML=ge,le=i(),s(G.$$.fragment),ne=i(),H=r("p"),H.innerHTML=ye,ie=i(),s(U.$$.fragment),ae=i(),j=r("p"),j.innerHTML=Te,re=i(),s(W.$$.fragment),oe=i(),s(P.$$.fragment),se=i(),X=r("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);h=o(t,"META",{name:!0,content:!0}),t.forEach(l),Z=a(e),R=o(e,"P",{}),ve(R).forEach(l),Y=a(e),p($.$$.fragment,e),E=a(e),p(b.$$.fragment,e),S=a(e),p(w.$$.fragment,e),q=a(e),g=o(e,"P",{"data-svelte-h":!0}),c(g)!=="svelte-rs46k0"&&(g.innerHTML=fe),N=a(e),y=o(e,"P",{"data-svelte-h":!0}),c(y)!=="svelte-k18632"&&(y.innerHTML=ue),z=a(e),p(T.$$.fragment,e),B=a(e),v=o(e,"P",{"data-svelte-h":!0}),c(v)!=="svelte-1a27bcp"&&(v.innerHTML=ce),D=a(e),p(k.$$.fragment,e),Q=a(e),J=o(e,"P",{"data-svelte-h":!0}),c(J)!=="svelte-1argkq5"&&(J.innerHTML=he),A=a(e),M=o(e,"P",{"data-svelte-h":!0}),c(M)!=="svelte-17new3z"&&(M.textContent=$e),F=a(e),p(L.$$.fragment,e),K=a(e),I=o(e,"P",{"data-svelte-h":!0}),c(I)!=="svelte-1oav1so"&&(I.textContent=be),O=a(e),p(C.$$.fragment,e),ee=a(e),_=o(e,"P",{"data-svelte-h":!0}),c(_)!=="svelte-1u66aq8"&&(_.innerHTML=we),te=a(e),x=o(e,"UL",{"data-svelte-h":!0}),c(x)!=="svelte-2khbd3"&&(x.innerHTML=ge),le=a(e),p(G.$$.fragment,e),ne=a(e),H=o(e,"P",{"data-svelte-h":!0}),c(H)!=="svelte-1fqf7j9"&&(H.innerHTML=ye),ie=a(e),p(U.$$.fragment,e),ae=a(e),j=o(e,"P",{"data-svelte-h":!0}),c(j)!=="svelte-5f7yaa"&&(j.innerHTML=Te),re=a(e),p(W.$$.fragment,e),oe=a(e),p(P.$$.fragment,e),se=a(e),X=o(e,"P",{}),ve(X).forEach(l),this.h()},h(){ke(h,"name","hf:doc:metadata"),ke(h,"content",je)},m(e,t){xe(document.head,h),n(e,Z,t),n(e,R,t),n(e,Y,t),d($,e,t),n(e,E,t),d(b,e,t),n(e,S,t),d(w,e,t),n(e,q,t),n(e,g,t),n(e,N,t),n(e,y,t),n(e,z,t),d(T,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,ae,t),n(e,j,t),n(e,re,t),d(W,e,t),n(e,oe,t),d(P,e,t),n(e,se,t),n(e,X,t),pe=!0},p:Me,i(e){pe||(m($.$$.fragment,e),m(b.$$.fragment,e),m(w.$$.fragment,e),m(T.$$.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($.$$.fragment,e),f(b.$$.fragment,e),f(w.$$.fragment,e),f(T.$$.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(g),l(N),l(y),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(ae),l(j),l(re),l(oe),l(se),l(X)),l(h),u($,e),u(b,e),u(w,e),u(T,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(h){super(),Ce(this,h,We,Ue,Je,{})}}export{Ye as component};

Xet Storage Details

Size:
8.9 kB
·
Xet hash:
d26a876a27921b05760607d904eb1e562ab6d2f8da7c24ce1fef658157b2f8ab

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.