任务:在自己的机器上跑一个模型Playbook: running a model on your own machine
显存、量化档、runtime、评估、监控五步;含体积算式、量化索引、失败模式与验收单。
Five steps — VRAM, quantization tier, runtime, evaluation, monitoring — with a size formula, the quantization index, failure modes and an acceptance list.
显存:先算再下VRAM: calculate before downloading
以下 KV 算式仅用于常规注意力缓存的简化预算,不适用于所有架构或缓存实现。GB 按十进制计,GiB = 字节 / 2^30。
权重体积 GB ≈ 参数量(B) × bpw / 8
KV 字节 ≈ 2 × 层数 × KV 头数 × 头维度 × 每请求缓存 tokens × 每元素字节数 × 并发请求数
总预算 ≈ 权重 + KV 缓存 + 运行器与系统开销 + 自定余量
- 7B 参数按纯 4-bit 算约为 3.5 GB;实际文件还含量化与其他数据,以文件字节数为准。
- 先定上下文长度,再定量化档;只按参数量算会低估。
- GQA/MQA 使用 KV 头数,不直接套查询头数。运行器开销与余量按配置记录,不预设通用百分比。
The KV formula below is a simplified budget for conventional attention caches, not every architecture or implementation. GB is decimal; GiB = bytes / 2^30.
Weight GB ≈ parameters in billions × bits per weight / 8
KV bytes ≈ 2 × layers × KV heads × head dimension × cached tokens per request
× bytes per element × concurrent requests
Total budget ≈ weights + KV cache + runtime/system overhead + chosen headroom
- Seven billion parameters at pure four-bit precision are about 3.5 GB; use actual file bytes for quantisation metadata and other contents.
- Choose context requirements before a tier; parameter count alone underestimates running memory.
- For GQA/MQA use KV heads, not query heads. Record overhead and headroom for the configuration rather than a universal percentage.
量化档:按索引选Quantization: use the index
本站 models 站快照(2026-10-30):129 个量化仓、1,262 个量化档、1,337 个 GGUF 文件。
- 按可用内存筛候选,同时预算缓存、并发与运行器。
- 核对基座版本、量化方法、来源与发布说明,不能只按发布者名字判断质量。
- 同档多文件时核对总体积、bpw、分片是否齐全与运行器兼容性。
- 先验证一个条件清楚的候选,再按任务决定是否比较其他档。
The 2026-10-30 snapshot contains 129 quantisation repositories, 1,262 variants and 1,337 GGUF files.
- Filter against available memory, including cache, concurrency and runtime.
- Check base version, quantisation method, provenance and release notes; publisher name alone does not establish quality.
- Check total size, bits per weight, complete shards and runtime compatibility.
- Validate one clearly specified candidate before deciding whether to compare others.
Runtime:按硬件选Runtime: match the hardware
| 硬件 | 候选路线 | 需要核对 |
|---|---|---|
| Apple 硅 | LM Studio(MLX)或 llama.cpp | 模型架构、格式与统一内存预算 |
| 单张 NVIDIA | LM Studio、llama.cpp 或 ExLlamaV3 | GPU/驱动支持;GGUF 与 EXL3 不是同一格式 |
| 多卡 / 并发 | vLLM 等服务运行器 | 并行配置、架构与量化格式支持 |
| CPU / 边缘 | llama.cpp 等本地运行器 | 内存、架构支持与任务响应要求 |
- 按图形界面、脚本或服务化需求选择路线;这不是性能排序。
- 注意工具许可证与权重许可证是两份文件。
| Hardware | Candidate paths | Check |
|---|---|---|
| Apple silicon | LM Studio with MLX, or llama.cpp | Architecture, format and unified-memory budget |
| One NVIDIA GPU | LM Studio, llama.cpp or ExLlamaV3 | GPU/driver support; GGUF and EXL3 are different formats |
| Multiple GPUs/concurrency | Serving runtimes such as vLLM | Parallel configuration, architecture and quantisation support |
| CPU/edge | Local runtimes such as llama.cpp | Memory, supported architectures and response requirements |
- Choose according to GUI, scripting or serving needs; this is not a performance ranking.
- Tool and model licences are separate.
评估:三类任务各 20 条Evaluate: 20 cases per task
下面以三类各 20 条为教学安排,实际样本按业务任务、边界情况与风险设计,不是通用验收规模。
- 准备 60 条真实任务:问答、摘要、代码各 20 条,带标准答案。
- 跑三档:Q4、Q5、Q8(或模型提供的相邻档),记录质量与速度。
- 看四个指标:正确率、幻觉率、首 token 延迟、tokens/s。
- 选档结论:写清「为什么这个档够用」,不要只写「感觉不错」。
失败模式:只测一个 prompt;真实任务一上就崩。
Twenty cases in each of three categories is an illustrative exercise, not a universal acceptance-set size. Choose real task and boundary coverage for the risk.
- Prepare an illustrative 60 tasks: Q&A, summaries and code, 20 each, with expected answers.
- Compare Q4/Q5/Q8, or available neighbouring tiers, recording quality and speed.
- Record correctness, hallucinations, first-token delay and tokens per second.
- Explain why the chosen tier satisfies the task rather than saying it “feels good”.
Failure mode: checking one prompt leaves real task failures undiscovered.
监控:上线后看什么Monitor after launch
- 显存峰值、tokens/s、首 token 延迟、错误率。
- 优先记录必要的长度、耗时与错误;哈希也可能关联原文,不能当作自动匿名化。明确日志访问权限与保留范围。
- 模型或量化档更新时,重跑评估集再切换。
- Peak memory, output throughput, first-token delay and error rates.
- Prefer necessary lengths, timings and errors in logs. Hashes can still link back to input; they are not automatic anonymisation. Define access and retention.
- Rerun the task set before changing the model or quantisation.
成本算式Cost formula
一次性:硬件 + 下载流量 + 调试时间
持续:电费 + 维护 + 评估复跑
对比云端:按同一期间分开计算输入/输出、缓存、工具与固定费用
不预置电价与报价。用 成本计算器 填写相同期间的假设;已有硬件、分摊与维护会改变结论,不能仅由调用量推断哪种更省。
Initial: hardware, transfer and setup time
Recurring: electricity, maintenance and reevaluation
Cloud comparison: input/output, caching, tools and fixed costs over the same period
No electricity rates or quotations are prefilled. Use the cost calculator with comparable periods. Existing hardware, allocation and maintenance can change the outcome; usage alone does not determine which is cheaper.
验收单Acceptance checklist
- [ ] 容量预算包含权重、KV 缓存、并发、开销与自定余量,单位一致
- [ ] 量化档与量化仓有版本记录
- [ ] runtime 许可证与模型许可证分别核对
- [ ] 约定的评估集完成,四指标与未覆盖情况有记录
- [ ] 选定档位写出理由
- [ ] 监控指标与告警阈值就绪
- [ ] 更新模型时的回滚方案就绪
- [ ] Consistent-unit capacity budget includes weights, KV cache, concurrency, overhead and chosen headroom.
- [ ] Quantisation and repository versions recorded.
- [ ] Runtime and model licences checked separately.
- [ ] Agreed task set completed, four metrics and uncovered cases recorded.
- [ ] Tier choice explained.
- [ ] Monitoring and alert thresholds defined.
- [ ] Rollback plan ready for updates.
常见失败模式Failure modes
- 只算权重:忘了 KV 缓存,长上下文直接 OOM。
- 混淆参数口径:总参与激活参数不同,不能直接代替内存或速度结论。
- 许可混淆:工具 MIT,权重却是非商用。
- 无评估集:换档后质量下降没人发现。
- 无监控:上线后显存峰值把机器拖死。
- Weights alone: context cache causes an OOM that the budget missed.
- Parameter confusion: total and active parameters do not directly establish memory or speed.
- Licence confusion: an MIT tool does not determine a model's commercial rights.
- No evaluation set: quality changes go unnoticed.
- No monitoring: peak memory failures are discovered only after deployment.
贯穿案例:先算内存,再尝试启动Worked example: budget memory before starting
以下数字是假设的容量练习,不对应某款模型,也不是性能测量。
设设备可用预算为 10 GiB,候选权重为 6 GiB。先预留 2 GiB 给上下文缓存、1 GiB 给运行时,其余 1 GiB 作为余量。合计 9 GiB 是初步预算,不是一定能启动的保证。
接下来核对文件来源、许可、运行器与架构支持。先用短输入检查能否加载、是否有不支持的算子,以及真实内存占用。再逐渐增加上下文;每一步记录错误和响应时间。
装不下时,先区分权重、缓存还是其他程序占用,再评估更小规格、不同量化或运行器支持的卸载。能启动但响应不满足任务要求,也应记录为未通过。
具体计算与单位见 硬件预算示例。
These are hypothetical capacity figures, not a named model or measured performance.
Assume a 10 GiB available budget and 6 GiB of weights. Reserve 2 GiB for context cache and 1 GiB for runtime, leaving 1 GiB headroom. The 9 GiB estimate is not a startup guarantee.
Check file provenance, licensing, runtime and architecture support. Start with short input and inspect loading, unsupported operations and actual memory. Increase context gradually, recording errors and response times.
If it does not fit, identify weights, cache and other applications separately. Assess smaller variants, quantizations or supported offload. Startup with unacceptable response time also fails the task.
See the hardware-budget example for units and calculation.
出处Sources
| 来源Source | 链接URL |
|---|---|
| models.specul.com · 量化索引(129 量化仓 / 1,262 量化档 / 1,337 GGUF,2026-10-30 快照)This site: quantisation index (129 repositories, 1,262 variants and 1,337 GGUF files; 2026-10-30 snapshot) | https://models.specul.com/https://models.specul.com/ |
| llama.cpp · 官方仓库(GGUF 与 llama-server;2026-10 快照)llama.cpp: repository (GGUF and llama-server; October 2026 snapshot) | https://github.com/ggml-org/llama.cpphttps://github.com/ggml-org/llama.cpp |
| vLLM · 官方文档(PagedAttention、OpenAI 兼容;2026-10 快照)vLLM: documentation (PagedAttention and OpenAI-compatible endpoint; October 2026 snapshot) | https://docs.vllm.aihttps://docs.vllm.ai/ |
| LM Studio · 官方站(MLX + llama.cpp 双运行时;2026-10 快照)LM Studio: official site (MLX and llama.cpp runtimes; October 2026 snapshot) | https://lmstudio.aihttps://lmstudio.ai/ |
| PyPI · exllamav3 1.6.5(2026-10-25;2026-11-03 复核)PyPI: exllamav3 1.6.5 (2026-10-25; checked 2026-11-03) | https://pypi.org/project/exllamav3/https://pypi.org/project/exllamav3/ |
| Hugging Face Transformers · 缓存张量形状(简化 KV 算式的推导依据;2026-11-04)Hugging Face Transformers: cache tensor shapes (basis for the simplified KV formula; 2026-11-04) | https://huggingface.co/docs/transformers/cache_explanationhttps://huggingface.co/docs/transformers/cache_explanation |
资料快照日期:2026-11-03;单项复核范围与日期见对应正文或来源记录。产品功能与条款可能变化,使用前请核对原始来源。Source snapshot: 2026-11-03; item-specific rechecks and their scope are recorded in the text or source notes. Features and terms may change; check the original sources before use.
这页出现在主题:This page appears in: 用 AI 做游戏Make games with AI · 做机器人Build a robot