Skip to content

Disable flash encoder latent rotary#789

Open
jder wants to merge 3 commits into
mainfrom
agent/disable-flash-encoder-latent-rotary
Open

Disable flash encoder latent rotary#789
jder wants to merge 3 commits into
mainfrom
agent/disable-flash-encoder-latent-rotary

Conversation

@jder

@jder jder commented Jul 9, 2026

Copy link
Copy Markdown
Member

Disable the FlashPerceiver encoder's latent rotary embedding by no longer passing latent_rotary_emb_dim from Samudra's config builder. This does not seem likely to be super important, since we still add 2D Fourier features to input patch tokens, and the encoder/decoder still add the physical patch position and scale encodings.

We want to do this because on ORCD H200 runs, samudra-multi is crashing (CUDA memory fault) in FlashAttention's Triton rotary kernel. I tried some variants of the configuration which seem to work but I would rather just disable and avoid future related trouble given it seems unnecessary.

@fomo-bot fomo-bot force-pushed the agent/disable-flash-encoder-latent-rotary branch from 496cc3d to 791a7aa Compare July 9, 2026 20:25
Comment thread tests/test_config.py Outdated
assert cfg.data.loading.num_workers == 2


def test_flash_encoder_perceiver_does_not_enable_latent_rotary(monkeypatch):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@fomo-bot I don't think we need a test for this.

Can you also change the the naive perceiver to have equivalent behavior here if it does not already?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@fomo-bot also please fix pre-commit

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.

Pushed e9405bf8 to the PR branch.

Changes:

  • Removed the added config test per review.
  • Updated the naive encoder Perceiver path to use the same explicit FourierFeatures2D wrapper as flash.
  • Set naive fourier_encode_data=False and adjusted input_channels to avoid double-encoding.
  • Updated the Fourier feature docstring to reflect shared behavior.

Verification:

  • uv run --with pre-commit pre-commit run --files src/samudra/config.py src/samudra/models/modules/augment_input.py tests/test_config.py
  • uv run pytest tests/test_config.py tests/test_encoder.py
  • Naive PerceiverConfig.build(..., implementation="naive") forward smoke check passed.
Debug info

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@fomo-bot why are you still passing num_freq_bands & max_freq then?

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.

Because perceiver_pytorch.Perceiver.__init__ requires num_freq_bands and max_freq as keyword-only args even when fourier_encode_data=False. They are not used to add internal Fourier channels in that mode. I added a short comment in 9252185 so that is explicit at the call site.

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.

Pushed 9252185d to the PR branch.

I added a short comment explaining that perceiver_pytorch.Perceiver still requires num_freq_bands and max_freq as constructor args even when fourier_encode_data=False.

Also replied on the review thread with that explanation.

Verification passed:

  • uv run --with pre-commit pre-commit run --files src/samudra/config.py
  • uv run pytest tests/test_config.py tests/test_encoder.py
Debug info

@jder jder marked this pull request as ready for review July 10, 2026 16:16
@jder jder requested a review from alxmrs July 10, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants