Buckets:

HuggingFaceDocBuilder's picture
download
raw
6.55 kB
import{s as te,n as ne,o as le}from"../chunks/scheduler.f3b1e791.js";import{S as se,i as ae,e as r,s,c as v,h as ie,a as m,d as n,b as a,f as D,g as k,j as _,k as O,l as re,m as l,n as T,t as w,o as J,p as j}from"../chunks/index.023a9934.js";import{C as me}from"../chunks/CopyLLMTxtMenu.cf318e17.js";import{C as ee}from"../chunks/CodeBlock.209f1898.js";import{H as N,E as oe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.7dd80aee.js";function pe(S){let i,E,C,U,o,I,p,B,c,Z,u,P='Here is how you would use the <a href="https://huggingface.co/kernels-community/activation" rel="nofollow">activation</a> kernels from the Hugging Face Hub:',G,h,X,f,q=`This fetches version <code>1</code> of the kernel <code>kernels-community/activation</code>.
Kernels are versioned using a major version number. Using <code>version=1</code> will
get the latest kernel build from the <code>v1</code> branch.`,Y,d,K=`Kernels 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.`,H,y,Q=`Some kernels have not yet been updated to use versioning yet. In these cases,
you can use <code>get_kernel</code> without the <code>version</code> argument.`,V,M,W,g,A=`You can check if a particular version of a kernel supports the environment
that the program is running on:`,R,b,z,$,L,x,F;return o=new me({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),p=new N({props:{title:"Quickstart",local:"quickstart",headingTag:"h1"}}),c=new N({props:{title:"Loading Kernels",local:"loading-kernels",headingTag:"h2"}}),h=new ee({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMGdldF9rZXJuZWwlMEElMEElMjMlMjBEb3dubG9hZCUyMG9wdGltaXplZCUyMGtlcm5lbHMlMjBmcm9tJTIwdGhlJTIwSHVnZ2luZyUyMEZhY2UlMjBodWIlMEFhY3RpdmF0aW9uJTIwJTNEJTIwZ2V0X2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMjB2ZXJzaW9uJTNEMSklMEElMEElMjMlMjBDcmVhdGUlMjBhJTIwcmFuZG9tJTIwdGVuc29yJTBBeCUyMCUzRCUyMHRvcmNoLnJhbmRuKCgxMCUyQyUyMDEwKSUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIpJTBBJTBBJTIzJTIwUnVuJTIwdGhlJTIwa2VybmVsJTBBeSUyMCUzRCUyMHRvcmNoLmVtcHR5X2xpa2UoeCklMEFhY3RpdmF0aW9uLmdlbHVfZmFzdCh5JTJDJTIweCklMEElMEFwcmludCh5KQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> get_kernel
<span class="hljs-comment"># Download optimized kernels from the Hugging Face hub</span>
activation = get_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>, version=<span class="hljs-number">1</span>)
<span class="hljs-comment"># Create a random tensor</span>
x = torch.randn((<span class="hljs-number">10</span>, <span class="hljs-number">10</span>), dtype=torch.float16, device=<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># Run the kernel</span>
y = torch.empty_like(x)
activation.gelu_fast(y, x)
<span class="hljs-built_in">print</span>(y)`,wrap:!1}}),M=new N({props:{title:"Checking Kernel Availability",local:"checking-kernel-availability",headingTag:"h2"}}),b=new ee({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBoYXNfa2VybmVsJTBBJTBBJTIzJTIwQ2hlY2slMjBpZiUyMGtlcm5lbCUyMGlzJTIwYXZhaWxhYmxlJTIwZm9yJTIwY3VycmVudCUyMGVudmlyb25tZW50JTBBaXNfYXZhaWxhYmxlJTIwJTNEJTIwaGFzX2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMjB2ZXJzaW9uJTNEMSklMEFwcmludChmJTIyS2VybmVsJTIwYXZhaWxhYmxlJTNBJTIwJTdCaXNfYXZhaWxhYmxlJTdEJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> has_kernel
<span class="hljs-comment"># Check if kernel is available for current environment</span>
is_available = has_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>, version=<span class="hljs-number">1</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Kernel available: <span class="hljs-subst">{is_available}</span>&quot;</span>)`,wrap:!1}}),$=new oe({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/basic-usage.md"}}),{c(){i=r("meta"),E=s(),C=r("p"),U=s(),v(o.$$.fragment),I=s(),v(p.$$.fragment),B=s(),v(c.$$.fragment),Z=s(),u=r("p"),u.innerHTML=P,G=s(),v(h.$$.fragment),X=s(),f=r("p"),f.innerHTML=q,Y=s(),d=r("p"),d.textContent=K,H=s(),y=r("p"),y.innerHTML=Q,V=s(),v(M.$$.fragment),W=s(),g=r("p"),g.textContent=A,R=s(),v(b.$$.fragment),z=s(),v($.$$.fragment),L=s(),x=r("p"),this.h()},l(e){const t=ie("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(n),E=a(e),C=m(e,"P",{}),D(C).forEach(n),U=a(e),k(o.$$.fragment,e),I=a(e),k(p.$$.fragment,e),B=a(e),k(c.$$.fragment,e),Z=a(e),u=m(e,"P",{"data-svelte-h":!0}),_(u)!=="svelte-2utbko"&&(u.innerHTML=P),G=a(e),k(h.$$.fragment,e),X=a(e),f=m(e,"P",{"data-svelte-h":!0}),_(f)!=="svelte-1xtp1ii"&&(f.innerHTML=q),Y=a(e),d=m(e,"P",{"data-svelte-h":!0}),_(d)!=="svelte-sotpzr"&&(d.textContent=K),H=a(e),y=m(e,"P",{"data-svelte-h":!0}),_(y)!=="svelte-1ucxhjf"&&(y.innerHTML=Q),V=a(e),k(M.$$.fragment,e),W=a(e),g=m(e,"P",{"data-svelte-h":!0}),_(g)!=="svelte-vgk28x"&&(g.textContent=A),R=a(e),k(b.$$.fragment,e),z=a(e),k($.$$.fragment,e),L=a(e),x=m(e,"P",{}),D(x).forEach(n),this.h()},h(){O(i,"name","hf:doc:metadata"),O(i,"content",ce)},m(e,t){re(document.head,i),l(e,E,t),l(e,C,t),l(e,U,t),T(o,e,t),l(e,I,t),T(p,e,t),l(e,B,t),T(c,e,t),l(e,Z,t),l(e,u,t),l(e,G,t),T(h,e,t),l(e,X,t),l(e,f,t),l(e,Y,t),l(e,d,t),l(e,H,t),l(e,y,t),l(e,V,t),T(M,e,t),l(e,W,t),l(e,g,t),l(e,R,t),T(b,e,t),l(e,z,t),T($,e,t),l(e,L,t),l(e,x,t),F=!0},p:ne,i(e){F||(w(o.$$.fragment,e),w(p.$$.fragment,e),w(c.$$.fragment,e),w(h.$$.fragment,e),w(M.$$.fragment,e),w(b.$$.fragment,e),w($.$$.fragment,e),F=!0)},o(e){J(o.$$.fragment,e),J(p.$$.fragment,e),J(c.$$.fragment,e),J(h.$$.fragment,e),J(M.$$.fragment,e),J(b.$$.fragment,e),J($.$$.fragment,e),F=!1},d(e){e&&(n(E),n(C),n(U),n(I),n(B),n(Z),n(u),n(G),n(X),n(f),n(Y),n(d),n(H),n(y),n(V),n(W),n(g),n(R),n(z),n(L),n(x)),n(i),j(o,e),j(p,e),j(c,e),j(h,e),j(M,e),j(b,e),j($,e)}}}const ce='{"title":"Quickstart","local":"quickstart","sections":[{"title":"Loading Kernels","local":"loading-kernels","sections":[],"depth":2},{"title":"Checking Kernel Availability","local":"checking-kernel-availability","sections":[],"depth":2}],"depth":1}';function ue(S){return le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ge extends se{constructor(i){super(),ae(this,i,ue,pe,te,{})}}export{ge as component};

Xet Storage Details

Size:
6.55 kB
·
Xet hash:
6f02c56af3fdb6937112e96865032f8a1f0f57f6257d48eb6fd0773d1ce8ad16

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