# 来源与边界

教材原文：用户提供的 handbook_with_exercises(1).html。新增代码为本轮独立编写的教学实现；没有复制它声称来自 Qwen3-0.6B 的旧实验数值。

核对日期：2026-10-09。机制参考（不是本程序直接导入的代码）：

- GQA 论文：https://arxiv.org/abs/2305.13245
- Transformers 固定 Llama 实现：https://github.com/huggingface/transformers/blob/b1463f5b871aeb20d58384a98aad57905a690799/src/transformers/models/llama/modeling_llama.py
- vLLM 分页注意力：https://docs.vllm.ai/en/latest/design/paged_attention/
- FlashAttention 原论文：https://arxiv.org/abs/2205.14135
- FlashAttention 实现与接口：https://github.com/Dao-AILab/flash-attention
- LMCache 的非前缀混合实现：https://github.com/LMCache/LMCache/blob/dev/lmcache/v1/compute/blend/blender.py

在线 softmax 函数只验证数学合并，不模拟 GPU 内存层次。量化函数是自行实现的均匀 INT4，使用每组 FP32 缩放系数，与厂商 NVFP4 的 E2M1 码本、E4M3 局部尺度、全局尺度均不同。随机模型的 logits 差异只说明计算变化，不代表自然语言任务的准确率变化。
