Minimal GPT2 Inference in C++
Here’s a little project which runs GPT2 inference with every operation rolled out by hand to be inspectable and debuggable, in C++, with no dependences. Ideal for learning about the Transformer mechanism.
Software Engineering
Here’s a little project which runs GPT2 inference with every operation rolled out by hand to be inspectable and debuggable, in C++, with no dependences. Ideal for learning about the Transformer mechanism.
This article is reproduced for posterity from codeflow.org, which is now no longer online. It explains how to render a realistic sky in GLSL by ray‐marching through a simplified spherical atmosphere.
This project moves code from the Real-Time Physically Based Rendering and BRDFs post below from rasterization to Monte Carlo integration with ray tracing. Implemented in GLSL shaders and WebAssembly.
The topic of lighting algorithms can be confusing, so this article will break down the building blocks of lighting, introducing each element from the most simple models to a physically based one which can render a range of metals and plastics, of varying roughness in a single Unity3D ShaderLab prgram.
The listing for this article is available in the a Gist.
Modern systems have a lot more functionaliy than classic ones, except for the ability to render non-square pictures as unlike CRTs, modern displays have fixed square pixels. This means when drawing at the correct aspect ratio there is no direct mapping of pixels between displays at any scale. Emulators usually handle this by using an incorrect aspect ratio and scaling at a round multiple, but a full screen scaling isn’t going to be an exact multiple of the original size.
A good way to solve this problem is supersampling the original pixels, Here is a live example in WebAssembly.
Naive nearest neighbor upscaling on the left, supersampling on the right.
Had a need to approximate a function in a very minimal environment lately, so here’s an example of how to write a PyTorch model to raw JavaScript. Might expand to do GLSL at some point.
https://github.com/binaryfoundry/pytorch-to-js-example
WebAssembly threads are available to try, so here’s Ray Tracing in One Weekend ported to make use of WASM threads. Done unobtrusively to keep it simple. Probably only working on Chrome so far and with some flags enabled described on the page.
Also generates Visual Studio projects which is useful for RTOW readers on Windows.
https://binaryfoundry.github.io/rtow/
https://github.com/binaryfoundry/raytracinginoneweekend-emscripten
In the future coding job interviews might not only ask questions about basic time-complexity such as Big O, but involve intractable problems and how to approximate solutions in realistic time-frames. Or to put it a little more bluntly, employers will want to know if you have some machine learning knowledge.
This post is about a very simple learning algorithm called Q-Learning, although simple it can be used to effectively tackle problems such as elevator scheduling, and is the underlying idea behind Alpha Go, DeepMind’s Go playing AI. The Tic Tac Toe game below has an opponent trained using Q-Learning, the algorithm should find a good strategy, try it out!