仓库文件导航
.aamt
面向本地 AI 的 GPU 原生文件格式。
GGUF 把模型变成一个文件,让你可以下载并在自己的 CPU 上运行。.aamt 则为在你自己的 GPU 上运行的东西而构建:为 compute shader 按位打包的权重、一个空间记忆索引,以及用内容寻址的层来承载模型除权重之外所需的一切,全部装进一个不可变、内存映射的文件。
开放规范,源码可见:个人、研究用途和小型团队免费;商业使用需授权(LICENSE.md、COMMERCIAL.md)。
试一试:一条命令
# Install or update globally (or run zero-install with npx @asamanthinks/aamt@latest):
npm install -g @asamanthinks/aamt@latest
npx @asamanthinks/aamt # interactive start screen (or chat with InnerSight, 0.72 GB)
npx @asamanthinks/aamt tui # 4-Pane Sovereign Terminal UI Cockpit (.weslyn MoE · Swarm · AgentStudio · Thin Viewer)
npx @asamanthinks/aamt update # check npm for CLI updates & verify/refresh cached .aamt models
# 12 Language/Expert Models + 4 Visual Diffusion Models (Glimpse/Glimmer & Vista):
npx @asamanthinks/aamt run gaian # BeyondSight GaIaN, 8B ternary (3.23 GB)
npx @asamanthinks/aamt run gaian-code # BeyondSight GaIaN CodeExpert, 8B ternary (3.07 GB)
npx @asamanthinks/aamt run gaian-math # BeyondSight GaIaN MathExpert, 8B ternary (3.07 GB)
npx @asamanthinks/aamt run gaian-unity # BeyondSight GaIaN UnityCSharpExpert, 8B ternary (3.07 GB)
npx @asamanthinks/aamt run gaian-draft # BeyondSight GaIaN Draft, 0.6B int4 speculative reflex (0.47 GB)
npx @asamanthinks/aamt run innersight2-4b # InnerSight 2 4B, ternary hybrid-attention (1.75 GB)
npx @asamanthinks/aamt run nomad # BeyondSight Nomad, 27B 1-bit (7.21 GB)
npx @asamanthinks/aamt run ezmarelda # BeyondSight Ezmarelda, 27B 1-bit hybrid (7.21 GB)
npx @asamanthinks/aamt run flow2 # BeyondSight Flow 2, 27B ternary (10.50 GB)
npx @asamanthinks/aamt run flow3 # Flow 3, 27B ternary, 64 layers, 262k context (10.50 GB)
npx @asamanthinks/aamt pull glimpse # BeyondSight Glimpse DiT (alias: glimmer), 1-bit diffusion (1.70 GB)
npx @asamanthinks/aamt pull vista # BeyondSight Vista DiT, ternary diffusion (2.16 GB)
npx @asamanthinks/aamt pull encoder-4b # BeyondSight Encoder 4B, int4 text encoder (1.95 GB)
npx @asamanthinks/aamt pull vae-flux2 # BeyondSight VAE Flux2, f32 latent decoder (0.34 GB)
npx @asamanthinks/aamt bench gaian # measure it on your machine; prints a shareable card
aamt 是运行时:这个引擎从 .aamt 文件运行完整模型,并按其自有许可证免费使用。模型只需下载一次,会对照一份 Ed25519 签名的目录进行校验,然后在本地运行;其余任何东西都不会离开本机。在 M1 Max 上,aamt bench gaian 在 128 token 回复上测得 41.2 tok/s,而 4,096 token 提示词的首个 token 在提示词被读取一次后从 32.7 s 降到 178 ms(184×)。跑一下,然后贴出你的卡片。
看它跑起来,无需安装任何东西
三个页面,全部都在你自己的浏览器标签页里完成工作,而不是给你看一段它的视频。
| Documentation | The CLI guides and the MCP server, rendered from docs/ in this repository. |
|---|---|
| The format, live | A model writes a town, four people walk it and think, and every thought becomes a coordinate, is packed into a real .aamt and is recalled by geometry — with a console streaming the math as it happens. |
| Sample apps | Eight ordinary applications whose memory is a .aamt file on the machine they run on: a bakery assistant, six fleet and robotics sites (warehouse, ground, air, sea, grid, datacentre), and a model registry that admits or refuses artifacts by identity and licence. |
Show HN:Aamt——一种在本地运行并能自我修复的单文件 AI 格式
在应用页面上,应用程序在左侧,引擎自身的日志在右侧,因为它们是同一个程序。没有任何东西调用服务器。场景和站点是模拟的;投影、路由、打包和哈希是真实的,由 libaamt.wasm 在标签页中计算——与本 CLI 相同的 C++ 核心——页面会说明哪些是哪些。
同一个场景可以用三种方式驱动,这是大多数人没有预料到的部分:
- Replay 不需要 GPU,也不需要下载。只记录模型的话;你的浏览器会重新计算每一次投影、路由、打包和哈希。仓库重放落在 fnv1a-64 5ca10f1e201a0155 上,与其在线 GPU 运行产生的字节完全一致。
- 你的 GPU 在 WebGPU 上将 InnerSight 加载到标签页中,并在那里作答。
- 你的 CLI 就是这个包。运行 npx @asamanthinks/aamt serve innersight,页面将通过 127.0.0.1 上的 OpenAI API 使用它:终端提供文字,标签页仍然负责几何计算。这个方式需要页面在你自己的机器上通过 http 提供——浏览器不会让 https 页面访问 127.0.0.1。
自己检查这个格式
git clone https://github.com/wwhitehead/aamt && cd aamt && pnpm install
pnpm gpu:check
adapter: apple · metal-3 · Metal driver on macOS Version 26.5.2 (Build 25F84)
matrix: 8192 × 8192 (67.1M weights), seeded, 100 timed products
kind file bits/weight rel. error time/product weights/s weight GB/s
int4 41.94 MB 4.50 9.11e-8 262.1 µs 256 G 144.0
ternary 25.17 MB 2.50 1.13e-7 178.7 µs 376 G 117.4
1bit 16.78 MB 1.50 1.38e-7 222.7 µs 301 G 56.5
GPU == CPU (relative error ≤ 0.0001)
那次运行把一个矩阵写入一个真实的 .aamt 文件,读回来,并通过 WebGPU 在 GPU 上对其做乘法,每种权重类型各一次。然后它将每个输出与 CPU 参考结果进行核对。那是在 Apple M1 Max(Node 22、Dawn)上运行 AAMT_M=8192 AAMT_K=8192 AAMT_ITERS=100 pnpm gpu:check 的结果。GPU 耗时每次运行会有 10–20% 的波动,不同会话之间最多可达 25%。CLAIMS.md 给出了中位数、范围、每个数字的测量方式,以及没有声称的内容。
为什么需要一种新格式
模型文件过去只是张量的容器。本地 AI 现在需要在同一个地方容纳更多东西:权重、模型读写的内存、它所行动的世界,以及它运行的代码,每一个都有可验证的身份。
| safetensors | GGUF | .aamt | |
|---|---|---|---|
| 权重 | 原始 dtype | ggml 块量化(ggml 最初是一个 CPU 库) | 着色器一次读取的 u32 字:8 个 int4、16 个 ternary 或 32 个 1-bit 权重 |
| 围绕 | PyTorch | ggml / llama.cpp | WebGPU 计算:Node 中的 Dawn,或浏览器;Dawn 面向 Metal、Vulkan 和 D3D12 |
| 权重之外 | 字符串元数据 | 键值元数据 | 5 个类型化层:模型、世界、心智、经验、代码 |
| 身份 | 无 | 无 | 每条记录、每层和每个文件 SHA-384,按层分隔 |
| 内存索引 | 无 | 无 | 4-D 坐标空间上的十六叉树:1M 记录时每次路由约 230–370 ns(跨会话中位数) |
| 重放 | 无 | 无 | 每个决策 40 字节日志,对照文件哈希逐位精确重放 |
| 自我修复 | 无 | 无 | 每条记录 mirror + RS(15,13) + CRC-32:修复、从镜像恢复或拒绝;400 次重度损坏试验中 0 次错误 |
| 对齐 | 8 B | 32 B(可配置) | GPU 候选 arena 使用 16 KiB 页(Apple Silicon 零拷贝) |
GGUF 在其构建目的上非常出色,而 .aamt 目前还读不了它的任何文件(导入器在路线图上)。区别在于起点。.aamt 的权重是为 GPU 内核的内层循环布局的(js/packages/webgpu/src/shaders/aamt_gemv_mr.wgsl),文件中为本地智能体积累的状态留有空间,而不仅仅是它启动时的权重。
烘焙一个真实模型
pnpm bake ~/.cache/huggingface/hub/models--Qwen--Qwen3-0.6B/snapshots/*/model.safetensors qwen3-0.6b.aamt
baked 311 tensors (198 int4, 113 f32) in 10.6 s
1503.3 MB -> 470.0 MB (31.3% of the input)
行数为 32 的倍数的矩阵会被量化。Norm 权重、偏置和奇数形状保持 f32。然后在 GPU 上乘以其某个真实张量,按偏移从文件中读取(footer → manifest → tensor;不加载其他任何内容):
AAMT_FILE=qwen3-0.6b.aamt AAMT_TENSOR=lm_head.weight pnpm gpu:check
tensor: lm_head.weight — 151936 × 1024, read by offset from qwen3-0.6b.aamt
int4 97.24 MB 4.50 1.08e-7 643.3 µs 242 G 136.0
GPU == CPU (relative error ≤ 0.0001)
用你已信任的工具来检查它
Python 包可在 Hugging Face transformers 中打开 .aamt 模型,每个权重都从 .aamt 文件读取,因此你可以用它生成文本,并衡量烘焙带来的代价:
pip install -e "python[quality]"
python python/examples/generate.py qwen3-0.6b.aamt Qwen/Qwen3-0.6B "Why does local AI protect privacy?"
python python/examples/quality.py qwen3-0.6b.aamt Qwen/Qwen3-0.6B
perplexity original 5.089 .aamt 6.051 (+18.92%)
top-1 agreement 80.01% of next-token predictions
mean KL 0.2518 nats per token (original ‖ .aamt)
greedy 0/8 outputs identical over 64 tokens; first difference after 1.1 tokens on average
这就是当前 baker 的诚实代价。它使用朴素的 round-to-nearest int4,没有校准,而 0.6B 模型对此很敏感:烘焙后的模型仍能合理地回答,但可测量地变差了。同一套测试框架在同一权重的全 f32 .aamt 上报告 0.0% 变化和 100% 一致率,所以损失来自量化器,而不是文件或加载器。更好的量化器是路线图上的第一项。
ternary 和 1bit 适用于为这些类型训练或蒸馏的模型。将全精度模型直接烘焙到 1-bit 可以运行,但会破坏模型。
内存基底
./native/build.sh test
python3 native/examples/gen_random_tsv.py 1000000 > r1m.tsv
native/build/aamt pack r1m.tsv r1m.aamt
native/build/aamt bench r1m.aamt 1000000
native/build/aamt query r1m.aamt 0.72 0.31 0.88 0.15
packed 1000000 records -> r1m.aamt (318.9 ms)
open (mmap + validate): 0.052 ms
1000000 queries: 354 ns/query (2.83 Mq/s) [checksum 23230724]
route: odu-word=5.6.13.1 depth=4 bucket=20
每个节点同时在四个维度上分割其盒子,因此它恰好有 2⁴ = 16 个子节点。两层给出 256 个单元。查询的路由就是它的地址:上面的路径 5.6.13.1 就是该单元,自上而下读取。节点是单个 64 字节缓存行(占用位掩码 + popcount 子槽位,由 static_assert 验证)。文件以 mmap 打开且从不解析。同一个 C ABI(native/include/aamt/aamt.h)服务于 CLI、Python(ctypes)、WebAssembly 和 C#(P/Invoke)。
几何结构及其测量结果在工作论文中:WP-23(基底)、WP-24(围绕它的架构)、WP-25(集成与接线状态)。每篇论文都有一个更正记录,列出早期草稿声称的内容以及测量改变了什么。
本仓库包含什么
| Path | What | Tests |
|---|---|---|
| SPEC.md | 字节布局:tensor、模型(AMDL)、容器 v1.x、substrate v0,以及如何区分它们 | — |
| docs/ | CLI 和 MCP 指南,由 GitHub Pages 直接从该目录发布 | — |
| native/ | C++17 substrate 核心、C ABI、CLI、Python 绑定、WebAssembly 构建、Metal 零拷贝基准测试、CRDT 绑定(JS 在浏览器中运行) | round-trip、journal replay、GF(16) Reed–Solomon、自修复 |
| js/packages/tera | 坐标数学:16 个 Meji 卦限、256 个 Odu 单元、乘积 Fisher–Rao 度量、确定性超越函数 | ALU 属性、400 用例一致性夹具 |
| js/packages/container | 统一容器:五层、384 位 id、流式写入器、零拷贝读取器、Odu 索引、自适应树 | 118 项,包括位翻转模糊测试 |
| js/packages/model | Tensor 和模型格式、流式 safetensors 烘焙器、f16 缩放打包 | 从真实 safetensors 进行 bake 往返测试 |
| js/packages/webgpu | 反量化和多行 GEMV 内核,以及 GPU 等于 CPU 的校验 | 13 种形状 × 种类,在任意有 GPU 的机器上 |
| python/ | 一个 numpy 读取器、一个 Hugging Face transformers 加载器、一个文本生成演示,以及质量检查 | 9 项,针对 TypeScript 写入器生成的文件 |
pnpm test # 205 tests (the GPU suite skips itself where there is no adapter)
pnpm typecheck
pnpm native # build + test the C++ core
python3 -m unittest discover -s python/tests
不在本仓库中:完整的推理引擎(前向传播、KV cache、采样、调优)以及 BeyondSight 模型权重。引擎以编译形式随 npx @asamanthinks/aamt 发布;模型在 Hugging Face 上,遵循 BeyondSight Model License。如需商业许可或试点:[email protected]。
Roadmap
- 更好的 int4 量化器。使用完整的 [−8, 7] 编码范围,并加入基于校准的舍入,以削减在 Qwen3-0.6B 上测得的 +18.9% 困惑度代价。大型嵌入保持更高精度。quality.py 是衡量标准。
- GGUF 和 safetensors 导入器,在类型匹配时保留源量化。
- 磁盘上的 f16 缩放。GPU 已将缩放读取为 f16 对;以这种方式存储还能将磁盘上的缩放字节减半。
- 默认嵌入式模型。将 AMDL 模型打包进容器按页对齐的模型层,使模型、其内存和其身份作为一个文件一同发布。
- Windows 原生构建。C++ 核心在 CI 中的 macOS 和 Linux 上可构建并通过测试;Windows 需要从 POSIX mmap 移植。
- 格式库的 npm 和 PyPI 包。目前,克隆并 pnpm install;运行时已是 npx @asamanthinks/aamt。
欢迎提交 issue 和 pull request;贡献者需要签署 CONTRIBUTING.md 中的 CLA。
License
- 代码:AAMT Community License 1.0。个人使用、非商业研究、60 天评估,以及营收低于 100 万美元、融资低于 500 万美元且人数少于 25 人的组织(免费注册)可免费使用。其他一切用途,包括任何产品、服务或竞争性运行时,均需商业许可。
- 规范:CC BY-ND 4.0,不含专利许可。
- 专利:待定;见 PATENTS.md。
- 论文、书籍和商标:见 COPYRIGHT.md。工作论文是各自许可下的独立作品(WP-23、WP-24 和 WP-25 为 CC BY 4.0——是对文本的许可,而非对方法的许可)。
这是 source-available 软件,并非 OSI 定义的开源软件。
Built by Weslyn Cory Whitehead Jr. · ORCID 0009-0005-7707-3210 · asamanthinks.com · [email protected]