File size: 1,676 Bytes
d52c89c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | The attention/MLP implementation follows architecture and tensor conventions
from karpathy/nanochat, inspected at 92d63d4e8bb4df75c3b71618f31ddde2378b2bcd.
Upstream license follows:
MIT License
Copyright (c) 2025 Andrej Karpathy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
kernels.py adapts the depth attention kernel design (two frames per 16-row
tile, block-diagonal causal mask, recomputed backward) from naklecha/caramel
kernels.py, inspected at 84a9271d265841543287d4044d7ef80991a2b003, licensed
under the Apache License, Version 2.0
(https://www.apache.org/licenses/LICENSE-2.0). It was rewritten for separate
query, key and value tensors in [rows, positions, heads, head_width] layout.
|