Chunked DFlash loss path flattens prev_token_ids, breaking DSpark subclass heads
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
调研方向
先阅读 angelspec/models/dflash.py 中的 _forward_chunked_decay 和 chunk gate,然后比较 angelspec/models/dspark.py 与 angelspec/models/draft/dspark.py 中的 hook 实现。使用仅 Markov 的 DSpark 配置并设置 confidence_head_alpha=0,在 ANGELSPEC_DFLASH_LOSS_CHUNK > 0 时复现 decay objective。完成的标准是 chunked path 不再崩溃,并在适用时保留 pos_alpha.smooth_loss() regularizer。
由索引模型根据 Issue 内容生成。
描述
In _forward_chunked_decay, prev_token_ids is flattened to 2-D before being passed to the _compute_draft_logits hook:
https://github.com/Tencent/AngelSpec/blob/main/angelspec/models/dflash.py#L1089-L1094
prev_chunk = prev_token_ids[:, start:end].reshape(bsz, nb * bs) # 2-D
logits_chunk = self._compute_draft_logits(dh_chunk, lm_head_weight, prev_chunk, nb)
But DSparkModel._compute_draft_logits (angelspec/models/dspark.py) forwards prev_token_ids to markov_head.apply_block_logits(token_ids=...), which expects [B, n_blocks, block_size] (angelspec/models/draft/dspark.py). With a 2-D input, compute_step_bias produces a [bsz, nb*bs, V] bias that is added to [bsz, nb, bs, V] logits — a RuntimeError whenever nb > 1 (and a silently wrong broadcast followed by a reshape crash when nb == 1, bsz > 1).
The gate that is supposed to keep subclass heads off the chunked path only checks _extra_distill_needed():
https://github.com/Tencent/AngelSpec/blob/main/angelspec/models/dflash.py#L754-L761
For DSpark that returns True only when a confidence head is active, so a DSpark model with only a markov_head (or confidence_head_alpha=0) plus ANGELSPEC_DFLASH_LOSS_CHUNK > 0 and the decay objective takes the chunked path and crashes. This contradicts the stated intent in _dflash_loss_chunk's docstring ("dpace / distillation / subclass heads keep the single full-vocab projection").
A secondary issue on the same path: _forward_chunked_decay never calls _compute_extra_loss, so the position-adaptive-alpha smoothness regularizer (pos_alpha.smooth_loss()) is silently dropped for any DSpark config that reaches the chunked path without crashing.
Possible fixes: extend the chunk gate to exclude models that override _compute_draft_logits / _compute_extra_loss, or pass prev_token_ids as [B, nb, bs] and make the hooks shape-consistent.
- 主要语言
- Python
- 星标
- 460
- 派生
- 40
- 平均合并
- 1 小时 4 分钟
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Tencent/AngelSpec 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 4/5 3-5 天 新手友好度 52/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 72/100
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
查看 Tencent/AngelSpec 的全部 Issue
相似的 Issue
-
ui
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
accepted
难度 2/5 1-3 小时 新手友好度 68/100
future-agi/future-agi#5070 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
juandresrodca/AdminForge#69 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
deepset-ai/haystack-integrations#817 ·
维护者通常 12 天内回复
-
[Bug]: test_remote_realpath_uses_argument_vector fails on Windows with Python 3.13+ (ntpath.isabs)可能已有人在做 @gouyu-hou 今天认领。 未关闭triage/confirmed
难度 1/5 1 小时以内 新手友好度 90/100
agentscope-ai/agentscope#4397 ·
维护者通常 2 天内回复