Record bounded Qwen3.5-2B pilot and stratified diagnostics

This commit is contained in:
2026-11-09 04:07:29 +08:00
parent 6121016a26
commit 727b05eb3f
92 changed files with 776086 additions and 27 deletions
+124
View File
@@ -0,0 +1,124 @@
# Qwen3.5-2B 有界试验结果
本轮已完成约定时间预算内的试验。整 tensor 精确比较 2,000 对;子块在内部截止时
完成 14,778 / 20,000 对(73.89%),其余 5,222 对未计算。不能把本轮写成全量搜索。
结论:在本次候选、坐标对齐及误差阈值范围内,没有获得显著的直接权重共享收益。
这不等于证明该模型不能通过其他方法压缩,也不代表 MoE 模型具有同样结果。
## 已确认的试验范围
- 模型:官方 `Qwen/Qwen3.5-2B`,revision `15852e8c16360a2fea060d615a32b45270f8a8fc`。
- 原始 safetensors 文件为 4,548,221,488 字节,已核对官方 LFS SHA256。
- 共 632 个存储 tensor;权重数据本身为 4,548,144,832 字节。
- 实际存储参数 2,274,069,824 个,包含官方 checkpoint 中的视觉部分。
- 维数分布:319 个一维、294 个二维、18 个三维、1 个五维。
- 三维权重是 `[6144, 1, 4]` 的卷积核,包含长度为 1 的轴;不能把它解释为一般三维体积。
- 五维视觉权重纳入完整清单和全模型字节分母,本轮不扩展五维子块搜索。
- 不执行前向计算、能力评测、训练或蒸馏。
## 整 tensor 的结果
已完成 2,000 对同角色、同形状候选的精确比较。它们是经过近邻筛选的候选,
不是所有可能 tensor 对的穷举。
| 最大直接替换相对误差 | 非单成员共享组 | 最大组大小 | 净节省字节 | 占模型权重 |
|---|---:|---:|---:|---:|
| 1% | 0 | 1 | 0 | 0% |
| 2% | 0 | 1 | 0 | 0% |
| 5% | 1 | 2 | 0 | 0% |
| 10% | 11 | 6 | 32,704 | 0.000719% |
| 20% | 16 | 15 | 119,424 | 0.002626% |
20% 阈值下找到的共享组均为一维权重。组数增加不代表显著的字节收益。
这里的百分比是权重误差,绝不是任务能力损失百分比。
净节省按本轮声明的理论布局计算:保留组代表,每个分析对象 16 字节映射,
每个共享组 64 字节描述;若大于原存储,则保持原表示。
这部分结果不支持在本次搜索范围内通过直接共享整 tensor 显著压缩该 checkpoint。
它不排除其他未比较组合、子块共享、重参数化或带残差的压缩方法。
## 子块结果
共筛选 13,328 个抽样子块。20% 直接替换误差阈值下:
这里的 tensor 指完整命名权重数组,block 指其局部子张量,不是 Transformer block。
三维原始权重为 6144×1×4,本轮切片实际是 1×1×4(4 个数),局部块是
4×1×4(16 个数);小块的高余弦不能推广为整份三维权重相似。
| 表示 | 非单成员共享组 | 最大组 | 映射开销前节省 | 当前布局净节省 |
|---|---:|---:|---:|---:|
| 64×64 二维块 | 3 | 3 | 40,960 字节 | 0 |
| 128×128 二维块 | 1 | 2 | 32,768 字节 | 0 |
| 三维 axis-0 切片 | 45 | 12 | 872 字节 | 0 |
| 三维局部块 | 2 | 2 | 64 字节 | 0 |
二维共享候选均来自 `model.visual.pos_embed.weight`,未在已复核候选中形成大规模
投影矩阵共享。不同块尺度是替代方案,不能相加。
净收益为零与声明的映射成本有关,不应解读为完全没有相似子块。更稀疏或更紧凑的
索引格式可能降低开销,但本轮找到的二维毛节省也仅为几十 KB,尚不足以支持大幅
减容。三维切片组数量较多,但整组三维权重合计只占模型字节的约 0.01945%。
模型字节占比:一维 0.01972%、二维 99.89167%、三维 0.01945%、五维 0.06917%。
因此,应按字节贡献评估价值,不能按 tensor 数量或共享组数量推断收益。
全部分组是满足代表半径约束的可行方案,不保证达到最少组数或最优压缩率。
## 运行经验
1. 实际服务器内存约 1.7 GiB,新增的 60 GB 是磁盘扩容,不是内存。
使用分块 BF16 解码和 mmap 页面释放完成了完整权重扫描与整 tensor 比较。
2. 只看进程 RSS 不足以解释运行成本。`vmstat` 快照观察到 75%~85% 的 I/O 等待,
同时存在交换活动;这些是共享主机的快照,不能全部归因于本进程。
3. 与权重读取并行的绘图合成测试触发过 300 秒超时;观察到测试处于磁盘等待。
后续验证应在权重读取结束后串行执行,避免把资源争用误判为数值算法失败。
4. Matplotlib 图例改为固定位置,避免自动定位引入额外布局开销。
5. 公平地选择各角色的候选,与高效地安排读取顺序,是两个不同问题。
下一轮应评估“先固定公平候选集合,再按文件/源 tensor 分批执行”的效果,
比较是否得到相同指标及更低 I/O 开销;本轮不在中途改变候选集合。
6. 从已保存元数据计算,13,328 个抽样子块的原始数据合计 256,387,072 字节
(约 244.5 MiB),对应指纹约 100.1 MiB。这是下一轮原始子块缓存的容量估计,
不是本轮已经实现的缓存或实测加速。应先用小样本验证数值一致性、峰值内存和
I/O 改善,再决定是否作为默认方案;不能仅凭容量估计保证运行效率。
参数分析及分组汇总耗时 6,661.13 秒(约 111.0 分钟),分析进程峰值 RSS 约
201.3 MiB;这不包含系统文件缓存和同机服务内存。内部比较截止后保存覆盖率与
分组,整个参数分析未触及 7,200 秒进程硬上限。块比较阶段将本进程 IO 优先级
调整为 best-effort 7,未改变服务器全局设置。
最终修图版 6 项串行合成测试通过(约 77.2 秒),六类图表的 PNG/PDF/SVG 已生成,
并对全部六类 PNG 做视觉检查;程序还核验了分组成员与代表之间的精确误差边。
## 三张诊断图的修订与解读
- 热力图只展示 `linear_attn.in_proj_a.weight`(16×2048),不是整个层。18 个相关层
的 153 种配对中核验了 74 对;已测非对角余弦约 0.011~0.298。
对角线 1 是身份比较,不是跨层发现。未测格子改用斜线,避免与接近零的底色混淆。
- 原混合层距曲线受维数组成影响:层距 1 含 183 对一维、19 对二维;层距 8
含 52 对一维、75 对二维。一维余弦中位数约从 0.941 变为 0.883,
不能将混合曲线的陡降全部归因于层距。修订版按维数/块尺度分开,模块和筛选偏差仍存在。
- 随机对照分为保留分布的元素打乱、匹配范数的零均值高斯向量、真实同角色随机配对。
元素打乱后仍高余弦的情况主要出现在一维归一化、偏置和 A_log,提示均值/分布影响。
修订版按维数分面、按密度归一化,并显示样本数,避免将不同样本量的峰高当概率比较。
它们是诊断对照,不是显著性检验,也没有完全匹配每个模块的采样构成。
三维对照分层仅有约 3~6 个样本,尤其不能据其峰形作总体推断。
这次只从已有 CSV/JSON 重绘并导出诊断表,模型权重已删除,没有增加参数比较或重新运行模型。
## 限制及后续决策
- 只研究一个 checkpoint;近邻筛选、同角色分组和子块抽样均可能漏掉其他共享机会。
- 直方图和层距曲线存在候选筛选与模块混合偏差,不能用作总体分布或独立样本推断。
- 光谱/子空间分析仅使用有界子体积;分布或子空间相似不等于可直接替换。
- 本轮没有测量能力损失、困惑度、运行内存或推理速度,也没有产出可运行的压缩模型。
- 大幅减少推理计算量需要进一步的计算图和路由分析,单纯共享存储不能保证加速。
下一轮先讨论候选选择与执行局部性、原始子块缓存、映射格式和阶段预算,
再修订 SOP;不自动下载第二个模型。只有获得额外授权后,才进行校准前向及
留出任务测试,以验证替换造成的能力损失。
数据与标准化报告见 `../results/qwen35-2b/`;具体阈值、分组、覆盖率、来源和校验记录
随原始图表数据归档。权重在交付副本校验后按授权删除,重现实验需要按固定 revision
重新下载。
+26 -3
View File
@@ -1,6 +1,8 @@
# Parameter similarity SOP — 2B pilot draft
Status: implementation draft; findings and revisions are added after the first real run.
Status: v0.1, executed for the bounded Qwen3.5-2B pilot. See [findings](PILOT_FINDINGS.md).
Changes proposed from this experience require a small equivalence/performance check before
the next model; no second model is started automatically.
## Scope and decision
@@ -62,7 +64,9 @@ Weight error is not task-accuracy loss, and parameter sharing does not imply few
- Save exact-pair tables every 100 pairs; stage deadlines prevent whole-tensor work
from consuming the complete block budget.
- On timeout or failure, retain source weights until partial results are recoverable
and report coverage/failure truthfully. Never call an incomplete run complete.
and report coverage/failure truthfully. An internal planned cutoff may produce a complete
bounded report with partial candidate coverage; always state verified/selected counts.
An external kill or missing required report is an incomplete run, not a completed experiment.
- Empty or negligible low-error sharing is a valid negative result. Do not add scales,
increase error thresholds, align permutations, train or expand to other models automatically.
- No runtime capability/performance claim without separately authorized evaluation.
@@ -70,10 +74,12 @@ Weight error is not task-accuracy loss, and parameter sharing does not imply few
## Commands (remote, from project root)
```sh
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m unittest discover -s tests -v
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 300 venv/bin/python -B -m unittest discover -s tests -v
venv/bin/python -B -m pilot.download --root runs/qwen35-2b
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 7200 venv/bin/python -B -m pilot.analyze --root runs/qwen35-2b --seconds 6600
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m pilot.plot --root runs/qwen35-2b
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 300 venv/bin/python -B -m unittest discover -s tests -v > runs/qwen35-2b/tests.log 2>&1
venv/bin/python -B -m pilot.audit --root runs/qwen35-2b --analysis-code-commit 6121016
venv/bin/python -B -m pilot.validate --root runs/qwen35-2b
# Copy archived results, verify checksums at the destination, then:
venv/bin/python -B -m pilot.validate --root runs/qwen35-2b --cleanup-weights
@@ -81,6 +87,23 @@ venv/bin/python -B -m pilot.validate --root runs/qwen35-2b --cleanup-weights
## Follow-up decisions after the pilot
- The pilot verified 2,000 tensor pairs and 14,778/20,000 selected block pairs before cutoff.
It took about 111 minutes; the final six-test suite including revised figure checks passed in about 77 seconds.
- Hatch missing heatmap cells and label identity values as constructed. Separate layer-distance
curves by dimension/scale; retain warnings about within-stratum module/selection bias.
Normalize control histograms, display sample counts, and verify their areas equal one.
Keep these diagnostics distinct from task-equivalence or statistical-significance claims.
- Avoid concurrent plotting tests and heavy weight IO on the shared host. Record IO wait,
swap, CPU and RSS; a low process RSS is not proof of low total resource cost.
- Distinguish tensor/group counts from byte contributions: 1D tensors were about half the
inventory count but only 0.0197% of weight bytes in this checkpoint.
- Keep fair candidate selection separate from IO-local execution order. Benchmark batching
by source file/tensor without changing the selected pairs or metrics.
- The sampled raw blocks total about 244.5 MiB. Test an explicitly bounded raw BF16/F32
cache against the uncached implementation before adopting it; include fingerprint and
temporary conversion memory in the budget. This was not enabled in the current run.
- Report both pre-metadata and net savings. Tiny blocks can have groups yet lose all savings
to mapping overhead. Any alternative sparse encoding needs its own explicit accounting.
- Separate low-byte normalization groups from matrix/expert compression opportunities.
- Decide whether approximate-neighbor recall and block coverage justify another bounded pass.
- If meaningful candidates exist, request a small calibration-forward experiment to measure