-
Notifications
You must be signed in to change notification settings - Fork 95
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
fix: attention refactor and base doc #216
Conversation
full test is passing, i suggest re-run on 3090 just in case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit hard to review but the new naming convention make the code easier to read.
There is still some omissions in the whole renaming. I've pointed out 3-4 of them in the feedback, not sure if there is others remaining.
src/kernl/implementations/README.md
Outdated
Suffixes list: | ||
- `_idx` integer representing an index | ||
- `_size` integer representing a size | ||
- `_off` integer reoresenting an offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
representing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/kernl/implementations/README.md
Outdated
## Dimension naming | ||
- Dimension is singular | ||
- If dimension follows variable name from a formula. You can use this name. Example MNK for matmul | ||
- Use `col` or `row` singular if you don't have a new for the last two dimensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't have a name ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
output_row_stride, | ||
output_col_stride, | ||
a_row_stride, | ||
a_col_stride, | ||
N, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use n_size
and block_n_size
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pid_n = (pid % width) // (group_size) | ||
group_idx = program_idx // width | ||
group_size = min(grid_m - group_idx * GROUP_M, GROUP_M) | ||
m_block_idx = group_idx * GROUP_M + (program_idx % group_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be block_m_idx
and block_n_idx
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
BLOCK_N: tl.constexpr, | ||
BLOCK_M_SIZE: tl.constexpr, | ||
BLOCK_DHEAD_SIZE: tl.constexpr, | ||
BLOCK_N_SIZE: tl.constexpr, | ||
): | ||
# Index of the block on M axis (M axis is the rows of matrix K) | ||
n_block_idx = tl.program_id(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be block_n_idx
and block_m_idx
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ptrs_q = Q + offs_q | ||
ptrs_k = K + offs_k | ||
ptrs_v = V + offs_v | ||
ptrs_q = q_ptr + offs_q |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q_ptrs
, k_ptrs
and v_ptrs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to review but it's really hard.
Did it passed tests? (full pytest)
Added few remarks on top of those of @jonathlela
src/kernl/implementations/README.md
Outdated
@@ -0,0 +1,41 @@ | |||
# Naming conventions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README in a more visible location like contribution folder? With a good title / name so we know its purpose.
@@ -186,21 +186,21 @@ def _fwd_kernel( | |||
┌────────────┐ | |||
│ │ │ | |||
M Dimension│ ├────────────┤ ┌───┐ | |||
size_m │ │ │ │ │ BLOCK_M | |||
m_size │ │ │ │ │ BLOCK_M |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BLOCK_M_SIZE ? same fo N
@pommedeterresautee no got an error at the end, I will try to reproduce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Markown is optimized but the lack of line breaks makes it less readable in .md
for maintainers and not readable once converted to HTML on the site.
- Don't hesitate to put line breaks after the titles and especially before the lists (otherwise they will be displayed inline).
- Tip: stay consistent on punctuation, especially the
.
at the end of the line and the:
(either you put them everywhere or you don't).
Otherwise it's fine.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quite hard to review line by line but from what I checked, it's ok.
plus test pass
@gaetansnl Still missing a line break. |
Linear is partially refactored because input name is fixed by early_config_prune
I avoided important changes except refactor to linear:
fixes #229