[{"data":1,"prerenderedAt":278},["ShallowReactive",2],{"project-43870998":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":42,"post_text":45,"what":46,"said":81,"maker_in_thread":177,"shape":187,"grid":191,"attempts":241,"same_week":242,"maker_shows":44,"maker_hidden":270,"reader_version":271,"card":272},"43870998","gpt2-webgl","GPT-2 implemented using graphics shaders","title","Show HN: GPT-2 implemented using graphics shaders","https:\u002F\u002Fgithub.com\u002Fnathan-barry\u002Fgpt2-webgl","github.com","nathan-barry",1746199309,2025,228,25,269,3837,8,"notable","ai","language model inference","web_app",[24,25,26,27,28],"gpt-2","webgl","shaders","browser inference","gpu programming","mixed",0.333,{"positive":32,"neutral":33,"mixed":34,"critical":35},6,7,0,2,15,{"execution":38,"idea":39,"performance":40},{"positive":34,"critical":35},{"positive":35,"critical":34},{"positive":41,"critical":34},1,[43,44,34,44,34,34,34,34,34,44,43,43,34,44,44,44,43,43,41,34,41,34,44,34,43],5,3,"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!",{"problem":47,"audience":53,"pricing":53,"motivation":54,"time_to_build":53,"stack":60,"openness":78,"stage":79,"team_size":80},{"value":48,"source":49,"evidence":50},"Runs GPT-2 language model using graphics shaders instead of CUDA-style compute","maker",[51],{"id":52},"post",null,{"value":55,"source":49,"evidence":56},"Final project for a graphics class using WebGL",[57],{"id":58,"by":11,"text":59},"43872752","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",[61,66,74],{"value":62,"source":49,"evidence":63},"WebGL",[64,65],{"id":52},{"id":58,"by":11,"text":59},{"value":67,"source":68,"evidence":69},"TypeScript","commenter",[70],{"id":71,"by":72,"text":73},"43873069","jasonjmcghee","Incredible. Was going to suggest tossing up a github page with it, but looks like one is currently in-progress? (https:\u002F\u002Fnathan-barry.github.io\u002Fgpt2-webgl\u002F) but doesn't seem to…",{"value":75,"source":49,"evidence":76},"GLSL shaders",[77],{"id":52},"open_source","beta","solo",{"praise":82,"objections":105,"requests":114,"questions":137,"alternatives":149},[83,98],{"value":84,"source":68,"evidence":85},"Cool, impressive project",[86,90,94],{"id":87,"by":88,"text":89},"43872670","ianand","As the guy who did GPT2 in Excel, very cool and kudos!! Curious why you chose WebGL over WebGPU? Just to show it can be done? (Also see my other comment about fetching weights…",{"id":91,"by":92,"text":93},"43873910","gitroom","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…",{"id":95,"by":96,"text":97},"43872083","SamosaGuru","Would be really cool to have it hosted on a website if it can be a static page so we could try it out",{"value":99,"source":68,"evidence":100},"Interesting link to GPU programming history",[101],{"id":102,"by":103,"text":104},"43879005","supuun","> 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…",[106],{"value":107,"source":68,"evidence":108},"Demo page does not load or lacks visualizations",[109,110],{"id":71,"by":72,"text":73},{"id":111,"by":112,"text":113},"43872022","throwaway314155","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…",[115,120,130],{"value":116,"source":68,"evidence":117},"Host a working demo on GitHub Pages",[118,119],{"id":95,"by":96,"text":97},{"id":71,"by":72,"text":73},{"value":121,"source":68,"evidence":122},"Load weights from Hugging Face instead of bundling them",[123,127],{"id":124,"by":125,"text":126},"43872281","Philpax","You may be able to fetch the weights directly from Hugging Face. I'd try that first.",{"id":128,"by":72,"text":129},"43873590","I haven't looked at your implementation, but if you can read ONNX weights... https:\u002F\u002Fhuggingface.co\u002FXenova\u002Fgpt2",{"value":131,"source":68,"evidence":132},"Write-up of how it was made",[133],{"id":134,"by":135,"text":136},"43872860","helloplanets","Would absolutely read a 'making of' post on this project!",[138,142],{"value":139,"source":68,"evidence":140},"Why WebGL instead of WebGPU",[141],{"id":87,"by":88,"text":89},{"value":143,"source":68,"evidence":144},"How much inference time is GPU-bound versus CPU-bound",[145],{"id":146,"by":147,"text":148},"43873384","badmonster","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.",[150,161,167,171],{"value":151,"source":68,"evidence":152},"transformers.js (ONNX runtime)",[153,157],{"id":154,"by":155,"text":156},"43872952","littlestymaar","> Curious why you chose WebGL over WebGPU? Just to show it can be done? For a WebGPU implementation, one can use transformers.js directly (or many other libraries actually),…",{"id":158,"by":159,"text":160},"43874350","85392_school","Transformers.js wraps the ONNX runtime which is rather versatile (WASM, WebGL, WebGPU, and WebNN). It's not the backend that makes it novel.",{"value":162,"source":68,"evidence":163},"gpt2-tfjs",[164],{"id":165,"by":88,"text":166},"43872629","Checkout https:\u002F\u002Fgithub.com\u002Fjseeio\u002Fgpt2-tfjs fetches the weights for GPT2 from huggingface on the fly.",{"value":168,"source":68,"evidence":169},"GPT-2 in Excel",[170],{"id":87,"by":88,"text":89},{"value":172,"source":68,"evidence":173},"Qwen2-0.5B shader world in VRChat",[174],{"id":175,"by":125,"text":176},"43872266","I'm reminded of this VRChat world, which runs Qwen2-0.5B in a shader: https:\u002F\u002Fvrchat.com\u002Fhome\u002Flaunch?worldId=wrld_e919c1f4-8399-43cc-8305-d890dc8e2e98",{"comments":178,"answered":44,"key":179},4,[180,181,184],{"id":58,"text":59},{"id":182,"text":183},"43872135","Working on getting it up on Github pages, will let you know. Not sure if there will be an issue with hosting the weights, I'll look into it",{"id":185,"text":186},"43873654","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…",{"commenters":188,"max_depth":178,"maker_replies":178,"first_comment_mins":189,"lifespan_hours":190},16,78,22,[192,194,198,200,202,204,208,210,213,215,216,217,219,220,221,222,223,225,227,229,231,232,234,236,239],[87,34,43,193,88,34],"maker\u002Fpositive\u002Fnone",[195,34,44,196,197,34],"43872714","project\u002Fneutral\u002Fexecution","ronsor",[58,34,34,199,11,41],"maker\u002Fneutral\u002Fnone",[154,34,44,201,155,34],"project\u002Fneutral\u002Fidea",[158,34,34,203,159,34],"commenter\u002Fneutral\u002Fidea",[205,34,34,206,207,34],"43873542","other\u002Fneutral\u002Fnone","_dijs",[209,34,34,206,88,34],"43877572",[211,34,34,206,212,34],"43874515","divan",[214,34,34,206,88,34],"43877614",[175,41,44,201,125,34],[134,35,43,193,135,34],[95,44,43,218,96,34],"project\u002Fpositive\u002Fnone",[182,44,34,199,11,41],[124,44,44,196,125,34],[165,44,44,196,88,34],[128,44,44,196,72,34],[146,178,43,224,147,34],"project\u002Fpositive\u002Fperformance",[102,43,43,226,103,34],"project\u002Fpositive\u002Fidea",[71,32,41,228,72,34],"project\u002Fcritical\u002Fexecution",[185,32,34,230,11,41],"maker\u002Fneutral\u002Fexecution",[111,33,41,228,112,34],[233,33,34,199,11,41],"43872105",[235,33,44,199,112,34],"43872246",[237,18,34,206,238,34],"43873481","Narishma",[91,240,43,226,92,34],9,[],[243,247,252,256,261,265],{"id":244,"name":245,"points":246,"category":20},"43905942","Clippy",1122,{"id":248,"name":249,"points":250,"category":251},"43880962","BreezePDF",791,"productivity",{"id":253,"name":254,"points":255,"category":20},"43899028","RealtimeVoiceChat",524,{"id":257,"name":258,"points":259,"category":260},"43873074","Anukari",512,"creative",{"id":262,"name":263,"points":264,"category":251},"43891245","AI Native Resume",301,{"id":266,"name":267,"points":268,"category":269},"43896011","VectorVFS",279,"data",false,"v2",{"id":273,"name":5,"line":6,"ai":270,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":274,"top":18,"kw":275,"maker":11,"domain":10,"tier":19,"attempts":34,"strip":276,"url":9,"mix":277,"praise":84,"objection":107,"sub":21},43870998,0.33,[24,25,26,27,28],"5303000003550333551010305",[32,33,34,35],1793991119158]