Andrej Karpathy's microgpt.py translated into the D programming language
Danny Arends
Danny.Arends at gmail.com
Sat Feb 21 12:30:27 UTC 2026
On Saturday, 21 February 2026 at 12:09:52 UTC, Sergey wrote:
> On Saturday, 21 February 2026 at 10:56:39 UTC, Danny Arends
> wrote:
>> I've finished on a port of Andrej Karpathy's microgpt.py to
>> the D programming language. For those unfamiliar, it is a
>> minimal, educational GPT implementation, great for
>> understanding transformer architecture.
>>
>> The D port stays faithful to the original: same architecture,
>> same training logic. Just D instead of Python. D's operator
>> overloading and struct semantics make it a surprisingly
>> natural fit for this kind of low-level ML work.
>>
>> Find it here:
>> https://gist.github.com/DannyArends/12704c9207797a64338a5be4f1010bcf
>
> Nice. Thanks
> The 3rd one :) Will check for some improvements in mine
>
> https://github.com/cyrusmsk/microDpt
> https://github.com/denizzzka/microgpt_dlang (WIP)
Lol, yeah guess everyone want to learn by doing... Looking at the
code, mine is quite a bit shorter. Guess using a more functional
approach with zip, map, fold, joiner et al. makes a big impact in
how compact you can get it.
I also got a basic ggml version working on Linux that uses a
ggml_tensor* for computation. But for some reason it doesn't work
properly under windows (yet).
More information about the Digitalmars-d-learn
mailing list