Inference School 是一个基于问题的课程,指导学习者在 Apple Silicon 上构建一个小型语言模型推理引擎,包含 47 个练习,涵盖从向量点积到最终推理引擎的所有内容。

Stars

180

7 天增长

暂无数据

Fork 数

14

开放 Issue

0

开源协议

Apache-2.0

最近更新

2026-07-17

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它独特地结合了 CPU 和 Metal GPU 实现,并以性能测量为核心,要求学习者预测、测量并将每个算子集成到不断增长的引擎中,而不仅仅是通过测试。

适合谁使用

  • 学习 Metal 和 GPU 编程的 Apple Silicon 开发者
  • 希望理解推理内部机制的机器学习工程师
  • 性能优化和系统编程的学生
  • 在 macOS 上构建自定义推理解决方案的爱好者

典型使用场景

  • 从基本原理自学习 Transformer 推理
  • 动手实践 Metal GPU 内核设计与优化
  • 理解和分析 KV 缓存、量化和批处理技术
  • 构建用于实验的参考教育推理引擎

项目优势

  • 完整的 47 个渐进式课程,所有练习均可运行
  • 每个算子都有 Swift CPU 参考实现和 Metal GPU 实现进行对比
  • 配套教材(545 页 PDF 和 EPUB),包含图表和章节解答
  • 每个问题都集成了性能预测和测量

使用前须知

  • 需要 Apple Silicon Mac 和 macOS 15 或更新版本,限制了平台适用范围
  • 最终项目中不包含预训练模型或完整的 Metal 生成
  • 命令行检查继承终端权限,需要注意安全性

README 快速开始

Inference School

Inference School is a problem-based course in which every exercise contributes to one small language-model inference engine for Apple Silicon. The problems are not standalone interview puzzles. A dot product becomes GEMV, GEMV becomes Q/K/V projections, those projections become attention, and the same path eventually loads a model and generates tokens.

Each numerical operator has two required paths where a GPU mapping is part of the lesson:

  1. A readable Swift CPU implementation that acts as the correctness oracle.
  2. A Metal implementation whose memory traffic, dispatch shape, and numerical behavior you can explain and measure.

The finish line is not merely "the tests pass." For each problem, you predict performance, run an experiment, inspect the result, and integrate the operator into the growing engine.

How you use it

Inference School Studio is the primary learning environment. It is a native macOS app with a searchable lesson reader, editable Swift and Metal source files, out-of-process checks, persistent completion lists, diagrams, math rendering, and text scaling from 80% to 200%. The command line exposes the same lessons, learner files, judges, and benchmarks.

From the repository root, package and open the Studio:

scripts/package-studio.sh debug
open "dist/Inference School Studio.app"

The packaging script creates an ad hoc signed, sandboxed app for local use. It does not produce a Developer ID signature or a notarized distribution.

It opens at the reader-only orientation lesson 000. Read Start Here for setup, local-execution boundaries, and the intended learning loop. Problems 001 through 047 are runnable, including the final profiling and systems module.

The packaged Studio is signed with App Sandbox. The first runnable lesson asks you to choose a dedicated build folder through the macOS folder picker. Editable sources, compiler output, and generated learner executables stay under that folder. The Studio host has the client entitlement required by WebKit on supported macOS releases; its lesson, diagram, and editor assets are bundled, and built-in checks do not upload learner code. Command-line checks are separate: they run with the permissions of your terminal session.

Companion book

The complete course is available as a 545-page PDF and a reflowable EPUB with native diagra

项目描述

A hands-on Swift and Metal course for building LLM inference from first principles on Apple silicon, with 48 guided lessons, runnable exercises, a native macOS Studio, and a complete companion book.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

Blaizzy
精选
Blaizzy GitHub avatar

nativ

Nativ is a native macOS app that lets you run AI models locally on Apple silicon, offering chat, model management, performance analytics, and an OpenAI/Anthropic-compatible API server.

AI 与机器学习AI 视觉与语音
985
uzairansaruzi
精选
uzairansaruzi GitHub avatar

hermex

Hermex is a native SwiftUI iPhone app that lets you control a self-hosted Hermes AI agent directly from your phone, with no subscriptions, tracking, or third-party relay.

AI 与机器学习大语言模型
941
simonw
精选
simonw GitHub avatar

speech-analyzer-cli

A macOS command-line tool that uses Apple's on-device speech APIs to transcribe prerecorded audio into plain text, JSON, JSONL, SRT, or WebVTT.

开发者工具CLI 与终端
20