Chunked DFlash loss path flattens prev_token_ids, breaking DSpark subclass heads

Đang mở
#3 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python, pytorch

Hướng nghiên cứu

Bắt đầu bằng cách đọc _forward_chunked_decay và chunk gate trong angelspec/models/dflash.py, sau đó so sánh các triển khai hook trong angelspec/models/dspark.py và angelspec/models/draft/dspark.py. Tái hiện mục tiêu decay với ANGELSPEC_DFLASH_LOSS_CHUNK > 0 bằng cấu hình DSpark chỉ dùng Markov và với confidence_head_alpha=0. Hoàn thành khi đường dẫn chunked không còn bị crash và regularizer pos_alpha.smooth_loss() vẫn được giữ lại khi áp dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
460
Fork
40
Merge trung bình
1 giờ 4 phút
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Tencent/AngelSpec

Tất cả issue của Tencent/AngelSpec

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.