
Security News
NIST Under Federal Audit for NVD Processing Backlog and Delays
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Utility functions for OpenAI Triton
Writing fast GPU kernels is easier with Triton than with CUDA, but there is still a lot of tedious indices juggling. That is not necessary.
Triton-util provides simple higher level abstractions for frequent but repetetive tasks. This allows you to write code that is more like your actual ideas.
Example: Say you have a 2d matrix which you have chunked along both axes, and you want to get the next chunk. With triton-util, you write
# ptr = pointer to matrix
# sz0/sz1 = sizes of chunk
# n0/n1 = index of chunk
# max0/max1 = bound of matrix
# stride0/stride1 = strides of matrix (stride1 is not set, so will use the sensible default 1)
load_2d(ptr, sz0, sz1, n0, n1, max0, max1, stride0)
instead of
offs0 = n0 * sz0 + tl.arange(0, sz0)
offs1 = n1 * sz1 + tl.arange(0, sz1)
offs = offs0[:,None] * stride0 + offs1[None,:] * stride1
mask = (offs0[:,None] < max0) & (offs1[None,:] < max1)
return tl.load(ptr + offs, mask)
Additionally, triton-util provides utility functions to make debugging easier. Want to print txt
only on the 1st kernel? Write print_once('txt')
- that's it!
print_once(txt)
breakpoint_once()
print_if(txt, conds)
breakpoint_if('=0,>1')
stops if pid_0 = 0
, pid_1 > 1
and pid_2
is abitrarybreakpoint_if(conds)
breakpoint_if('=0,>1')
stops if pid_0 = 0
, pid_1 > 1
and pid_2
is abitraryassert_tensors_gpu_ready(*tensors)
'TRITON_INTERPRET'=='1'
) on GPUcdiv(a,b)
:
get_1d_offset(sz, n_prev_chunks=0)
(n_prev_chunks+1)
th chunk of size sz
get_2d_offset(offs_0, offs_1, stride_0, stride_1=1)
get_1d_mask(offs, max)
get_2d_mask(offs_0, offs_1, max_0, max_1)
load_2d(ptr, sz0, sz1, n0, n1, max0, max1, stride0, stride1=1)
(sz0,sz1)
, and load the (n0,n1)
th chunk.load_full_2d(ptr, sz0, sz1, stride0, stride1=1)
sz0 x sz1
load_full_1d(ptr, sz, stride=1)
sz
Other resources: Looking for ...
Brought to you by Umer ❤️
FAQs
Make Triton easier - A utility package for OpenAI Triton
We found that triton-util demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.