[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80567":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":13,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":13,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":15,"starSnapshotCount":15,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},80567,"gbc-transformer","maddiedreese\u002Fgbc-transformer","maddiedreese","TinyStories-260K running locally on a stock Game Boy Color.","",null,"C",58,1,55,0,3,0.9,"MIT License",false,"main",true,[],"2026-06-12 02:04:04","# gbc-transformer\n\n\u003Cimg width=\"378\" height=\"504\" alt=\"IMG_4019\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002Ff0fa45be-902f-496c-b78c-23a16ffbb83f\" \u002F>\n\n\nTinyStories-260K running locally on a stock Game Boy Color.\n\nThis is a proof-of-concept GBDK-2020 ROM that runs a quantized transformer\nlanguage model on the Game Boy Color CPU. Prompt entry happens on the handheld\nwith the D-pad\u002Fbuttons and an on-screen keyboard. The ROM tokenizes the prompt,\nruns transformer prefill, then autoregressively generates a short continuation.\n\nIt is intentionally tiny, slow, and imperfect. The current build proves the\nend-to-end path on hardware; it is not a polished text generator yet.\n\n## What Works\n\n- Desktop FP32 reference runner for `stories260K.bin`.\n- Desktop row-wise INT8\u002FQ8 packer and zero-float Q8 runner.\n- GBC ROM with the Q8 model embedded as MBC5 bank-switched cartridge data.\n- On-device BPE tokenization using the 512-token TinyStories tokenizer.\n- Integer\u002Ffixed-point transformer inference with RoPE, attention, RMSNorm,\n  SwiGLU-style MLP, and greedy argmax decoding.\n- Cartridge SRAM KV cache so base WRAM stays below 8 KB.\n- On-screen keyboard with explicit `ENTER`.\n- Runtime progress markers (`P` for prefill, `G` for generation).\n\n## Current Limitations\n\n- Extremely slow on real hardware. The C implementation works, but the hot\n  matmul loops need SM83 assembly to become demo-friendly.\n- Output quality is rough\u002Fgibberish. The GBC path uses heavy quantization and\n  fixed-point approximations.\n- Context is capped at 16 tokens.\n- Greedy decoding only; no top-k or temperature sampling yet.\n- Built for one model shape: TinyStories-260K (`dim=64`, `hidden_dim=172`,\n  `layers=5`, `heads=8`, `kv_heads=4`, `vocab=512`).\n\n## Hardware\n\n- Game Boy Color\n- EZ-FLASH Junior or another MBC5-compatible flashcart\n- microSD card mounted at `\u002FVolumes\u002Fbootfs` for `make sd-card`\n\nNo soldering or internal Game Boy modification is required.\n\n## Dependencies\n\n- Python 3\n- C compiler for desktop tools (`clang` or `gcc`)\n- GBDK-2020 4.5.0 or compatible\n- `curl` and `unzip` for fetch helpers\n\nBy default the Makefile looks for GBDK at:\n\n```sh\ntools\u002Fvendor\u002Fgbdk-4.5.0\n```\n\nYou can also point it elsewhere:\n\n```sh\nmake GBDK_HOME=\u002Fpath\u002Fto\u002Fgbdk gbc-rom\n```\n\n## Fetch Model Assets\n\nThe TinyStories checkpoint and tokenizer are downloaded from Andrej Karpathy's\n`karpathy\u002Ftinyllamas` Hugging Face repository:\n\n```sh\nmake fetch-assets\n```\n\nThis creates:\n\n- `stories260K.bin`\n- `tok512.bin`\n\nExpected sizes:\n\n- `stories260K.bin`: 1,056,540 bytes\n- `tok512.bin`: 6,227 bytes\n\n## Build\n\nDesktop references:\n\n```sh\nmake run-fp32\nmake run-q8\nmake run-gbc-sim\n```\n\nGame Boy ROM:\n\n```sh\nmake gbc-rom\n```\n\nOutput:\n\n```text\nbuild\u002FTINYSTORY.GB\n```\n\n## Prepare EZ-FLASH Junior SD Card\n\nFetch the official EZ-FLASH Junior stable kernel:\n\n```sh\nmake fetch-ezflash\n```\n\nThen copy the ROM and kernel to the SD card:\n\n```sh\nmake sd-card\n```\n\nThe SD root will contain:\n\n- `ezgb.dat`\n- `TINYSTORY.GB`\n- `README.txt`\n- `GBC-TINYSTORIES\u002F` reference folder\n\nIn the EZ-FLASH menu, run `TINYSTORY.GB` from the SD card root.\n\n## Credits\n\n- TinyStories-260K and tokenizer: Andrej Karpathy's\n  [`karpathy\u002Ftinyllamas`](https:\u002F\u002Fhuggingface.co\u002Fkarpathy\u002Ftinyllamas\u002Ftree\u002Fmain\u002Fstories260K)\n- GBDK-2020: https:\u002F\u002Fgithub.com\u002Fgbdk-2020\u002Fgbdk-2020\n- EZ-FLASH Junior kernel: https:\u002F\u002Fwww.ezflash.cn\u002Fdownload\u002F\n","gbc-transformer 是一个在原版 Game Boy Color 上运行 TinyStories-260K 语言模型的项目。该项目使用 GBDK-2020 开发，通过量化和整数\u002F定点运算实现了一个小型的变压器模型，支持基于 D-pad 和按钮的输入以及屏幕键盘。它在设备上进行 BPE 分词，并通过 RoPE、注意力机制、RMSNorm 和 SwiGLU 风格的 MLP 进行推理，同时利用 SRAM 作为 KV 缓存以保持低内存占用。尽管目前生成速度较慢且输出质量有限，但该项目展示了在硬件资源极其有限的情况下运行复杂机器学习模型的可能性。适合对复古计算平台或嵌入式系统上的 AI 应用感兴趣的开发者探索和研究。",2,"2026-06-11 04:01:15","CREATED_QUERY"]