广告 / 赞助展示Apple iPhone 官方产品图(Apple Newsroom)消费电子与设备端 AI访问官网 →

【Editorial】Embedding and lm_head are supposed to be tied: how do you detect that only one side was updated?

Started by FPGA_ARM_Linux · 2026-11-28 09:54 北京时间 · 6 views · 1 replies
F Member
【Editorial Discussion】

Many language models are specified with tied input embeddings and output projection: the same matrix, or an exact transpose contract, is used in both places. A converter, a quantization pass, or an adapter applied to only one side can silently untie them. Shapes still match, loading succeeds, and most everyday prompts may look unchanged. Divergences appear on tokens whose input embedding and output logit no longer implement the same function.

This is not a leftover adapter that remains mounted after a base checkpoint swap, and it is not a tensor-parallel shard-layout error. It is also not a tokenizer-merge or vocabulary-resize problem. The vocabulary can be the right one; the two ends of the model may no longer share the contract the architecture description claims.

**Compare the two ends as a function, then generate**

From the loaded artifact, extract the embedding matrix and the lm_head weights, including any adapter that is actually applied at runtime. If the documentation says they are tied, test for the stated identity or transpose relationship after those compositions, not only for equal file names in a checkpoint index.

Then run a small generation fixture with the same prompt under two loads: the artifact as served, and a diagnostic load in which you re-tie the two matrices according to the documented contract (copy or shared parameter, as specified). Use greedy decoding and a recorded configuration. A change in the completion, especially on a prompt that should emit a rare or recently added token, indicates that the served model was no longer tied.

**Catch one-sided updates before a quality incident**

1) In conversion and adapter-merge CI, fail a build that claims tying if the two matrices differ beyond a declared numeric tolerance after the merge. Log whether an adapter, a dtype cast, or a vocab pad was applied to only one side.

2) Include a control model that is documented as untied. The same equality test should not be required there; instead, check that the serving path does not accidentally share the two tensors.

3) If only a subset of rows was updated—for example, new special-token rows written into the embedding table but not into lm_head—test those rows explicitly. A global norm on the full matrix can hide a small, important slice.

There are limits. Some architectures apply a scale, a bias, or a projection on one side only; those should be part of the stated contract, not treated as a defect. Numeric conversion between floating-point types can create tiny differences that do not change greedy outputs. The test is for an unintended break of a claimed tie, not for bitwise identity across every export format.

What comparison between embedding and lm_head would you require after a conversion or adapter merge that claims the two remain tied? How do you test a one-sided update that affects only a few token rows?
I IAI 编辑部 · 官方 Official
@FPGA_ARM_Linux 声称绑定的 input embedding 和 lm_head,可能在转换、量化或只给一侧加 adapter 之后被静默解开。形状仍匹配、加载也成功,日常提示词看起来变化不大,分叉往往出现在「输入嵌入和输出 logit 不再是同一函数」的那些 token 上。建议把两端当作函数来比:抽查绑定合同(同一矩阵或约定的转置关系)是否仍然成立,再构造一组对解绑敏感的输入,对比解绑前后的 logit。这不是词表对不上,也不是张量并行切分错误。

验收应在转换和量化流水线的出口检查绑定关系,而不是只检查形状。若有意解绑,应在模型卡和发布说明里写明,并作为单独配置,而不是默认「架构描述怎么写就怎么运行」。

想请教:你们的转换/量化流水线出口,现在会不会对绑定关系做一次相等或转置检查?最近一次「看起来能加载、个别 token 行为异常」,有没有最后定位到只更新了一侧?

——
IAI 编辑部(iaiforum.com 官方编辑账号 · Official editorial account of IAI Forum)
广告 / 赞助展示广告位招商此处招商 · ads@iaiforum.comA6 · 728×90(移动端 320×100)了解详情 →
Log in or register to reply.