Files
myWiki/concepts/lazyar.md

48 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "LazyAR (Lazy Autoregressive Decoder)"
created: 2026-06-28
updated: 2026-06-28
type: concept
tags: [generative-recommendation, inference-optimization, decoder-architecture]
sources: [GR4AD]
---
# Lazy Autoregressive Decoder (LazyAR)
LazyAR 是 [[GR4AD]] 提出的**懒惰自回归解码器**架构释放逐层自回归依赖以提升多候选生成吞吐量。在保持推荐效果的前提下LazyAR 将近翻倍推理 QPS。
## 动机
标准自回归解码中UA-SID 的每一级 token 的生成都需要完整的 $L$ 层解码器计算,即:
$$m_t(1), m_t(2), ..., m_t(L) = \text{Decoder}(s_{<t})$$
$T$ UA-SID 总计算量为 $T \cdot L$
观察发现第一级 UA-SID$s_1$的损失最大承载了最关键的语义信息后续级别$s_2, s_3, ...$的解码可以在不显著影响效果的前提下共享计算
## 架构
LazyAR $L$ 层解码器分为两段
- ** $K$ 共享段**计算与 $s_{t-1}$ 无关的 trunk 表示 $m_t(K)$所有 UA-SID 级别共享
- ** $L-K$ 注入段**在第 $K$ 层注入 $s_{t-1}$ 的嵌入仅这些层需逐级重算
$$m_t(K) = \text{Decoder}^{1:K}(s_{<t} \setminus \{s_{t-1}\})$$
$$\hat{m}_t = \text{Decoder}^{K+1:L}(m_t(K) \oplus \text{Emb}(s_{t-1}))$$
## 速度优势
$m_t(K)$ 不依赖 $s_{t-1}$因此前 $K$ 层的结果可以**在所有 UA-SID 级别间复用**。总计算量从 $T \cdot L$ 降至 $1 \cdot K + T \cdot (L-K)$
- $K=6, L=9, T=3$:计算量从 $27$ 降至 $6 + 3 \times 3 = 15$,节省 ~44%
## 与 DeepSeek MTP 的区别
DeepSeek [[MTP]] 也为所有后续 token 复用前几个 transformer MTP 在每个位置都进行融合投影LazyAR 直接复用 trunk 表示延迟到第 $K$ 层才注入前级 token——这种"延迟注入"设计在短序列多候选场景中更高效
配置GR4AD 使用 $L=9, K=6$,共享前 6
## 参考
- [[GR4AD]]
- [[MTP]]