Buckets:
| import{s as Ie,n as Ce,o as _e}from"../chunks/scheduler.f3b1e791.js";import{S as xe,i as He,e as r,s as i,c as s,h as Ge,a as o,d as l,b as a,f as Me,g as p,j as d,k as Le,l as Ue,m as n,n as m,t as f,o as u,p as c}from"../chunks/index.023a9934.js";import{C as je}from"../chunks/CopyLLMTxtMenu.c780467c.js";import{C as Z}from"../chunks/CodeBlock.fc650646.js";import{H as fe,E as We}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.fb377ec3.js";function Pe(ue){let h,E,V,S,$,Y,b,q,w,N,g,ce=`<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.`,z,y,he=`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.`,B,T,D,v,$e=`<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:`,Q,k,A,J,be=`The <code>-f</code> flag is optional and instructs <code>kernel-builder</code> to overwrite | |
| existing files.`,F,M,we=`It is recommended to do an editable install of the generated project into | |
| your Python virtual environment for development:`,K,L,O,I,ge="You can also create a Python project for a kernel in another directory:",ee,C,te,_,ye="<strong>Warnings:</strong>",le,x,Te=`<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>`,ne,H,ve=`See <a href="./ide-setup">IDE Setup</a> for wiring the generated project into | |
| VS Code with direnv.`,ie,G,ae,U,ke=`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:`,re,j,oe,W,Je=`It is also possible to map multiple repositories to local kernel directories | |
| by separating the entries with a colon (<code>:</code>):`,se,P,pe,R,de,X,me;return $=new je({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new fe({props:{title:"Local development of kernels",local:"local-development-of-kernels",headingTag:"h1"}}),w=new fe({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),T=new fe({props:{title:"Generating a Python project with kernel-builder",local:"generating-a-python-project-with-kernel-builder",headingTag:"h2"}}),k=new Z({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBjcmVhdGUtcHlwcm9qZWN0JTIwLWY=",highlighted:"$ kernel-builder create-pyproject -f",lang:"bash",wrap:!1}}),L=new Z({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 Z({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBjcmVhdGUtcHlwcm9qZWN0JTIwLWYlMjBwYXRoJTJGdG8lMkZrZXJuZWw=",highlighted:"$ kernel-builder create-pyproject -f path/to/kernel",lang:"bash",wrap:!1}}),G=new fe({props:{title:"Testing kernel builds before publishing",local:"testing-kernel-builds-before-publishing",headingTag:"h2"}}),j=new Z({props:{code:"JTI0JTIwTE9DQUxfS0VSTkVMUyUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUzRGRldmVsJTJGYWN0aXZhdGlvbiUyMiUyMCU1QyUwQSUyMCUyMHB5dGhvbiUyMG15X2FwcC5weQ==",highlighted:`$ LOCAL_KERNELS=<span class="hljs-string">"kernels-community/activation=devel/activation"</span> \\ | |
| python my_app.py`,lang:"bash",wrap:!1}}),P=new Z({props:{code:"JTI0JTIwTE9DQUxfS0VSTkVMUyUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGYWN0aXZhdGlvbiUzRGRldmVsJTJGYWN0aXZhdGlvbiUzQWtlcm5lbHMtY29tbXVuaXR5JTJGZmxhc2gtYXR0bjIlM0RkZXZlbCUyRmZsYXNoLWF0dG4yJTIyJTIwJTVDJTBBJTIwJTIwcHl0aG9uJTIwbXlfYXBwLnB5",highlighted:`$ LOCAL_KERNELS=<span class="hljs-string">"kernels-community/activation=devel/activation:kernels-community/flash-attn2=devel/flash-attn2"</span> \\ | |
| python my_app.py`,lang:"bash",wrap:!1}}),R=new We({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/local-dev.md"}}),{c(){h=r("meta"),E=i(),V=r("p"),S=i(),s($.$$.fragment),Y=i(),s(b.$$.fragment),q=i(),s(w.$$.fragment),N=i(),g=r("p"),g.innerHTML=ce,z=i(),y=r("p"),y.innerHTML=he,B=i(),s(T.$$.fragment),D=i(),v=r("p"),v.innerHTML=$e,Q=i(),s(k.$$.fragment),A=i(),J=r("p"),J.innerHTML=be,F=i(),M=r("p"),M.textContent=we,K=i(),s(L.$$.fragment),O=i(),I=r("p"),I.textContent=ge,ee=i(),s(C.$$.fragment),te=i(),_=r("p"),_.innerHTML=ye,le=i(),x=r("ul"),x.innerHTML=Te,ne=i(),H=r("p"),H.innerHTML=ve,ie=i(),s(G.$$.fragment),ae=i(),U=r("p"),U.innerHTML=ke,re=i(),s(j.$$.fragment),oe=i(),W=r("p"),W.innerHTML=Je,se=i(),s(P.$$.fragment),pe=i(),s(R.$$.fragment),de=i(),X=r("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);h=o(t,"META",{name:!0,content:!0}),t.forEach(l),E=a(e),V=o(e,"P",{}),Me(V).forEach(l),S=a(e),p($.$$.fragment,e),Y=a(e),p(b.$$.fragment,e),q=a(e),p(w.$$.fragment,e),N=a(e),g=o(e,"P",{"data-svelte-h":!0}),d(g)!=="svelte-rs46k0"&&(g.innerHTML=ce),z=a(e),y=o(e,"P",{"data-svelte-h":!0}),d(y)!=="svelte-k18632"&&(y.innerHTML=he),B=a(e),p(T.$$.fragment,e),D=a(e),v=o(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-1a27bcp"&&(v.innerHTML=$e),Q=a(e),p(k.$$.fragment,e),A=a(e),J=o(e,"P",{"data-svelte-h":!0}),d(J)!=="svelte-1argkq5"&&(J.innerHTML=be),F=a(e),M=o(e,"P",{"data-svelte-h":!0}),d(M)!=="svelte-17new3z"&&(M.textContent=we),K=a(e),p(L.$$.fragment,e),O=a(e),I=o(e,"P",{"data-svelte-h":!0}),d(I)!=="svelte-1oav1so"&&(I.textContent=ge),ee=a(e),p(C.$$.fragment,e),te=a(e),_=o(e,"P",{"data-svelte-h":!0}),d(_)!=="svelte-1u66aq8"&&(_.innerHTML=ye),le=a(e),x=o(e,"UL",{"data-svelte-h":!0}),d(x)!=="svelte-2khbd3"&&(x.innerHTML=Te),ne=a(e),H=o(e,"P",{"data-svelte-h":!0}),d(H)!=="svelte-6k4c84"&&(H.innerHTML=ve),ie=a(e),p(G.$$.fragment,e),ae=a(e),U=o(e,"P",{"data-svelte-h":!0}),d(U)!=="svelte-1fqf7j9"&&(U.innerHTML=ke),re=a(e),p(j.$$.fragment,e),oe=a(e),W=o(e,"P",{"data-svelte-h":!0}),d(W)!=="svelte-5f7yaa"&&(W.innerHTML=Je),se=a(e),p(P.$$.fragment,e),pe=a(e),p(R.$$.fragment,e),de=a(e),X=o(e,"P",{}),Me(X).forEach(l),this.h()},h(){Le(h,"name","hf:doc:metadata"),Le(h,"content",Re)},m(e,t){Ue(document.head,h),n(e,E,t),n(e,V,t),n(e,S,t),m($,e,t),n(e,Y,t),m(b,e,t),n(e,q,t),m(w,e,t),n(e,N,t),n(e,g,t),n(e,z,t),n(e,y,t),n(e,B,t),m(T,e,t),n(e,D,t),n(e,v,t),n(e,Q,t),m(k,e,t),n(e,A,t),n(e,J,t),n(e,F,t),n(e,M,t),n(e,K,t),m(L,e,t),n(e,O,t),n(e,I,t),n(e,ee,t),m(C,e,t),n(e,te,t),n(e,_,t),n(e,le,t),n(e,x,t),n(e,ne,t),n(e,H,t),n(e,ie,t),m(G,e,t),n(e,ae,t),n(e,U,t),n(e,re,t),m(j,e,t),n(e,oe,t),n(e,W,t),n(e,se,t),m(P,e,t),n(e,pe,t),m(R,e,t),n(e,de,t),n(e,X,t),me=!0},p:Ce,i(e){me||(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(j.$$.fragment,e),f(P.$$.fragment,e),f(R.$$.fragment,e),me=!0)},o(e){u($.$$.fragment,e),u(b.$$.fragment,e),u(w.$$.fragment,e),u(T.$$.fragment,e),u(k.$$.fragment,e),u(L.$$.fragment,e),u(C.$$.fragment,e),u(G.$$.fragment,e),u(j.$$.fragment,e),u(P.$$.fragment,e),u(R.$$.fragment,e),me=!1},d(e){e&&(l(E),l(V),l(S),l(Y),l(q),l(N),l(g),l(z),l(y),l(B),l(D),l(v),l(Q),l(A),l(J),l(F),l(M),l(K),l(O),l(I),l(ee),l(te),l(_),l(le),l(x),l(ne),l(H),l(ie),l(ae),l(U),l(re),l(oe),l(W),l(se),l(pe),l(de),l(X)),l(h),c($,e),c(b,e),c(w,e),c(T,e),c(k,e),c(L,e),c(C,e),c(G,e),c(j,e),c(P,e),c(R,e)}}}const Re='{"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 Ve(ue){return _e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends xe{constructor(h){super(),He(this,h,Ve,Pe,Ie,{})}}export{qe as component}; | |
Xet Storage Details
- Size:
- 9.15 kB
- Xet hash:
- d6cea08ba30a7a632524027e517b77de026ee9ff51f977ecdb90873183e344a5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.