Skip to content

fix fsdp error from unused register token module - #2686

Open
Jubeku wants to merge 2 commits into
develop-ssl-diffusion-v1from
jk/develop-ssl-diffusion-v1/fix-fsdp
Open

fix fsdp error from unused register token module#2686
Jubeku wants to merge 2 commits into
develop-ssl-diffusion-v1from
jk/develop-ssl-diffusion-v1/fix-fsdp

Conversation

@Jubeku

@Jubeku Jubeku commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Only create the auxiliary-token parameter when aux tokens are actually used.
With num_register_tokens == num_class_tokens == 0, a zero-size parameter still participates in autograd and yields an empty gradient, which makes FSDP2's reduce-scatter fail with "RuntimeError: _chunk_cat expects non-empty tensor".

Description

Issue Number

Is this PR a draft? Mark it as draft.

Checklist before asking for review

  • I have performed a self-review of my code
  • My changes comply with basic sanity checks:
    • I have fixed formatting issues with ./scripts/actions.sh lint
    • I have run unit tests with ./scripts/actions.sh unit-test
    • I have documented my code and I have updated the docstrings.
    • I have added unit tests, if relevant
  • I have tried my changes with data and code:
    • I have run the integration tests with ./scripts/actions.sh integration-test
    • (bigger changes) I have run a full training and I have written in the comment the run_id(s): launch-slurm.py --time 60
    • (bigger changes and experiments) I have shared a hegdedoc in the github issue with all the configurations and runs for this experiments
  • I have informed and aligned with people impacted by my change:
    • for config changes: the MatterMost channels and/or a design doc
    • for changes of dependencies: the MatterMost software development channel

@Jubeku Jubeku self-assigned this Jul 27, 2026
@github-actions github-actions Bot added the model Related to model training or definition (not generic infra) label Jul 27, 2026
@clessig

clessig commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

@shmh40 : can you have a look? q_aux comes from develop-ssl.

@clessig clessig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add this:

diff --git a/src/weathergen/model/model_interface.py b/src/weathergen/model/model_interface.py
index d67ceaed..9a52aede 100644
--- a/src/weathergen/model/model_interface.py
+++ b/src/weathergen/model/model_interface.py
@@ -94,7 +94,7 @@ def init_model_and_shard(
             find_unused_parameters=cf.get("ddp_find_unused_parameters", True),
             gradient_as_bucket_view=True,
             bucket_cap_mb=512,
-            static_graph=cf.get("ddp_static_graph", True),
+            static_graph=cf.get("ddp_static_graph", False),
         )
 
     elif with_ddp and with_fsdp:

It's related to the PR and causes silent degradation of model convergence. Potentially we should remove it at all as a config parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model Related to model training or definition (not generic infra)

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants