Skip to content

Add optional diffusion distillation strategy - #2099

Closed
CharlelieLrt wants to merge 1 commit into
codex/diffusion-checkpoint-bundlefrom
codex/diffusion-distillation-strategy
Closed

CharlelieLrt wants to merge 1 commit into
codex/diffusion-checkpoint-bundlefrom
codex/diffusion-distillation-strategy

Conversation

@CharlelieLrt

@CharlelieLrt CharlelieLrt commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR adds the optional DistillationStrategy for users who do not need to
write their own distillation loop. It extends Alchemi's general training strategy
to manage phase-specific optimizers, gradient accumulation, AMP, EMA, and
checkpoint restart.

Users install the diffusion-strategy extra and supply public models, a native
or FastGen-backed loss, and TensorDict batches:

strategy = DistillationStrategy(
    models={"student": student}, loss_fn=loss_fn, num_steps=1000,
    optimizer_configs={"student": [{"optimizer_cls": torch.optim.Adam,
                                    "optimizer_kwargs": {"lr": 1e-4}}]},
)
strategy.run(batches)

For explicit MeanFlow times, store t and r as separate batch tensors.
Use training_fn(models, batch) to return loss arguments containing
(t, DiffusionExtraTimes(r=r, batch_size=[B])). Ordinary single-time batches
need no conversion.

The strategy remains optional: expert users can call the same loss from their
own loop. Compilation and distributed setup remain under user control.
This PR also carries the grouped changelog entry for the distillation feature.

Checklist

  • This PR follows the contribution guidelines.
  • The documentation describes the API and its role in the stack.
  • This PR remains a draft.

Dependencies

If FastGen maintainers decline FastGen #44, we would close PhysicsNeMo #2100.
The preceding PhysicsNeMo stack would remain available.

Review process

Reviewers can compare this PR with its immediate parent. After a parent merges,
we update the remaining branches and their PR bases to keep each diff focused.

@CharlelieLrt CharlelieLrt added 2 - In Progress Currently a work in progress 5 - DO NOT MERGE Hold off on merging; see PR for details 5 - Merge After Dependencies Depends on another PR: do not merge out of order labels Oct 14, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS review map

Current for commit bc163960e295. An approval covers every file listed for that owner; one owner is sufficient for shared files.

⏳ @CharlelieLrt — 7 file(s)
  • docs/api/diffusion/distillation.rst
  • physicsnemo/diffusion/distillation/init.py
  • physicsnemo/diffusion/distillation/_alchemi.py
  • physicsnemo/diffusion/distillation/_fastgen.py
  • physicsnemo/diffusion/distillation/losses.py
  • physicsnemo/diffusion/distillation/strategy.py
  • test/diffusion/test_distillation_strategy.py
⏳ @coreyjadams — 1 file(s)
  • pyproject.toml
⏳ @ktangsali — 1 file(s)
  • pyproject.toml
⏳ @megnvidia — 1 file(s)
  • docs/api/diffusion/distillation.rst

No CODEOWNER

  • CHANGELOG.md
  • uv.lock

Comment /codeowners-info to refresh.

@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-distillation-strategy branch from bc16396 to b8c31db Compare October 14, 2026 05:35
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch from b19f3dc to 251d5db Compare October 14, 2026 05:35
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch from 251d5db to 6fb97f0 Compare October 14, 2026 17:03
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-distillation-strategy branch from b8c31db to 859b1c8 Compare October 14, 2026 17:03
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch from 6fb97f0 to 7a29c5f Compare October 16, 2026 01:19
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-distillation-strategy branch 2 times, most recently from 71c4445 to b7f4957 Compare October 16, 2026 02:52
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch 2 times, most recently from 8b9bbd5 to 62a1dba Compare October 16, 2026 20:15
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-distillation-strategy branch 2 times, most recently from 7ac3370 to 5ed9710 Compare October 17, 2026 01:44
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch from 62a1dba to 6a7ad14 Compare October 17, 2026 01:44
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-distillation-strategy branch from 5ed9710 to f7ae646 Compare October 28, 2026 03:42
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch from 6a7ad14 to 76416bf Compare October 28, 2026 03:42
Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-checkpoint-bundle branch from 76416bf to d775406 Compare October 29, 2026 02:23
@CharlelieLrt
CharlelieLrt force-pushed the codex/diffusion-distillation-strategy branch from f7ae646 to 78c4e28 Compare October 29, 2026 02:23
@CharlelieLrt

Copy link
Copy Markdown
Collaborator Author

Continued in PhysicsNeMo #2204, from branch diffusion-distillation-strategy in CharlelieLrt/modulus. The replacement preserves this implementation and includes the requested documentation clarifications. Please continue the review there. This PR retains the earlier discussion.

@CharlelieLrt
CharlelieLrt deleted the codex/diffusion-distillation-strategy branch October 29, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 - In Progress Currently a work in progress 5 - DO NOT MERGE Hold off on merging; see PR for details 5 - Merge After Dependencies Depends on another PR: do not merge out of order

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant