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!
This was a final project for a graphics class where we used WebGL a lot. Also I was just more familiar with OpenGL and haven't looked that much into webGPU
Super cool project! How much of the inference time is actually GPU-bound vs CPU-bound in the browser? Curious if WebGPU would offer a big perf boost over WebGL2 here.
> 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).
I learned about this at the lecture last week. So fun to see this project.
Incredible. Was going to suggest tossing up a github page with it, but looks like one is currently in-progress? (https://nathan-barry.github.io/gpt2-webgl/) but doesn't seem to load for me currently.
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.
Yeah, right now the weights aren't even pushed to the repo so there's no way for the github page to load them in. I've looked a tiny bit into it and might end up making a fix for it, having it load the weights by fetching them from somewhere else on load, but probably not today.
This is pretty rad. I've built and run the project on my MacBook and can't seem to get the visualizations to show as they appear in the GitHub demonstration. I'm running Firefox but I think that should support WebGL features you're using?
Happy to file an issue on the repository as well if you'd prefer that.
Nice, that takes some serious grinding to pull off in shaders. Makes me kinda wonder - does pushing old tools like WebGL actually force deeper understanding of how these models work compared to just grabbing a new library?
Curious why you chose WebGL over WebGPU? Just to show it can be done?
(Also see my other comment about fetching weights from huggingface)