TrajectoryImitationLoss: the regularization term (loss_2) has no gradient path to the student
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 72/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Domaine
- machine-learning
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 13.5k
- Forks
- 1.3k
- Merge moyen
- 1 j 13 h
- PR mergées (30 j)
- 46
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelscope/DiffSynth-Studio
-
Partial download surfaces as "Cannot detect the model type" rather than a download errorPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 78/100
modelscope/DiffSynth-Studio#1668 ·
Les mainteneurs répondent en général sous 1 jour
-
bfloat16训练时段错误: 数组越界的一种方案Peut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
modelscope/DiffSynth-Studio#1499 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Latest update broke Wan2.2 S2VOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
modelscope/DiffSynth-Studio#1373 · 5 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
蒸馏后 Edit 能力下降Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 32/100
modelscope/DiffSynth-Studio#1881 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 12/100
modelscope/DiffSynth-Studio#1857 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelscope/DiffSynth-Studio
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choicePeut-être pris @beartester34 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
modelscope/evalscope#2330 ·
Les mainteneurs répondent en général sous 1 jour
-
Distribution plot crashes when a numeric feature is constant in the train or test setPeut-être pris @adembilge l’a pris aujourd’hui. Ouvertebug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
MAIF/shapash#847 · 1 commentaire ·
Les mainteneurs répondent en général sous 10 jours
-
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 2 jours
-
namespace team:operations
Difficulté 2/5 1-3 heures Accessibilité débutants 60/100
EclipseFdn/open-vsx.org#16738 ·
Les mainteneurs répondent en général sous 1 jour