Show HN: GPT-2 implemented using graphics shaders
222 nathan-barry 25 5/2/2025, 3:21:49 PM github.com ↗
Back in the old days, people used to do general-purpose GPU programming by using shaders like GLSL. This is what inspired NVIDIA (and other companies) to eventually create CUDA (and friends).
This is an implementation of GPT-2 using WebGL and shaders. Enjoy!
Curious why you chose WebGL over WebGPU? Just to show it can be done?
(Also see my other comment about fetching weights from huggingface)
For a WebGPU implementation, one can use transformers.js directly (or many other libraries actually), maybe WebGL is more original.
[1]: https://huggingface.co/docs/transformers.js/index
I learned about this at the lecture last week. So fun to see this project.
Looks like it's trying to load the typescript directly / hosting the source files: `<script type="module" src="src/main.ts"></script>` - instead of hosting the dist folder.
There is a link to the zipped up folder with the weights here: https://github.com/nathan-barry/gpt2-webgl/releases/download...
If anyone wants to make a PR which fetches the file from there, unzips it, then loads in the weights from there that would be greatly appreciated.
Happy to file an issue on the repository as well if you'd prefer that.