TrajectoryImitationLoss: the regularization term (loss_2) has no gradient path to the student
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- machine-learning
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 13.5k
- Fork
- 1.3k
- Merge medio
- 1g 13h
- PR unite (30g)
- 46
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelscope/DiffSynth-Studio
-
Partial download surfaces as "Cannot detect the model type" rather than a download errorForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
modelscope/DiffSynth-Studio#1668 ·
I maintainer di solito rispondono entro 1 giorno
-
bfloat16训练时段错误: 数组越界的一种方案Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelscope/DiffSynth-Studio#1499 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
modelscope/DiffSynth-Studio#1373 · 5 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
蒸馏后 Edit 能力下降Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
modelscope/DiffSynth-Studio#1881 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
modelscope/DiffSynth-Studio#1857 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelscope/DiffSynth-Studio
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choiceForse già presa @beartester34 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelscope/evalscope#2330 ·
I maintainer di solito rispondono entro 1 giorno
-
Distribution plot crashes when a numeric feature is constant in the train or test setForse già presa @adembilge l’ha presa oggi. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MAIF/shapash#847 · 1 commento ·
I maintainer di solito rispondono entro 10 giorni
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
namespace team:operations
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
EclipseFdn/open-vsx.org#16738 ·
I maintainer di solito rispondono entro 1 giorno