-
Notifications
You must be signed in to change notification settings - Fork 24
Add Softmax kernel in Triton. Use softmax kernel and argmax in Llama generation.py. + Small changes #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Softmax kernel in Triton. Use softmax kernel and argmax in Llama generation.py. + Small changes #11
Changes from 1 commit
a9cb93a
6475766
426b934
7c84e9d
16c4040
7e47ddd
a8759f1
213c407
bec9312
88e1bed
243e22b
036e4bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from kernels.cross_entropy import cross_entropy | ||
from kernels.matmul import matmul | ||
from kernels.flash_attention import attention | ||
from kernels.fused_softmax import triton_softmax | ||
from benchmarking import Profiler | ||
import time | ||
|
||
|
@@ -70,14 +71,15 @@ def attention(self, xq, keys, values, head_dim, mask): | |
|
||
@Profiler.profiling_decorator("softmax") | ||
def softmax(self, x, dim): | ||
if self.use_triton: | ||
return F.softmax(x, dim=-1) | ||
if self.use_triton and len(x) == 2: | ||
|
||
return triton_softmax(x, dim=-1) | ||
|
||
else: | ||
return F.softmax(x, dim=-1) | ||
|
||
@Profiler.profiling_decorator("argmax") | ||
def argmax(self, x, dim): | ||
if self.use_triton: | ||
# TODO: change | ||
|
||
return torch.argmax(x, dim=-1) | ||
else: | ||
return torch.argmax(x, dim=-1) | ||
|
Uh oh!
There was an error while loading. Please reload this page.