Skip to content
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

Refactor trimat #553

Merged
merged 2 commits into from
Jun 6, 2024
Merged

Refactor trimat #553

merged 2 commits into from
Jun 6, 2024

Conversation

gordicaleksa
Copy link
Contributor

Made sure we're consistent in our notation:

  • Use (B,T,NH,HS) only
  • Constant are upper case

Added additional comments to clarify what each of the kernels is doing, including what the indexing operation is doing, e.g.:
annotate flat indexing: const float* q = inp + b * T * C3 + nh * HS;
with Q[b][nh][:][:] = inp[b][:][0][nh][:]

@gordicaleksa
Copy link
Contributor Author

Additionally I've moved us to the more familiar Q @ K^T form (from previous K^T @ Q).

This is how the attention is always written down in papers and i had a mental overhead parsing the code due to this permutation. :D I made sure there are no differences in terms of perf (they're completely equivalent).

@karpathy karpathy merged commit 067aadc into karpathy:master Jun 6, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants