读见

你的量化验收门缺少的那个数字

原题The Number Your Quantization Gate Doesn't Have

约 24 分钟约 5,795 字原文英文已翻译

推荐理由准备上线量化模型的工程师,可用这篇实验重查验收清单:除了平均准确率,还要看业务阈值附近的误接受、误拒绝及其变化。

读前速览

5 个要点

对十个量化验收门的审计发现,没有一个使用依赖阈值的指标;一项人脸验证实验表明,沿用继承的相似度阈值会导致 int8 量化后误接受率飙升 3.5 倍,而准确率和 rank-1 几乎不变。

  1. 量化验收门在结构上对依赖阈值的失败视而不见,因为它们完全依赖无阈值指标。

    在调查的十份指南中,每个验收门都使用准确率、top-1、top-5、输出方差、延迟或内存。没有一个报告在实际决策阈值下的 FAR 或 FRR,因此通过验收门的构建仍可能拥有严重失准的工作点。

  2. 在一项人脸验证实验中,int8 量化使继承阈值下的误接受率增至三倍,而排序指标几乎未动。

    在 τ=0.2592 时,误接受从每 10,000 对冒名对中的 30 例升至 104 例(FAR 0.0104 对 0.0030),误拒绝从每 10,000 对真实对中的 582 例升至 745 例。precision@10 和 rank-1 的变化小于 0.01,因此验收门本会放行该构建。

  3. 两种错误率同时恶化,意味着量化产生了不同的 DET 曲线,而非沿同一曲线移动。

    fp32 和 int8 的 DET 曲线在观测窗口内并不重合,因此没有任何单一阈值选择能恢复 fp32 的工作点。这推翻了「量化沿固定曲线以宽松换严格」的常见假设。

  4. 对敏感层进行选择性 16 位保护并未修复阈值偏移。

    保护嵌入头、头加批归一化、输入主干或首尾层,都使误接受保持在 102–104,与完全 int8 无法区分。该启发式方法解决的是准确率问题,而非余弦阈值所测量的尺度问题。

  5. 修复方案是将 τ 下的 FAR 和 FRR 加入验收门,在量化模型上重新推导 τ,并将 τ 版本化后随模型产物一同发布。

    在继承的 τ 下进行诊断读数可显示损害;阻断标准则在留出对上分别以各自重新推导的 τ 比较 fp32 和 int8。重新推导将误接受从 104 降至 44,但将误拒绝从 745 升至 959,因此修复是必要的,但并非没有代价。

完整摘要

文章审计了十份量化指南,发现每个验收门都由无阈值指标构成,如准确率、top-1、top-5、输出方差、延迟和内存。没有一个报告在实际决策阈值下的误接受率(FAR)或误拒绝率(FRR)。作者使用 Hailo 工具链将 ArcFace 人脸验证编码器量化为 int8,结果显示 precision@10 和 rank-1 几乎不变(0.978→0.972 和 0.990→0.985),但在继承的阈值 τ=0.2592 下,误接受从 10,000 对冒名对中的 30 例升至 104 例,误拒绝从 10,000 对真实对中的 582 例升至 745 例。两种错误率同时恶化,表明这是不同的 DET 曲线,而非沿同一曲线移动。作者认为这一失败是结构性的:阈值是拟合到 fp32 模型的常数,量化改变了分数分布,而验收门没有重新检查它。对首尾层进行选择性 16 位保护也无济于事。提出的修复方案是将 τ 下的 FAR 和 FRR 加入验收门,在量化模型上重新推导 τ,并将 τ 版本化后随模型产物一同发布。局限性已被详尽记录。

目录 · 24 节

查看原文
Homage to Hamlet: an engineer asks a skull in the churchyard of the Elsinore castle whether he ought "to ship or not to ship" the quantized model build.

在你的量化运行手册中,某一行内容决定了 int8 构建能否发布。我调查的十份文档中,凡是写明这一标准的,表述都大同小异。EdgeGate 的门槛表将其写作“INT8 准确率 ≥ FP32 准确率 − 1%”。oneuptime 的检查清单则规定,当 PTQ“导致准确率下降超过 1%”时,应采用 QAT。一份实用的 PTQ 指南建议,将 top-1 和 top-5 与 FP32 基线进行比较。一个指标,一次比较,一个结论。Somewhere in your quantization runbook there is one line that decides whether the int8 build ships. In the ten documents I surveyed, wherever that line is written down at all, it is a version of the same sentence. EdgeGate's gate table writes it as "INT8 accuracy ≥ FP32 accuracy − 1%". The oneuptime checklist reaches for QAT when PTQ "loses more than 1% accuracy". A practical PTQ guide says compare top-1 and top-5 against the FP32 baseline. One metric, one comparison, one verdict.

本文对这条日志进行了审计,最后请你补充误接受率和误拒绝率,并按配置文件中实际设定的阈值进行测量。这两项目前都不在日志中。它们的缺失并非疏漏。This article is an audit of that line, and it ends by asking you to add to it a false-accept and a false-reject rate, measured at the threshold your config file actually holds. Neither is in the line today. That absence is not an oversight.

除非另有说明,所有图片均由作者提供。All images, unless otherwise noted, are by the author.

目录Table of contents

  1. 以计数形式进行的审计
  2. 本文讨论的接缝
  3. 闸门所看到的内容
  4. 它看不到的内容
  5. 在错误的地方越找越仔细
  6. 接缝还延伸到哪里
  7. 将 τ 处的 FAR 和 FRR 添加到门控中
  8. 返回计数器
  9. 附录 1:方法
  10. Appendix 2: limitations
    1. The absolute error rates are the weakest numbers in the piece.
    2. The target itself is my choice.
    3. The threshold shift is an illustration, not evidence.
    4. One drop of one model on one dataset with one toolchain.
    5. LFW is a saturated benchmark, and that cuts both ways.
    6. The calibration data was friendly.
    7. The green panels come from a different protocol.
    8. The 16-bit null is a null about this drop.
    9. The repair is measured, and it is neither sufficient nor free.
    10. The cost of the repair sits on the other side of the decision.
    11. The 377 extra rejections split, and the split is the price of the repair.
  11. 附录3:引导式调查(验收门槛和“阈值”)
  12. 参考文献

通过交互式机器学习路线图,一步步学习。Learn this step by step with the interactive Machine Learning roadmap.

以计数形式进行的审计An audit in the form of a count

检查你的验收门槛,并统计其中有多少指标的数值取决于决策阈值设在哪里。我调查的十份文档中,答案是零——每个门槛都由准确率、top-1、top-5、输出方差、延迟和内存构成。Go through your acceptance gate and tally the numbers whose value depends on where your decision threshold sits. In the ten documents I surveyed, the answer is zero — every gate is built from accuracy, top-1, top-5, output variance, latency, memory.

这十项并不是十道门槛,区分它们很重要。其中两项给出了一个数值门槛——EdgeGate 的“INT8 accuracy ≥ FP32 − 1%”,以及 oneuptime 用于切换到 QAT 的 1% 触发条件——而这两个门槛都是准确率差值。还有五项要求你将准确率与 fp32 进行比较,却没有给出具体数字。最后三项则是在比较结果不理想时要遵循的补救路径。三种类型,计数结果却相同:零。用于作出判断的是准确率数值,失败时你要关注的也是准确率数值,而这整个链条中没有任何一个数值取决于阈值。The ten are not ten gates, and the split matters. Two of them name a numeric bar — EdgeGate's "INT8 accuracy ≥ FP32 − 1%" and oneuptime's 1% trigger for switching to QAT — and both bars are an accuracy delta. Five more tell you to compare accuracy against fp32 without naming a number. The last three are the remediation path you follow when that comparison comes out badly. Three genres, one count: zero. The number that decides is an accuracy number, the number you reach for when it fails is an accuracy number, and nowhere along that chain does a threshold-dependent one appear.

那个零并不是我挑选了哪些文档所造成的偶然结果。这些指标评估的是模型,而决定接受还是拒绝的并不是模型本身,而是包裹在模型外围的一个常量——相似度阈值、置信度截断值或拒绝门限——它是根据 fp32 分数拟合出来的。量化并非中性的导出过程;它会改变分数的生成方式。一个完全由不含阈值的数字构成的门控,无论你再添加多少这样的数字,都无法判断那个常量是否仍处于你设定的位置。That zero is not an accident of which documents I picked. Those metrics grade the model, and the thing that decides an accept from a reject is not the model: it is a constant wrapped around it — a similarity threshold, a confidence cutoff, a reject gate — fitted against the fp32 scores. Quantization is not a neutral export; it changes how scores are produced. A gate made entirely of threshold-free numbers cannot ask whether that constant still lands where you put it, no matter how many such numbers you add.

因此,问题并不在于这个行业的门槛设错了,而在于这道门槛从结构上就无法察觉一种具体、可衡量的失效;要发现它,只需两个数字和一个下午的测量工作。本文接下来的内容将提供证据:这种失效确实存在,门槛中现有的任何环节都无法发现它,而修复它虽负担得起,却并非毫无成本。The claim, then, is not that the industry's gate is wrong. It is that the gate is structurally incapable of seeing a specific, measurable failure, and that seeing it costs two numbers and an afternoon of measurement. The rest of this piece is the evidence: that the failure is real, that nothing already in the gate would have caught it, and that the repair is affordable but not free.

本文讨论的那条接缝The seam this article is about

我在一个具体场景中测量了这种失效:人脸验证,使用预训练的 ArcFace 编码器,以及通过 Hailo 工具链构建的 int8 量化版本。因为只有在这里,我才能拿到真实数据,而不是演示文稿里的说法。下文所示的影响大小仅适用于这个量化版本,不能外推到其他场景;“局限性”附录完整列出了这项测量无法证明的内容。但这个计数可以外推:它取决于门控机制由什么构成,而不是我的编码器。至于这条分界线还出现在哪些地方——闭集分类、检测、普通检索——文末会给出一张地图,等这些数字证明了它的价值之后再看。I measured that failure in one place — face verification, a pretrained ArcFace encoder, an int8 drop built through a Hailo toolchain — because that is where I could get real numbers rather than a slide-deck claim. The size of the effect below belongs to that drop and travels no further; the limitations appendix is the full list of what this measurement does not establish. The count does travel: it is a property of what the gate is made of, not of my encoder. Where else the seam runs — closed-set classification, detection, plain retrieval — is a map at the end of this piece, after the numbers have earned it.

这个问题如此容易弥补,值得追问一句:为什么它至今仍未解决?并不是因为背后的事实晦涩难懂。阈值取决于特定模型和特定数据,二者任一发生变化,阈值便会失效——这在 RAG 和向量搜索中是标准做法(凭感觉设定阈值;将 RAG 阈值固定为绝对分数):团队会将截止值绑定到模型版本,并在 CI 中重新推导。在生物识别领域,这更是基础,因为错误匹配率和错误非匹配率都是相对于某个阈值定义的。这两部分知识都已存在,也都有明确记载。A hole this cheap to close is worth one question: why is it still open? Not because the underlying fact is obscure. That a threshold belongs to a specific model on specific data, and dies when either changes, is a standard playbook item in RAG and vector search (Threshold by feel; the RAG threshold pinned to an absolute score), where teams pin cutoffs to a model revision and re-derive them in CI. In biometrics it is foundational, since false-match and false-non-match rates are defined against a threshold. Both halves of the knowledge exist and are written down.

缺失的是这种交集。实际交付 int8 构建时你拿到的资料——编译器用户指南、供应商的精度调试页面、边缘部署检查清单——其中的“阈值”指的是 NMS 参数、编译器拆分或测试框架一致性,而从不会指“量化后重新推导工作点”(见下方综述表)。What does not exist is the overlap. Read what you are actually handed while shipping an int8 build — the compiler user guide, the vendor's accuracy-debugging page, the edge deployment checklist — and "threshold" appears as an NMS parameter, a compiler split, or harness consistency, never as "re-derive the operating point after quantization" (see the survey table below).

有些团队无论如何都会弥合这一差距:接受生物特征认证的组织会按照自己的时间表重新推导其工作点,而本文并非写给他们的。本文面向的是所有验收标准都源自工具链文档的人——在这些文档所描述的流程中,将分数转化为决策的那个常数,存放在一个构建流程既不会生成、门禁也不会读取的配置文件里。没有人会决定沿用一个继承来的阈值;只是,阈值根本不被视为构建流程应当产出的东西。在这种情况下,构建验收时,阈值的负责人并不在场,而验收构建的文档里也没有他们的位置。这正是本文要讨论的衔接缝隙,也正是统计结果为零的原因。Some teams close that gap anyway: an organisation under biometric certification re-derives its operating point on a schedule of its own, and this article is not addressed to them. It is addressed to everyone whose acceptance criterion comes from the toolchain documentation — where the constant that turns a score into a decision lives in a config file the build process never produces and the gate never reads. Nobody decides to ship an inherited threshold; the threshold is simply not one of the things a build is understood to produce. In that setting the people who own the threshold are not in the room when the build is accepted, and the document that accepts the build has no line for them. That is the seam this article is about, and it is why the count came out at zero.

A flowchart: a quantized build is evaluated on the reference set, then a gate asks whether every metric is within the toolchain guide's tolerance and ships or rejects the build. The checklist the gate reads - accuracy, top-1, precision@k, latency, memory - enters from one side. From the other, on a dashed line the gate does not consult, enter the constant from the config file and the false accepts and false rejects at it.

门所看到的内容What the gate sees

于是:门控读取的那张表。同一个编码器分别使用 fp32 和 int8,相同的评估照片,嵌入向量和指标并排展示。性能下降看起来几乎没有代价:So: the table the gate reads. Same encoder in fp32 and int8, the same evaluation photographs, embeddings and metrics side by side. The drop looks almost free:

  • 精确率@10:0.978 → 0.972

    precision@10: 0.978 → 0.972

  • 排名-1:0.990 → 0.985

    rank-1: 0.990 → 0.985

如果你就此停下——而门卫也允许你这么做——你就可以发布了。If you stopped here — and the gate says you may — you would ship.

现在注意这两个数字的共同点。Precision@10 和 rank-1 关注的都是谁排在最前面,而不是分数有多高。它们从定义上就是无阈值的:无论分数所处的尺度发生了什么变化,最不受影响的都会是这两个指标——而验收门槛正是由它们构成的。同样的现象——大量单条预测发生变化,而 top-1 几乎不动——在量化图像分类器中也有记录 [1];这并非本次发布的偶发现象。Now notice what those two numbers have in common. Precision@10 and rank-1 both ask who came back first, not how high the score was. They are threshold-free by construction: whatever happened to the scale the scores live on, these are the last metrics it would show up in — and they are what the acceptance gate is made of. The same pattern — a large share of individual predictions changing while top-1 barely moves — is documented for quantized image classifiers [1]; it is not a quirk of this drop.

它无法看到的内容What it cannot see

这里是开篇提到的两个数字——它们从未出现在仪表板上。固定阈值——配置中保留 fp32 在一个身份池上校准得到的原始数值——然后在一个独立的身份池上对留出样本对进行评分。即使是 fp32,在 10 000 个冒名者样本对中也有 30 个被错误接受。对 int8 版本应用同一个继承而来的截断值后,这个数量跃升至 104(FAR 0.0104):约为留出集 fp32 错误接受率的 3.5 倍;在同一批冒名者样本对上,FAR 增量为 +0.0074(76 个从拒绝翻转为接受,反方向只有 2 个)。错误拒绝也随之增加:在 10 000 个真实样本对中,从 582 增至 745(FRR 0.0745)。Here are the two numbers from the opening — the ones that never made it onto the dashboard. Fix the threshold — leave in the config exactly the number fp32 was calibrated to on one identity pool — and score held-out pairs from a disjoint identity pool. Already at fp32 the false-accept count is 30 out of 10 000 impostor pairs. Apply the same inherited cutoff to the int8 drop and the count jumps to 104 (FAR 0.0104): about 3.5× the held-out fp32 rate, FAR delta +0.0074 on the same impostor pairs (76 reject→accept flips against 2 the other way). False rejects move with them: 582 → 745 out of 10 000 genuine pairs (FRR 0.0745).

还要注意,并没有发生什么。你并没有在严格和宽松之间权衡取舍。两种错误率却同时变差了。这不是工作点沿着同一条曲线移动,而是换了一条曲线。And notice what did not happen. You did not trade strictness for laxity. Both error rates got worse at once. That is not one operating point sliding along the same curve — it is a different curve.

Two DET curves on log-log axes, false accept rate against false reject rate. The blue fp32 curve runs below the orange int8 curve across the whole window; they never meet. A marker on each curve shows where the same inherited threshold lands: on fp32 at 30 false accepts and 582 false rejects, on int8 at 104 and 745. A dashed hairline joins the two markers.

一个继承而来的阈值,两条曲线。fp32 参考模型和全 int8 构建版本在同一组留出的 TEST 配对上的 DET 曲线,每条曲线上都标出了继承的 τ = 0.2592。两条曲线并不重合,而且在图示窗口内,无论选择哪个阈值,都无法让 int8 构建版本回到 fp32 曲线上。这里的比率基于同一组固定的 31 个身份,并非绝对的现场 FAR/FRR;图注注明了分母和窗口的左边界。One inherited threshold, two curves. DET for the fp32 reference and the full-int8 build on the same held-out TEST pairs, with the inherited τ = 0.2592 marked on each. The curves do not coincide, and within the window shown no choice of threshold puts the int8 build back on the fp32 one. Rates on one fixed sample of 31 identities, not absolute field FAR/FRR; the figure's footnote carries the denominators and the window's left edge.

在错误的地方费力寻找Looking harder in the wrong places

显而易见的辩护是:我测错了。我是在固定阈值下打分的——这个具体数值是根据 fp32 DEV 集中的冒名者样本得出的,然后在 TEST 集上保持不变。这并不是业界报告结果的方式。惯例是报告 FAR = 1e-4 时的 TAR;这个数值在打印结果前,会悄悄地在评估集上重新推导阈值。NIST FRVT Part 3(NISTIR 8280)[2] 直言不讳地指出,这种惯例掩盖了什么:它说,大多数学术研究报告的是“固定假阳性率下的假阴性率,而非固定阈值下的假阴性率,因此掩盖了假阳性率的偏移,并错误表述了假阴性率”。NIST 追踪的是不同人口群体之间的偏移,而不是不同构建版本之间的偏移,所以这种类比是我做的——但它所依据的前提也恰恰是我的前提:“绝大多数生物识别系统都配置了一个固定阈值,所有比对都以此为准。”部署后的系统不会重新推导任何东西。它会一直沿用配置文件中的常量,直到有人手动修改。按标准方式报告这一降幅,失败就会从表格中消失——这种惯例掩盖的正是门控机制所掩盖的同一种失败。这就是制定该协议的理由,而不是它的缺陷。The obvious defence is that I measured it wrong. I scored at a fixed cutoff — the literal number derived on fp32 DEV impostors and then held on TEST. That is not how the field reports it. The convention is TAR at FAR = 1e-4, a number that quietly re-derives the cutoff on the evaluation set before printing the result. NIST FRVT Part 3 (NISTIR 8280) [2] is blunt about what that convention hides: most academic studies, it says, report false negative rates "at fixed false positive rates rather than at fixed thresholds, thereby hiding excursions in false positive rates and misstating false negative rates." NIST is tracking excursions across demographic groups rather than across builds, so the transposition is mine — but the premise it rests on is exactly mine too: "the vast majority of biometric systems are configured with a fixed threshold against which all comparisons are made." A deployed system re-derives nothing. It holds a constant in a config file until a human edits it. Report this drop the standard way and the failure leaves the table — the convention hides the same failure the gate does. That is the reason for the protocol, not a flaw in it.

第二种辩解是,我看的面板还不够多。我看了。邻居列表有五分之一发生了变化(相对于 fp32 的 recall@10 为 0.81),而门控数值只变了 0.6 个百分点——排名表经受住了考验,因为换掉的照片通常还是同一个人。几何检查结果保持平稳:内在维数从 269 变为 271,对比度从 0.596 变为 0.567。这些数字没有一个取决于截断点的位置。扩大门控范围也救不了这个局面。我的调查表中有两项直接比较 int8 输出与 fp32 的指标——EdgeGate 的输出方差、PyTorch 逐层的 SQNR——它们确实可能测出发生了变化。但它们都无法说明变化落在截断点的哪一侧,也无法说明这个常数如今偏离其拟合时所对应的速率有多远。这就是“与阈值无关”的含义,也是这组计数所包含的全部内容。一次退化中,四个面板亮起绿灯——两个排名指标、相对于 fp32 的召回率、几何检查——唯一亮红灯的,却是那个没人盯着看的面板。The second defence is that I did not look at enough panels. I did look. A fifth of the neighbour list turned over (recall@10 against fp32 is 0.81) while the gate's number moved by six tenths of a point — the ranking table survived because the swapped photographs are usually the same person. The geometry checks stayed flat: intrinsic dimensionality 269 → 271, contrast 0.596 → 0.567. Not one of those numbers is a function of where the cutoff sits. Nor would a wider gate have rescued the situation. The two items in my survey table that compare int8 outputs against fp32 directly — EdgeGate's output variance, PyTorch's per-layer SQNR — could well have registered that something moved. Neither can say which side of the cutoff it moved to, or how far the constant now sits from the rate it was fitted for. That is what threshold-free means, and it is the whole content of the count. Four green panels on one drop — two ranking numbers, recall against fp32, the geometry checks — and the only red one was the panel nobody was watching.

一旦接受这些数字,人们的本能反应就是去找编译器。看起来最适合下手的旋钮,是用额外的位数保护第一层和最后一层——我的供应商反复推荐这一启发式方法,而它的出处可以追溯到 NVIDIA 那篇整数定量化论文中一条相关工作:该论文提到,其他人在低于 8 位的位宽下会这么做 [3]。但那篇论文对 int8 的建议恰恰相反:量化所有层,然后通过测量找出敏感层。我按四种范围做了实验——嵌入头(fc1)、嵌入头加上其前面的批归一化层、单独的输入 stem(conv1),以及首尾层一起——在相同的留出集测试方案下,这四种做法的误接受数都在 102–104 之间,而 fp32 为 30,与全量 int8 并无显著差异(这里的零结果只针对这次降幅,并非针对选择性使用 16 位的普遍效果——参见局限性附录)。这本该就是警示信号。无论依据多么薄弱,这种启发式方法从未对余弦阈值所依据的尺度作出任何保证:它背后的每项说法都关乎准确率。我之所以求助于准确率工具,只是因为手边正好有这些工具——也正是同一种本能,让我把一个准确率数值放进了门槛指标里。The reflex, once you accept those numbers, is to reach for the compiler. The knob that looks made for this is protecting the first and last layers with extra bits — a heuristic my vendor repeats, and which traces back to a single related-work line in NVIDIA's integer-quantization paper reporting that other people do it [3] at sub-8-bit widths. That paper's own int8 recommendation is the opposite: quantize everything, then find the sensitive layers by measuring them. I ran it at four scopes — the embedding head (fc1), the head plus its preceding batch-norm, the input stem (conv1) alone, and first-and-last together — and under the same held-out protocol all four left the false-accept count at 102–104 against fp32's 30, indistinguishable from full int8 (a null about this drop, not about selective 16-bit in general — see the limitations appendix). Which should have been the tell. The heuristic never promised anything about the scale a cosine threshold is measured on: every claim behind it, thinly sourced or not, is a claim about accuracy. I reached for an accuracy tool because those are the tools lying around — the same reflex that put an accuracy number in the gate.

接缝还延伸到哪里Where else the seam runs

人脸识别是我能够测量的案例。影响幅度各不相同,但断层是结构性的:只要编码器输出连续分数,而下游系统将其切分为一个决策,这个切分阈值就是针对编码器的某个版本拟合出来的常数,而门控机制中没有任何环节会重新校验它。车辆图库匹配几乎与此同构——用的是同一个余弦相似度,也同样要做接受或拒绝的判断。闭集分类器没有相似度阈值,但它们会设定一个置信度,达到该置信度时就会请人介入;已有研究表明,量化会改变量化分类器 [1] 和 VLM [4] 的置信度校准——具体是朝哪个方向变化,取决于基础模型原本是过度自信还是信心不足。即使这种变化可能带来改善,也不能因此免于重新校准:无论往哪个方向变,按旧尺度拟合的阈值都会出错,而准确率面板不会告诉你它究竟朝哪个方向变了。检测器有一个边界框分数阈值,背后对应着一条精确率—召回率曲线。这些系统中任何一种是否会像我的案例那样发生如此大的变化,目前都还是个开放问题——值得测量,而不该想当然。本文唯一未涉及的场景,是没有接受或拒绝环节的纯检索:在那里,问题是邻居的排序被打乱,而既然从来没有阈值,也就谈不上阈值失效。Faces were the case I could measure. The magnitude is theirs alone, but the seam is structural: wherever an encoder emits a continuous score and something downstream cuts it into a decision, that cut is a constant fitted to one version of the encoder, and nothing in the gate re-checks it. Vehicle gallery matching is nearly isomorphic — same cosine, same accept-or-reject. Closed-set classifiers have no similarity cutoff, but they have a confidence at which a human gets pulled in, and confidence calibration is what quantization has been shown to move, in quantized classifiers [1] and in VLMs [4] — in either direction, depending on whether the base model was under- or overconfident to begin with. That the move can be an improvement is not a reprieve: a cutoff fitted to the old scale is wrong either way, and the accuracy panel will not tell you which way it went. Detectors have a box-score threshold with a precision-recall curve behind it. Whether any of these moves as far as mine did is an open question in each case — worth a measurement, not an assumption. The one place this article does not reach is pure retrieval with nothing to accept or reject: there the pain is reshuffled neighbours, and no threshold dies because there was never one to die.

这又让我们回到了计数问题。在这项实验中,所有结果为绿色的面板都没有设置阈值;而所有本可发现故障的面板,都没有纳入门禁——这正是那十份文档共同缺失的内容。再加上第五个绿色面板也无济于事,编译器同样帮不上忙。唯一有用的做法,是将阈值 τ 处的 FAR 和 FRR 纳入门禁。下面说明如何如实解读它们。Which brings us back to the count. Every panel that came out green in this experiment was threshold-free, and every panel that would have caught the failure was absent from the gate — the same absence the ten documents share. Adding a fifth green panel would not have helped, and neither would the compiler. The only thing that helps is putting FAR and FRR at the threshold τ into the gate. Here is what it takes to read them honestly.

将 τ 处的 FAR 和 FRR 添加到门控中Adding FAR and FRR at τ to the gate

四行:一行命名工作点,两行读取这对数值——一次使用你继承来的阈值,一次使用新构建所达到的阈值——还有一行输出结果。只有第二次读取会阻断流程。这些都不会取代现有门禁中的任何内容,而是与准确率差值并列。Four lines: one names the operating point, two read the pair — once at the threshold you inherited, once at the threshold the new build earns — and one ships the result. Only the second reading blocks. None of it replaces anything in your existing gate; it sits next to the accuracy delta.

  1. 明确说明这个构建承诺的运行点——目标误接受率、触发人工介入的置信度,或你的决策规则实际针对的指标。根据两种错误方向各自造成的代价来推导;我的目标是 FAR = 1e-3。

    Name the operating point the build is promising — a target false-accept rate, a confidence at which a human is pulled in, whatever your decision rule is actually for. Derive it from what each error direction costs; mine is FAR = 1e-3.

  2. 在继承的 τ 下报告 FAR 和 FRR——将其作为诊断指标,而非阻断条件。这一组指标正是计数结果未达标的原因:在一个准确率差异不构成阻碍的构建版本中,它显示有 104 次误接受,而 fp32 为 30 次;有 745 次误拒绝,而 fp32 为 582 次。两项都要看——NIST 也要求报告这两项 [2],原因相同:系统在固定阈值下运行,因此必须报告该阈值下的两项错误率。“这种做法很少见——大多数报告只关注假阴性。”不过,不要因此阻断构建。旧常量不必在新构建中继续沿用;若因它失效而阻断,就等于从定义上禁止量化。

    Report FAR and FRR at the inherited τ — as a diagnostic, not a blocker. This is the pair the count came up short by: it shows 104 false accepts against fp32's 30, and 745 false rejects against 582, on a build the accuracy delta waves through. Read both halves — NIST demands the same [2], for the same reason: systems run at a fixed threshold, so both rates must be reported at that threshold. "This is rarely done — most reports are concerned only with false negatives." Do not block on it, though. The old constant is not obliged to survive a new build, and blocking on its death forbids quantization by definition.

  3. 在量化模型上重新推导 τ,然后在新的 τ 下检查 FAR 和 FRR——这一项会阻止构建。这才是构建实际作出的承诺,而判据是比较,而不是绝对值:在同一组留出配对上,让 fp32 使用自己的 τ,与量化构建使用自己的 τ 进行比较;当任一错误率的变化幅度超过该错误方向所允许的代价时,构建就会被阻止——这正是得出第 1 步目标时采用的权衡。以我这样的配对数量预算而言,绝对错误率不能作为判据;方法附录解释了原因。两种错误仍都要看,而且这次它们朝相反方向变化:重新推导后,我的错误接受数从 104 降到 44,而错误拒绝数从 745 升到 959。让每个构建都使用自己的 τ,前者是 30 对 44(证据薄弱),后者是 582 对 959,差距大得多。修复是必要的,但不充分,也不是免费的;局限性附录分别列出了这三点的证据,包括第二个差距有多大程度上取决于某一个身份。

    Re-derive τ on the quantized model, then gate on FAR and FRR at the new τ — this one blocks. That is the promise the build is actually making, and the criterion is a comparison, not an absolute: fp32 standing at its own τ against the quantized build standing at its own τ, on the same held-out pairs, and the build blocks when either rate has moved further than the cost of that error direction allows — the same reckoning that produced step 1's target. An absolute rate cannot be the criterion on a pair budget like mine; the methods appendix says why. Both halves again, and here they move in opposite directions: re-deriving cut my false accepts 104 → 44 while raising my false rejects 745 → 959. Standing each build at its own τ, that is 30 against 44 on one side (thin evidence) and 582 against 959 on the other, a far larger margin. The repair is necessary, not sufficient, and not free; the limitations appendix carries the evidence under each of those three, including how much of the second margin rests on one identity.

  4. 将 τ 一同打包进模型制品,并与模型采用相同的版本号——绝不要把它作为全局常量放在配置文件中,让它的生命周期长于据此拟合的模型。“量化后重新校准”这条规则过于狭隘,无法适用于你下一次流水线变更。真正值得坚持的原则是:阈值是特定构建版本的产物。任何产出新构建版本、却没有同时生成新阈值的流程,发布的都是一个数值,而它所指向的模型早已不复存在。

    Ship τ inside the model artifact, versioned with it — never as a global constant in a config file that outlives the model it was fitted to. "Recalibrate after quantization" is too narrow a rule to survive your next pipeline change. The one worth keeping is that a threshold is an output of a specific build. Any process that produces a new build without producing a new threshold is shipping a number that refers to a model which no longer exists.

Two bar panels side by side, one per error direction, three columns each: fp32 at the inherited threshold, int8 at the inherited threshold, int8 at its own re-derived threshold. Columns are coloured by build, blue for fp32 and orange for int8, the same key as the DET figure. False accepts go 30, 104, 44; false rejects go 582, 745, 959. Arrows between adjacent columns carry the signed change. The panels are on different scales, one ticked to 100 and the other to 1000.

三个运行点上的两种错误方向。来自身份不重叠的 seed-0 划分中 10 000 对真实配对和 10 000 对冒名者配对的留出 TEST 计数。沿用原有阈值时,两个方向的错误会同时恶化;在 int8 版本自身的 DEV 冒名者样本上重新推导阈值,可减少 60 次误接受,但代价是再增加 214 次误拒绝——规定的修正方案只是以一种错误换取另一种错误,并不能恢复 fp32 的运行点。各面板的比例尺不同。计数基于同一固定样本,其中包含 31 个身份,不能代表实际场景中的绝对 FAR/FRR。Two error directions across three operating points. Held-out TEST counts on 10 000 genuine and 10 000 impostor pairs from an identity-disjoint seed-0 split. Under the inherited cutoff both directions move the wrong way at once; re-deriving the cutoff on the int8 build's own DEV impostors buys back 60 false accepts by spending 214 further false rejects — the prescribed repair trades one direction for the other, it does not restore the fp32 operating point. The panels are on different scales. Counts on one fixed pair sample of 31 identities, not absolute field FAR/FRR.

另外两项做法属于别人的实践手册,而非我的测量工作:将分数校准为概率,以便在更换模型时阈值能平稳退化;以及把阈值保存在纳入版本控制的文件中,并锁定到特定模型修订版本,同时在门控率发生漂移时触发警报——这都是前文引用的检索实践手册中的标准做法。如果你是第一次测量 FAR 和 FRR,方法附录还列出了让我付出最大代价的三个陷阱:划分数据集时确保身份互不重叠、按身份数而非配对数计算配对预算,以及使用配对检验,而不是比较绝对率之差。Two further moves belong to other people's playbooks rather than my measurement: calibrating scores to probabilities so a cutoff degrades gracefully across model swaps, and keeping thresholds in a checked-in file pinned to a model revision with an alarm on gate-rate drift — standard practice in the retrieval playbooks cited earlier. And if you are measuring FAR and FRR for the first time, the methods appendix carries the three traps that cost me the most: identity-disjoint splits, a pair budget counted in identities rather than pairs, and paired tests instead of differences of absolute rates.

没人给我的那一部分,是一份“反清单”——哪些情况不能算作决策规则经受住考验的证据:The one part nobody handed me is the anti-checklist — what does not count as evidence the decision rule survived:

  • 固定 FAR 下的 TAR,取自一份报告。该数值在打印前会重新推导阈值;而已部署的系统不会这样做(参见上文 NIST)。

    TAR at a fixed FAR, taken from a report. The number re-derives the threshold before printing it; a deployed system does not (see NIST above).

  • Top-1、rank-1、precision@k。从定义上来说,它们不受阈值影响。无论截断点设在哪里,这些指标都不会关注那里。

    Top-1, rank-1, precision@k. Threshold-free by construction. Wherever the cutoff went, these do not look there.

  • 内在维度、对比度,或任何全局几何检查。它也不依赖阈值,这就是为什么我的所有检查都一直是绿色通过状态。

    Intrinsic dimensionality, contrast, or any global geometry check. Threshold-free too, which is why all of mine stayed green.

  • “我们在 DEV 上重新推导了 τ。”这个行为不是结果。结果是该 τ 下留出配对上的 FAR 和 FRR。

    "We re-derived τ on DEV." The act is not the result. The result is FAR and FRR on held-out pairs at that τ.

  • “我们重新推导 τ 后,FAR 降低了。”相较于沿用的数值,确实如此。但同一操作也提高了误拒率。两方面都要检查。

    "FAR dropped after we re-derived τ." Against the inherited number, yes. The same act raised false rejects. Check both sides.

  • “我们达到了 1e-3。”对于 31 个身份而言,这个问题无法回答——请参阅方法附录中的配对预算。请改为报告计数和比率。

    "We hit 1e-3." Unanswerable on 31 identities — see the pair budget in the methods appendix. Report counts and ratios instead.

返回计数Back to the count

十份文档,一个计数:它们任何一道门槛中的数字,都不取决于决策阈值设在哪里。增加更多准确率面板改变不了这一点,转而求助于编译器也一样。真正能改变这一点的,是这道门槛所缺少的一对指标——在你的配置实际采用的阈值下,误接受和误拒绝的数量;先在你继承来的 τ 值上读一次,再在新构建所达到的 τ 值上读一次。决定 int8 构建能否发布的那行规则,仍然只有一行。只是它必须带上两个数字,准确率差值无法替代它们。Ten documents, one count: not one number in any of their gates depends on where the decision threshold sits. Adding more accuracy panels does not change that, and neither does reaching for the compiler. What changes it is the pair the gate is missing — false accepts and false rejects at the threshold your config actually holds, read once at the τ you inherited and once at the τ the new build earns. The line that decides whether the int8 build ships stays one line. It just has to carry two numbers an accuracy delta cannot stand in for.

附录 1:方法Appendix 1: methods

正文中的数值来自同一个编码器、同一个数据集划分,以及身份不相交的配对协议。数据集:通过 fetch_lfw_people(min_faces_per_person=20, color=True) 获取 LFW——3023 张人脸,62 个身份(已根据该调用验证)。使用 seed-0 排列,将 1024 张图像留作量化校准池;其余 1999 张用于评估。模型:预训练的 ArcFace w600k_r50.onnx,嵌入向量经过 L2 归一化。工具链:Hailo DFC,网内 normalization1,calibset_size=256;int8 数据为分支 A(完整 int8,不覆盖精度模式)。选择性 16 位作用域:B = fc1;C = fc1+batch_norm25;D = conv1;E = conv1+fc1。The body numbers come from one encoder, one dataset split, and an identity-disjoint pair protocol. Dataset: LFW via fetch_lfw_people(min_faces_per_person=20, color=True) — 3023 faces, 62 identities (verified against that call). A seed-0 permutation holds out 1024 images as the quantization calibration pool; the remaining 1999 are evaluation. Model: pretrained ArcFace w600k_r50.onnx, embeddings L2-normalised. Toolchain: Hailo DFC, in-net normalization1, calibset_size=256; the int8 figures are branch A (full int8, no precision-mode overrides). Selective 16-bit scopes: B = fc1; C = fc1+batch_norm25; D = conv1; E = conv1+fc1.

运行点(留出集):对 62 个评估身份进行 identity-disjoint 的 seed-0 划分——DEV 中有 31 个身份 / 806 张人脸,TEST 中有 31 个身份 / 1193 张人脸;在每个子集中分别独立抽取 10 000 对 genuine pairs 和 10 000 对 impostor pairs。阈值 τ = 0.259203 是这样一个截断值:它使 10 000 对 fp32 DEV impostor pairs 中恰好有 10 对高于该值——这是这些分数的 1−1e-3 分位数,在 DEV 上对应一个排名,而不是这批数据能够验证的比率。FAR/FRR 和原始计数均在 TEST 上报告,其身份从未出现在 DEV 中。成对不一致性是根据各集合中相同的 TEST impostor pairs 得出的。每个集合各自的 DEV τ 仅作为示例,与重采样基线并列报告(在相同的 pair 数量下,95% 半宽为 ±0.0167);它不是关于漂移的主要结论。Operating point (held-out): identity-disjoint seed-0 split of the 62 evaluation identities — 31 identities / 806 faces DEV, 31 / 1193 TEST; 10 000 genuine and 10 000 impostor pairs drawn independently in each half. Threshold τ = 0.259203 is the cutoff that leaves exactly 10 of the 10 000 fp32 DEV impostor pairs above it — the 1−1e-3 quantile of those scores, which is a rank on DEV and not a rate this data could verify. FAR/FRR and raw counts are reported on TEST, whose identities DEV never saw. Paired discordance is read off the same TEST impostor pairs across sets. Per-set DEV τ is reported only as an illustration next to a resampling baseline (±0.0167 at 95% half-width on the same pair budget); it is not the primary drift claim.

从“我测量了 FAR”到“我可信地测量了 FAR”之间有三个陷阱,它们让我付出了最多的返工代价。按身份划分,而不是按图像划分:在同一批配对上拟合并评估阈值,得到的只是样本内数值;仅仅重新抽样,我的数值就变动了 ±0.017。按身份数计算配对预算:有 K 个身份,就有 C(K,2) 个不同的配对,因此即使一次实验中没有误接受,95% 上限也只能达到 3/C(K,2)——我的 31 个身份将这个上限限制在 0.0065,这就是为什么本文中的任何绝对 FAR 声明都不能单独成立。要声称存在差异,必须在相同配对上进行配对检验——查看不一致计数、χ²,以及在配对足够独立、适合进行自助法分析的情况下,对差值计算自助法置信区间;绝不能直接相减两个绝对率。这里有一种方法我没有采用:对配对进行重抽样,会把来自 31 个身份的 10 000 次抽样当成 10 000 个观测值,从而报告超出这份预算所能支持的精度。旁边列出的计数和 χ² 不受同样的聚类问题影响,因为它们只针对实际测量所用的固定配对集合进行推断。Three traps sit between "I measured FAR" and "I measured FAR credibly", and they are the ones that cost me the most rework. Split by identity, not by image: a threshold fitted and scored on the same pairs is an in-sample number, and mine moved by ±0.017 under nothing but resampling. Count your pair budget in identities: with K identities there are C(K,2) distinct couples, so even a run with zero false accepts supports only a 95% upper bound of 3/C(K,2) — my 31 identities cap that at 0.0065, which is why no absolute FAR claim in this article stands on its own. Claim gaps with a paired test on the same pairs — discordant counts, χ², and, where pairs are independent enough to carry one, a bootstrap interval on the delta — never as the difference of two absolute rates. That interval is the one instrument here I do not use: resampling pairs treats 10 000 draws from 31 identities as 10 000 observations, and would report a precision this budget has not got. The counts and χ² beside it are untouched by the same clustering, because they claim nothing beyond the fixed pair set they were measured on.

这里的 χ² 指 McNemar 检验:它只根据不一致对计算——也就是两个构建结果不同的那些样本对,因为两个构建给出相同判断的样本对,对比较它们之间的差异毫无信息——检验的原假设是,两种方向的翻转概率相同,因此预期各占一半;经过连续性校正的统计量,大致就是偏离这一预期的标准误数的平方。误接受结果中,76 对 2 的差距约为 8 个标准误。第三个陷阱,正是区分我保留下来的两个结果的关键:重新校准后的 FAR 残余差距基于 32 个不一致对(23/9,χ² 为 5.3,略高于 2 个标准误)——在 10 000 对样本中只差 14 对,反转 7 对就能抹平;而 FRR 的代价则基于 415 对(396/19,χ² ≈ 341),差距为 377。门槛相同,证据基础却完全不可同日而语。χ² here is McNemar's: it is read off the discordant pairs alone — the ones where the two builds disagree, since a pair both builds call the same way says nothing about the difference between them — against a null in which a flip is equally likely either way, so the expectation is an even split and the continuity-corrected statistic is roughly the squared number of standard errors from it. The false-accept result's 76-against-2 sits about eight of those out. That third trap is what separates my two surviving results: the residual FAR gap after recalibration rests on 32 discordant pairs (23/9, χ² 5.3, a bit over two standard errors) — a margin of 14 pairs out of 10 000, which seven flipping back would erase — while the FRR cost rests on 415 (396/19, χ² ≈ 341), a margin of 377. Same bar, nothing like the same footing.

绿色排名/几何指标(precision@10、rank-1、内在维度、对比度、recall@10,相较于 fp32)仍来自此前在完整评估集上采用的单次抽样协议;这些指标本身不依赖阈值,因此不会与误接受结果混在一起。Green ranking / geometry figures (precision@10, rank-1, intrinsic dim, contrast, recall@10 vs fp32) still come from the earlier single-draw protocol on the full evaluation set; they are threshold-free by construction and are not mixed into the false-accept result.

上述每个数字背后的代码都在配套仓库 maxeffectus/quantization-threshold-drift 中,该仓库采用 MIT 许可证。无需 Hailo 许可证即可重新核验这三个留出的运行点:派生出的嵌入向量作为带校验和的 Release 资源一并发布,check_eval_release.py 会在重新打印本附录报告的计数前,验证每个数组的 SHA-256;flip_identity_breakdown.py 则逐个身份复现真实配对中的翻转情况,并且如果统计结果不是 396 对 19,就会拒绝打印明细。仓库未发布的是人脸裁剪图像(仓库不会再分发这些图像),以及 int8 重建模型(这需要 Hailo Dataflow Compiler)。发布的嵌入向量也不采用 MIT 许可证——它们是由编码器权重派生的生物特征模板,因此继承了这些权重的非商业研究条款。仓库的 README 已完整说明上述协议并划清这些界限;本附录不再赘述。The code behind every number above is the companion repository, maxeffectus/quantization-threshold-drift, MIT-licensed. The three held-out operating points can be rechecked without a Hailo licence: the derived embeddings ship as a checksummed Release asset, and check_eval_release.py verifies the SHA-256 of each array before it reprints the counts this appendix reports; flip_identity_breakdown.py reproduces the genuine-pair flips identity by identity, and refuses to print a breakdown that does not come to 396 against 19. What does not ship is the face crops, which the repository does not redistribute, or the int8 rebuild, which needs the Hailo Dataflow Compiler. The released embeddings are not MIT either — they are biometric templates derived from the encoder weights, and inherit those weights' non-commercial research terms. The repository's README states the protocol above and draws those lines in full; this appendix does not restate them.

附录 2:局限性Appendix 2: limitations

接下来列出的是这项测量无法确立的事项。这个列表比它能够确立的事项更长;对于单滴实验来说,这种比例很正常,而且其中大多数条目只是限定正文中的数值,而非对这些数值构成质疑。What follows is the list of things this measurement does not establish. It is longer than the list of things it does, which is the normal ratio for a single-drop experiment, and most of the entries bound the numbers in the body rather than threaten them.

这篇文章中最不理想的数据是绝对误差率。The absolute error rates are the weakest numbers in the piece.

从 31 个身份中抽取的一万对冒名者样本,并不等于一万个相互独立的观测:共享同一身份的样本对也共享该身份的独有特征,因此有效样本量更接近身份数量,而非样本对数量。其影响是实实在在的。31 个身份构成 465 个不同的身份组合,因此,即便某个工作点在所有组合中都没有产生误接受,95% 置信上限仍只能达到 3/465 ≈ 0.0065——高于拟合该阈值时所依据的 1e-3。因此,任何声称“此构建版本在绝对意义上达不到 1e-3”的表述,在这组数据上都缺乏依据,我自己写的也不例外。能够成立的结论,仅限于固定样本对集合上的结果:原始计数、相对比值,以及成对不一致情况(76 对从拒绝翻转为接受,反向则有 2 对)。解读误接受结果时,应说“在相同样本对上增加了 ×3.5”,绝不能说“实际场景中的 FAR 为 0.0104”。Ten thousand impostor pairs drawn from 31 identities are not ten thousand independent observations: pairs sharing an identity share its idiosyncrasies, so the effective sample is closer to the identity count than to the pair count. The consequence is concrete. With 31 identities there are 465 distinct identity couples, so an operating point that produced zero false accepts across all of them would still only support a 95% upper bound of 3/465 ≈ 0.0065 — above the 1e-3 the cutoff was fitted to. Any sentence of the form "this build misses 1e-3 in absolute terms" is therefore unsupported on this dataset, mine included. What survives is what is conditioned on the fixed pair set: the raw counts, the relative ratios, and the paired discordance (76 pairs flipping reject→accept against 2 the other way). Read the false-accept result as "×3.5 on the same pairs", never as "FAR is 0.0104 in the field".

目标本身由我选择。The target itself is my choice.

FAR = 1e-3 是我在评估脚本中硬编码的,因为我必须选一个值;它既不是行业标准,也不是产品 SLA,更不是别人给我的数值。真正的工作点应根据每种错误方向的代价来确定。正文中的所有内容,都是在说明针对一个目标拟合的截断值在量化后会如何表现,而不是在论证为什么应选这个目标。FAR = 1e-3 is hardcoded in my evaluation scripts because I had to pick something; it is not an industry standard, not a product SLA, and not a number anybody handed me. A real operating point is derived from the cost of each error direction. Everything in the body is a statement about how a cutoff fitted to one target behaves under quantization, not an argument for that target.

阈值的变化只是一个示例,并非证据。The threshold shift is an illustration, not evidence.

对评估样本对进行重采样,会使 fp32 阈值变动 ±0.017(95% 半宽)。要在 int8 DEV 样本池上恢复拟合得到的 FAR,余弦差距需增加约 +0.025——仅为这一噪声的 1.5 倍(我之前测得的样本内偏移 +0.032 也好不到哪儿去,约为 1.9 倍)。按照我自己的标准,这只能算一个警示,而非结论,因此没有写入正文。漂移这一主张仅基于留出集上的误接受计数,不依赖其他任何依据。Resampling the evaluation pairs moves the fp32 threshold by ±0.017 at 95% half-width. The cosine gap that would restore the fitted FAR on the int8 DEV pool is about +0.025 — barely 1.5× that noise (the in-sample shift of +0.032 I measured earlier fares no better, at ~1.9×). Under my own bar that is a flag, not a finding, which is why it does not appear in the body. The drift claim rests on held-out false-accept counts, and nothing else.

单一工具链在单个数据集上运行单个模型的一次部署。One drop of one model on one dataset with one toolchain.

没有重复的身份划分,没有第二个编码器、第二个编译器或第二项任务。操作点协议的两个部分都来自同一个 seed-0 身份划分;只有对这些划分进行身份级自助抽样,才能为这些数字中的任何一个给出站得住脚的区间,而我并未进行这项工作。文章末尾附近的相邻领域图明确是一组假设,正文中的数值不应被套用到其中任何一项。No repeated identity splits, no second encoder, no second compiler, no second task. Both halves of the operating-point protocol come from a single seed-0 identity split; an identity-level bootstrap over splits is what would put a defensible interval on any of these numbers, and it is not something I ran. The map of neighbouring domains near the end of the article is explicitly a set of hypotheses, and the magnitudes in the body should not be carried into any of them.

LFW 是一个已经趋于饱和的基准测试,这有利也有弊。LFW is a saturated benchmark, and that cuts both ways.

任何从事人脸识别工作的人都会注意到,我是在一个业界认为已经攻克的数据集上进行测量的。结构性结论并不取决于准确率面板是否一直显示绿色——一个不依赖阈值的数值,无法告诉你工作点移到了哪里,也无法说明它是否发生了移动——但这个演示确实取决于此;如果换成更难的基准测试,准确率差值可能大到足以让人以错误的理由叫停这个构建。饱和带来的,是一种至关重要的工作状态:选择验证编码器,恰恰是因为它在这类指标上已接近上限,所以在这种情况下,“准确率看起来没问题”是常态,而非侥幸。饱和并不能带来人口群体覆盖度。我在文中引用的那份关于固定阈值的 NIST 报告,同时也记录了不同人口群体之间的错误匹配率差异有多大;LFW 中的 31 个身份无法说明这一点,而这里也没有声称我测得的漂移会在部署系统实际面对的所有人群中均匀分布。Anyone who works in face recognition will note that I measured on a dataset the field considers solved. The structural claim does not depend on the accuracy panels staying green — a threshold-free number tells you nothing about where the operating point went, whether it moves or not — but the demonstration does, and on a harder benchmark the accuracy delta might have been large enough to stop this build for the wrong reason. What saturation buys is the regime that matters: a verification encoder is chosen precisely because it sits near the ceiling on metrics of that kind, so "accuracy looks fine" is the normal reading there rather than a lucky one. What it does not buy is demographic coverage. The same NIST report I quote on fixed thresholds is the one that documents how far false-match rates vary across demographic groups; 31 LFW identities cannot speak to that, and nothing here claims the drift I measured is uniform across the people a deployed system would actually see.

校准数据很友好。The calibration data was friendly.

那 1024 张校准图像和评估图像来自同一个 LFW 数据池,因此编译器设定激活值范围时,int8 看到的是分布内数据。实际流水线通常会用手边方便获取的图像进行校准。我的分布漂移算是比较温和的情况,并非最坏情况。类似地,编译器使用的图像数量也是另一个陷阱——误差与数据集大小之间呈 U 形关系——而我固定了 calibset_size,没有对它进行扫描。这里的失效模式是决策阈值没有调优,而不是校准集太小。Those 1024 calibration images come from the same LFW pool as the evaluation images, so the int8 drop saw in-distribution data when the compiler set its activation ranges. Real pipelines calibrate on whatever images are convenient. My drift is a friendly case, not a worst case. Relatedly, how many images the compiler uses is a separate trap — error versus set size is U-shaped — and I fixed calibset_size rather than sweeping it. The failure mode here is a decision threshold left untuned, not an undersized calibration set.

绿色面板来自另一种协议。The green panels come from a different protocol.

Precision@10、rank-1、recall@10 相对于 fp32 的结果、内在维度和对比度,都是在身份不相交的数据集划分出现之前,基于完整评估集并采用早期的单次抽样协议计算的。按定义,它们不依赖阈值,这恰恰就是这里要强调的要点,因此较宽松的协议不会削弱论证——但它们所依据的样本对与 FAR 数值并非来自同一批数据,不应将二者进行算术合并。Precision@10, rank-1, recall@10 against fp32, intrinsic dimensionality and contrast were computed under the earlier single-draw protocol on the full evaluation set, before the identity-disjoint split existed. They are threshold-free by construction, which is exactly the point being made about them, so the looser protocol costs the argument nothing — but they are not drawn from the same pairs as the FAR figures and should not be arithmetically combined with them.

这个 16 位空值是关于此次丢弃的空值。The 16-bit null is a null about this drop.

四种精度模式配置都让误接受数量维持在全 int8 的水平。这 refutes 了“调一下编译器选项,工作点就能保持不变”这一说法,但仅限于这个编码器。这并不能说明选择性使用 16 位精度在其他地方是否有帮助;要回答这个问题,需要做一个我刻意没有进行的析因实验。Four precision-mode scopes left the false-accept count where full int8 put it. That refutes "reach for the compiler knob and the operating point survives" on this encoder. It says nothing about whether selective 16-bit helps elsewhere, and answering that needs a factorial experiment I deliberately did not run.

修复措施是有限度的,既不足够,也并非免费。The repair is measured, and it is neither sufficient nor free.

按文章给出的方法,重新推导量化模型的阈值——也就是文章规定的修正——与沿用原数值相比,能将误接受率大致减半,因此兼容性门槛确实没有反映修正已经带来的改善。但与 fp32 的差距仍然存在:在同一组配对上是 44 对 30。配对检验确实能检出这一差异,但证据很弱(χ² 为 5.3,而误接受结果的 χ² 为 68)。应将这一残余差距视为在有限证据下可检测到的差异——其证据支持力度比兼容性失效弱一个数量级;这说的是差距得到了多充分的证实,而不是差距有多大。它绝不是“又恶化了一半”。Re-deriving the cutoff on the quantized model — the fix the article prescribes — cuts false accepts roughly in half against the inherited number, so the compatibility gate really is blind to work the repair already does. But the residual gap to fp32 is still there: 44 against 30 on the same pairs, and while a paired test does resolve it, it barely does (χ² 5.3 against the false-accept result's 68). Treat the residual as detectable on thin evidence — an order weaker in support than the compatibility failure, which is a statement about how well the gap is established and not about how large it is. It is certainly not "half again worse".

维修费用是做出决定后才需要考虑的问题。The cost of the repair sits on the other side of the decision.

在同一承诺的工作点上,int8 构建拒绝真实配对的频率是接受的 1.6 倍(396 次从 ok 翻转为 error,反向只有 19 次,χ² ≈ 341)。这也给所有实现修复的人提了个醒——如果门控机制只关注误接受,就会把重新校准判定为成功,却永远不会注意到合法用户开始被拒之门外。上文的身份聚类现象在这一侧同样存在,而且更为突出:贡献了 79% 真实配对的那个身份占了 80% 的翻转,因此 χ² 的五分之四都来自同一个人;这个计数反映的是这组配对的情况,不代表实地发生率。不过,这种现象并非只存在于这个人身上。来自其他 30 个身份的 2085 组真实配对中,翻转次数为 79 比 11(χ² ≈ 50):方向相同,仍远非均等分布。代价也并非只由少数几个倒霉的面孔承担:翻转最多的身份的翻转率为 4.01%,而合并后的翻转率为 3.96%,恰好与其占比相符;31 个测试身份中有 13 个完全没有发生翻转,因此翻转率也并不均匀。细分结果排除了一种解读:代价由一两个面孔承担。At the same promised operating point the int8 build rejects genuine pairs 1.6× more often (396 flips ok→error against 19 back, χ² ≈ 341), and that carries a warning for anyone who implements the fix — a gate watching only false accepts will call the recalibration a success and never notice that legitimate users started getting turned away. The identity clustering above applies to this side too, and more heavily: the identity contributing 79% of the genuine pairs holds 80% of the flips, so four fifths of that χ² is one person, and the count is a property of this pair set, not a field rate. It does survive the person, though. On the 2085 genuine pairs from the other 30 identities the flips run 79 against 11 (χ² ≈ 50): the same direction, still nowhere near an even split. Nor is the cost a handful of unlucky faces: the largest identity flips at 4.01% against a pooled 3.96%, exactly its share, and thirteen of the 31 test identities produced no flip at all, so the rate is not uniform either. What the breakdown rules out is the reading that one or two faces carry the cost.

这 377 次额外拒绝被拆分开来,而这种拆分就是修复所付出的代价。The 377 extra rejections split, and the split is the price of the repair.

在继承的 τ 下,int8 构建版本已拒绝了 745 对真实匹配,而 fp32 版本拒绝了 582 对,因此额外拒绝的匹配中有 163 对仅仅是量化分数造成的,另外 214 对则是将 τ 提高到足以减少误接受所付出的代价。重新校准以此为代价,挽回了 60 个误接受。At the inherited τ the int8 build already rejected 745 genuine pairs against fp32's 582, so 163 of the extra rejections are the quantized scores alone, and the other 214 are what raising τ far enough to cut false accepts costs. Recalibration buys back 60 false accepts at that price.

附录 3:指导性调查(验收门槛和“阈值”)Appendix 3: guide survey (acceptance gate and "threshold")

开篇和范围界定段落中的说法有所限定:共十份文档,来自九个来源,都是从业者在交付 int8 版本时可能会查阅的资料——Hailo DFC 用户指南按 3.27 和 3.30 两个版本分别计入,因为升级版本后,门槛条款保持不变;再加上下面的另外八个来源。这些资料属于同一类,而且这是有意为之:工具链和边缘部署文档。产品质量保证手册和生物识别认证规程属于另一类,此处不纳入;正文在说明文章不面向哪些读者时,也划分了同样的界限。Bounded claim for the opener and the scoping paragraph: ten documents from nine sources, the ones a practitioner is likely to open while shipping an int8 drop — the Hailo DFC User Guide counted at 3.27 and at 3.30, because the gate line survived the version bump unchanged, plus the eight further sources below. That is one shelf, and deliberately so: toolchain and edge-deployment documentation. Product-QA manuals and biometric certification protocols are a different shelf, not sampled here, which is the same distinction the body draws when it says who the article is not addressed to.

这十项资料分为三类。两项给出了具体的精度门槛(EdgeGate、oneuptime)。五项指出应将精度与 fp32 对比,但没有给出具体数值(DFC 的两个章节、Hailo 精度下降讨论串、TensorRT、PTQ 指南)。三项仅涉及补救措施(Hailo Quantization Scheme、YOLO 召回率讨论串、PyTorch 精度调试)。这三类资料都没有将重新推导验证工作点视为量化验收门槛的一部分。如果出现反例,就把它列入这张表——这只会让文章更加严谨,不会推翻它。Within the shelf the ten split three ways. Two name a numeric accuracy bar (EdgeGate, oneuptime). Five say to compare accuracy against fp32 without naming a number (both DFC sections, the Hailo accuracy-degradation thread, TensorRT, the PTQ guide). Three are remediation only (Hailo Quantization Scheme, the YOLO recall thread, PyTorch accuracy debugging). None of the three genres treats re-deriving a verification operating point as part of the quantization acceptance gate. If a counterexample appears, it belongs in this table — it would sharpen the piece, not collapse it.

Source

Stated acceptance / quality gate

Where "threshold" (or equivalent) appears

Hailo DFC User Guide 3.27 and 3.30

Accuracy of the quantized model vs the original; layer analysis and optimization levels as the remediation path

nms_score_threshold, split_threshold, dead-channel zeroing, compiler utilization — not operating-point recalibration

Hailo Quantization Scheme

Fix under-representation / degradation via 16-bit on sensitive layers, richer calibration, etc.

Layer precision advice; no verification τ

Hailo community: accuracy degradation

Compare original and compressed outputs to ground truth with task-specific postprocessing and metric

Metric left unspecified; silent on fixed-τ vs TAR@FAR

Hailo community: YOLO recall after HEF

Restore recall after compile

nms_score_threshold / iou_threshold as harness consistency with the PyTorch run — not drift of a deployed cutoff

PyTorch Quantization Accuracy Debugging

Restore accuracy after PTQ (SQNR / per-layer sensitivity)

No decision-rule / operating-point gate

TensorRT Working with Quantized Types

Correct quantized inference; accuracy vs FP32 as the practical check

No verification operating-point recalibration

EdgeGate: FP32 vs INT8 on real hardware

Explicit gate table: latency, memory, accuracy delta INT8 ≥ FP32 − 1%, output variance

"Threshold" = gate threshold on those metrics; not a similarity cutoff

oneuptime quantization checklist

Prefer QAT if PTQ loses more than ~1% accuracy

No operating-point recalibration step

Practical Guide to PTQ for Edge AI

Compare top-1 / top-5 to the FP32 baseline

No operating-point recalibration step

参考文献References

[1] G. Xia、S. Ha、T. Azevedo、P. Maji,《量化神经网络中置信度与校准之间一个尚未充分探讨的两难问题》(2021),arXiv:2111.08163[1] G. Xia, S. Ha, T. Azevedo, P. Maji, An Underexplored Dilemma between Confidence and Calibration in Quantized Neural Networks (2021), arXiv:2111.08163

[2] P. Grother、M. Ngan、K. Hanaoka,《人脸识别供应商测试(FRVT)第 3 部分:人口统计学影响》(2019),NISTIR 8280,美国国家标准与技术研究院[2] P. Grother, M. Ngan, K. Hanaoka, Face Recognition Vendor Test (FRVT) Part 3: Demographic Effects (2019), NISTIR 8280, National Institute of Standards and Technology

[3] H. Wu、P. Judd、X. Zhang、M. Isaev、P. Micikevicius,《深度学习推理的整数数量化:原理与实证评估》(2020),arXiv:2004.09602[3] H. Wu, P. Judd, X. Zhang, M. Isaev, P. Micikevicius, Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation (2020), arXiv:2004.09602

[4] A. Bouguerra、D. Montoya、A. Gomez-Villa、C. Mraidha、F. Arnez,《更低精度可能更可靠:量化对视觉语言模型影响的系统评估(超越准确率)》(2025),arXiv:2509.21173[4] A. Bouguerra, D. Montoya, A. Gomez-Villa, C. Mraidha, F. Arnez, Less Precise Can Be More Reliable: A Systematic Evaluation of Quantization's Impact on VLMs Beyond Accuracy (2025), arXiv:2509.21173


作者:Written By

马克西姆·波德斯特列奇内Maxim Podstrechnyy

Network Optix 的 AI 视频工程师。我对视觉模型、视觉语言模型等进行量化和优化,并将它们部署到 CPU、GPU、NPU 和边缘设备上。我是一名成员。AI Video Engineer at Network Optix. I quantize, optimize, and deploy vision models, vision-language models, and others across CPUs, GPUs, NPUs, and edge devices. I am a member

值得记下

  1. 那个零并非我挑选文档的偶然。那些指标评估的是模型,而决定接受还是拒绝的东西不是模型:它是包裹在模型外面的一个常数。
  2. 你并没有以严格换宽松。两种错误率同时恶化了。这不是一个工作点沿同一曲线滑动——而是一条不同的曲线。
  3. 唯一有帮助的是把阈值 τ 下的 FAR 和 FRR 放进验收门。
  4. 修复是必要的,但不充分,也并非没有代价。

← 回到本期 · 第 5 条