TrajectoryImitationLoss: the regularization term (loss_2) has no gradient path to the student
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Start with diffsynth/diffusion/loss.py, especially TrajectoryImitationLoss.compute_regularization at the linked lines, then trace how forward adds loss_2. Reproduce the gradient comparison described in the issue and check whether the regularization term contributes gradients to the student. Done when the gradient behavior is corrected or its intended stop-gradient behavior is clarified, with a regression check covering the reported case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
In TrajectoryImitationLoss.compute_regularization, the student rolls out from the teacher's starting latent and each step is taken with noise_pred.detach():
The starting latent trajectory_teacher[0] comes from fetch_trajectory under torch.no_grad(). Every update then uses the detached prediction, so image_pred = pipe.vae_decoder(inputs_shared["latents"]) does not depend on the student's parameters. loss_2 is added to the training loss in forward (L215-L217), but it contributes no gradient to the student. Training still runs normally, because loss_1 (align_trajectory) is differentiable, so nothing signals that the regularizer is inactive.
If the stop-gradient is intended (e.g. to save memory), then loss_2 only changes the logged loss value, which is probably not what the image-space regularizer is for.
Reproduction
I ran the original TrajectoryImitationLoss.forward on CPU with:
- a scalar "student" (
0.7) and a frozen "teacher" (1.0) as model functions; - the real scheduler,
pipe.stepand serial CFG; - an identity decoder and an MSE consumer in place of LPIPS.
| d(total loss)/d(student) | |
|---|---|
| autograd, current code | −6.036 |
| central finite difference of the same loss | −6.636 |
autograd, with .detach() removed only in compute_regularization |
−6.636 |
The missing −0.6 is exactly the regularization term's gradient. The same result holds with the actual LPIPS (AlexNet) architecture with random frozen weights in place of the MSE consumer.
Context
I am working on a research project that checks diffusion training code for silent gradient and convention problems. This came out of that check. #1192 asks about this loss in general but does not mention the gradient path.
- Ngôn ngữ chính
- Python
- Star
- 13.5k
- Fork
- 1.3k
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelscope/DiffSynth-Studio
-
Partial download surfaces as "Cannot detect the model type" rather than a download errorCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
modelscope/DiffSynth-Studio#1668 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bfloat16训练时段错误: 数组越界的一种方案Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelscope/DiffSynth-Studio#1499 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Latest update broke Wan2.2 S2VĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
modelscope/DiffSynth-Studio#1373 · 5 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
蒸馏后 Edit 能力下降Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
modelscope/DiffSynth-Studio#1881 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
modelscope/DiffSynth-Studio#1857 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelscope/DiffSynth-Studio
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choiceCó thể đã có người làm @beartester34 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
modelscope/evalscope#2330 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Distribution plot crashes when a numeric feature is constant in the train or test setCó thể đã có người làm @adembilge đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MAIF/shapash#847 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 10 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
namespace team:operations
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 60/100
EclipseFdn/open-vsx.org#16738 ·
Maintainer thường phản hồi trong vòng 1 ngày