BootGPT fits inference code in a 512-byte boot sector, with a separate 11.5 KB int8 character model. It generates synthetic boot logs, not general-purpose answers or real diagnostics. kerlenton/bootgpt #TinyInferenceSystems #QuantizedRuntime t.co
1 like · 77 views
项目叫 bootgpt,一个住在引导扇区里的语言模型:kerlenton/bootgpt
1 like · 44 views
HN 上有人把语言模型塞进了引导扇区。别人比谁的模型大,这位比谁的模型住得小。
项目叫 bootgpt,一个住在引导扇区里的语言模型:kerlenton/bootgpt
A language model that lives in a boot sector
A working language model that fits inside a 512-byte boot sector and boots straight into QEMU.
一个塞进启动扇区的语言模型,我自己跑了一遍
原始链接:kerlenton/bootgpt
电脑开机时,BIOS 先读硬盘的第一个扇区,也就是 MBR(主引导记录,开机时第一段被执行的代码)。它只有 512 字节,去掉结尾两字节的标记,能放代码的只有 510 字节。过去有人在这里塞进过国际象棋和 C 编译器,bootgpt 往里面放的是一个神经网络。开机后它不加载操作系统,屏幕上一行行打印 Linux 启动日志,日志里的硬件都不存在,是模型逐个字符编出来的。
模型很小。作者先用脚本生成 3 MB 假的 dmesg(Linux 内核启动时输出的日志),再训练一个字符级网络,看前 8 个字符,经过一个隐藏层,预测下一个字符。训练完参数全部量化成 int8。量化:把浮点数换成小整数来存和算。这样前向计算只要乘法和一次除法,汇编写得下。MBR 里只放代码,权重和词表放在后面的扇区。
仓库里没有现成权重,要自己训练。我在一台 Linux 机器上试了一下。作者用的是 macOS,安装命令是 brew,我换成 apt 装 nasm 和 QEMU,Python 只需要 numpy。
sudo apt install nasm qemu-system-x86
python3 -m venv .venv && .venv/bin/pip install numpy
./build.sh
`build.sh` 用的是 zsh 和 BSD 版的 `stat -f%z`,在 Linux 上会报错,我把它改成 bash 和 `stat -c%s`,别的没动。这个脚本依次做几件事:生成语料,训练并量化,用 nasm 汇编,最后把启动扇区和权重拼成一个磁盘镜像。
整个过程 58 秒,CPU 就够,不需要显卡。训练跑了 4 万步,loss 从 0.96 降到 0.64。生成的 `boot.bin` 正好 512 字节,权重 11776 字节,占 23 个扇区,磁盘镜像一共 12288 字节。
corpus.txt: 3079543 bytes, 44800 lines
step 40000 loss 0.6412
weights.bin: 11776 bytes (23 sectors), params.inc written
disk.img ready: 12288 bytes (boot sector + int8 weights)
然后用 QEMU 启动这个镜像,模拟一台老式 PC。
qemu-system-i386 -drive format=raw,file=disk.img,if=ide -boot c
屏幕上出现的是这样的内容,格式像模像样,细节里夹着乱码:
[ 0.578063] ata1: SATA link up 6.0 Gbps SStatus 103
[ 3.856633] smpboot: CPU7 is now online
[ 2.597257] ACPI: Power Button [PWR ]
[ 4.223293] LrGilet riterid root=/dev/sda2 quiet splash
它会一直写下去,按任意键重启,重启后换一套日志。
我最想验证的是作者的一个说法:训练脚本里有一个模拟器,用和汇编完全相同的整数运算跑推理,输出能和 QEMU 逐字符对上。正常的镜像用 BIOS 时钟做随机种子,每次开机都不同,没法比。源码里留了一个调试开关,我用 `nasm -DSEEDFIX=0x1234` 重新汇编,种子和模拟器一致,再启动。QEMU 打印出的开头几行,和模拟器的输出一个字符都不差。作者就是靠这种对照找到 bug 的:除法指令 idiv 会把余数写进 edx 寄存器,覆盖了存在那里的偏置表指针,只有第一个神经元算对了。
部署我没有试。作者说 `disk.img` 是标准启动镜像,用 dd 写进 U 盘,就能在支持 BIOS 启动的电脑上开机,程序只读自己的扇区。
1 like · 95 views
Show HN: A language model that lives in a boot sector kerlenton/bootgpt (news.ycombinator.com)
“A neural network that boots your pc. The machine wakes up and dreams a Linux boot log: timestamps, PCI bars, ACPI events for hardware that never existed” kerlenton/bootgpt
6 likes · 1 repost
Show HN: A language model that lives in a boot sector | Discussion
Show HN: A language model that lives in a boot sector
1 point · 1 comment
@sakurayukiai Saw this while researching prior art for my own take on the genre: the whole engine now fits inside the 510-byte MBR itself, and the model is trained for one thing, dreaming this machine's own boot log
kerlenton/bootgpt
2 likes · 8 views
Mentions
BootGPT fits inference code in a 512-byte boot sector, with a separate 11.5 KB int8 character model. It generates synthetic boot logs, not general-purpose answers or real diagnostics. kerlenton/bootgpt #TinyInferenceSystems #QuantizedRuntime t.co
项目叫 bootgpt,一个住在引导扇区里的语言模型:kerlenton/bootgpt
HN 上有人把语言模型塞进了引导扇区。别人比谁的模型大,这位比谁的模型住得小。 项目叫 bootgpt,一个住在引导扇区里的语言模型:kerlenton/bootgpt
A language model that lives in a boot sector A working language model that fits inside a 512-byte boot sector and boots straight into QEMU.
一个塞进启动扇区的语言模型,我自己跑了一遍 原始链接:kerlenton/bootgpt 电脑开机时,BIOS 先读硬盘的第一个扇区,也就是 MBR(主引导记录,开机时第一段被执行的代码)。它只有 512 字节,去掉结尾两字节的标记,能放代码的只有 510 字节。过去有人在这里塞进过国际象棋和 C 编译器,bootgpt 往里面放的是一个神经网络。开机后它不加载操作系统,屏幕上一行行打印 Linux 启动日志,日志里的硬件都不存在,是模型逐个字符编出来的。 模型很小。作者先用脚本生成 3 MB 假的 dmesg(Linux 内核启动时输出的日志),再训练一个字符级网络,看前 8 个字符,经过一个隐藏层,预测下一个字符。训练完参数全部量化成 int8。量化:把浮点数换成小整数来存和算。这样前向计算只要乘法和一次除法,汇编写得下。MBR 里只放代码,权重和词表放在后面的扇区。 仓库里没有现成权重,要自己训练。我在一台 Linux 机器上试了一下。作者用的是 macOS,安装命令是 brew,我换成 apt 装 nasm 和 QEMU,Python 只需要 numpy。 sudo apt install nasm qemu-system-x86 python3 -m venv .venv && .venv/bin/pip install numpy ./build.sh `build.sh` 用的是 zsh 和 BSD 版的 `stat -f%z`,在 Linux 上会报错,我把它改成 bash 和 `stat -c%s`,别的没动。这个脚本依次做几件事:生成语料,训练并量化,用 nasm 汇编,最后把启动扇区和权重拼成一个磁盘镜像。 整个过程 58 秒,CPU 就够,不需要显卡。训练跑了 4 万步,loss 从 0.96 降到 0.64。生成的 `boot.bin` 正好 512 字节,权重 11776 字节,占 23 个扇区,磁盘镜像一共 12288 字节。 corpus.txt: 3079543 bytes, 44800 lines step 40000 loss 0.6412 weights.bin: 11776 bytes (23 sectors), params.inc written disk.img ready: 12288 bytes (boot sector + int8 weights) 然后用 QEMU 启动这个镜像,模拟一台老式 PC。 qemu-system-i386 -drive format=raw,file=disk.img,if=ide -boot c 屏幕上出现的是这样的内容,格式像模像样,细节里夹着乱码: [ 0.578063] ata1: SATA link up 6.0 Gbps SStatus 103 [ 3.856633] smpboot: CPU7 is now online [ 2.597257] ACPI: Power Button [PWR ] [ 4.223293] LrGilet riterid root=/dev/sda2 quiet splash 它会一直写下去,按任意键重启,重启后换一套日志。 我最想验证的是作者的一个说法:训练脚本里有一个模拟器,用和汇编完全相同的整数运算跑推理,输出能和 QEMU 逐字符对上。正常的镜像用 BIOS 时钟做随机种子,每次开机都不同,没法比。源码里留了一个调试开关,我用 `nasm -DSEEDFIX=0x1234` 重新汇编,种子和模拟器一致,再启动。QEMU 打印出的开头几行,和模拟器的输出一个字符都不差。作者就是靠这种对照找到 bug 的:除法指令 idiv 会把余数写进 edx 寄存器,覆盖了存在那里的偏置表指针,只有第一个神经元算对了。 部署我没有试。作者说 `disk.img` 是标准启动镜像,用 dd 写进 U 盘,就能在支持 BIOS 启动的电脑上开机,程序只读自己的扇区。
Show HN: A language model that lives in a boot sector kerlenton/bootgpt (news.ycombinator.com)
“A neural network that boots your pc. The machine wakes up and dreams a Linux boot log: timestamps, PCI bars, ACPI events for hardware that never existed” kerlenton/bootgpt
Show HN: A language model that lives in a boot sector | Discussion
Show HN: A language model that lives in a boot sector
@sakurayukiai Saw this while researching prior art for my own take on the genre: the whole engine now fits inside the 510-byte MBR itself, and the model is trained for one thing, dreaming this machine's own boot log kerlenton/bootgpt