TrajectoryImitationLoss: the regularization term (loss_2) has no gradient path to the student
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Domínio
- machine-learning
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 13.5k
- Forks
- 1.3k
- Merge médio
- 1d 13h
- PRs com merge (30d)
- 46
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelscope/DiffSynth-Studio
-
Partial download surfaces as "Cannot detect the model type" rather than a download errorTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
modelscope/DiffSynth-Studio#1668 ·
Mantenedores costumam responder em até 1 dia
-
bfloat16训练时段错误: 数组越界的一种方案Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
modelscope/DiffSynth-Studio#1499 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
modelscope/DiffSynth-Studio#1373 · 5 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
蒸馏后 Edit 能力下降Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 32/100
modelscope/DiffSynth-Studio#1881 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 12/100
modelscope/DiffSynth-Studio#1857 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de modelscope/DiffSynth-Studio
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choiceTalvez já em andamento @beartester34 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
modelscope/evalscope#2330 ·
Mantenedores costumam responder em até 1 dia
-
Distribution plot crashes when a numeric feature is constant in the train or test setTalvez já em andamento @adembilge assumiu hoje. Abertabug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
MAIF/shapash#847 · 1 comentário ·
Mantenedores costumam responder em até 10 dias
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 2 dias
-
namespace team:operations
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 60/100
EclipseFdn/open-vsx.org#16738 ·
Mantenedores costumam responder em até 1 dia