Add Flux.2 segmented checkpointing support - #2941
Merged
bghira merged 2 commits intoAug 3, 2026
Merged
Conversation
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
from
August 3, 2026 08:50
7a70b79 to
0477572
Compare
bghira
marked this pull request as ready for review
August 3, 2026 08:53
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Flux.2 model-family integration for the segmented gradient-checkpointing controls introduced in the stacked base branch, wiring Flux.2’s transformer forward pass into the shared checkpointing/offload infrastructure and ensuring the safety-check allow-lists recognize Flux.2.
Changes:
- Add a Flux.2 model-support test ensuring required checkpointing control hooks/flags are present.
- Extend safety-check allow-lists to permit Flux.2 usage of gradient-checkpointing interval/segment-stride and attention activation offload.
- Implement Flux.2 transformer support for segmented checkpointing (interval + segment stride) and attention activation offload plumbing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_segmented_checkpointing_model_support.py |
Adds Flux.2 to the model-support coverage checks for segmented checkpointing controls. |
simpletuner/helpers/training/default_settings/safety_check.py |
Allows Flux.2 in the relevant safety-check lists for checkpointing interval/stride and attention activation offload. |
simpletuner/helpers/models/flux2/transformer.py |
Adds Flux.2 runtime support for segmented checkpointing and threads offload_attention through attention processors/blocks. |
Suppressed comments (1)
simpletuner/helpers/models/flux2/transformer.py:439
- Same as above for
Flux2ParallelSelfAttnProcessor: themaybe_metal_flash_rope_attention(...)path executes outsideactivation_offload_context, sooffload_attention=Truewon’t offload saved tensors when this backend is used. Wrap that call inactivation_offload_contexttoo.
getattr(attn, "to_qkv_mlp_proj", None) and attn.to_qkv_mlp_proj.weight,
)
if hidden_states is None:
with activation_offload_context(offload_attention, label=f"{attn.__class__.__qualname__}:attention"):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
257
to
+261
| getattr(attn, "to_q", None) and attn.to_q.weight, | ||
| getattr(attn, "to_k", None) and getattr(attn, "to_k", None).weight, | ||
| ) | ||
|
|
||
| if hidden_states is None and self._packed_attention_backend is not None and not cp_active: | ||
| hidden_states = _run_packed_qkv_attention(query, key, value, attention_mask, self._packed_attention_backend) | ||
| elif hidden_states is None: | ||
| hidden_states = dispatch_attention_fn( | ||
| query, | ||
| key, | ||
| value, | ||
| attn_mask=attention_mask, | ||
| backend=self._attention_backend, | ||
| parallel_config=parallel_config, | ||
| ) | ||
| if hidden_states is None: |
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
2 times, most recently
from
August 3, 2026 09:49
61955d3 to
900af3a
Compare
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
from
August 3, 2026 10:45
900af3a to
0b50f28
Compare
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
from
August 3, 2026 15:30
0b50f28 to
99a2506
Compare
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
from
August 3, 2026 15:32
99a2506 to
764620d
Compare
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
from
August 3, 2026 15:33
764620d to
d743b25
Compare
bghira
force-pushed
the
agent/segmented-checkpointing-flux2
branch
from
August 3, 2026 15:35
d743b25 to
485b02d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits the Flux.2 segmented checkpointing support model integration out of #2925.
Stack
Base branch:
agent/segmented-checkpointing-fluxValidation
.venv/bin/python -m unittest tests.test_segmented_checkpointing_model_support -v