Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ff45cc7
[dist] fix: keep FSDP2 buffers on compute device with CPU offload
YLlllllllllll Jul 23, 2026
a134860
fix: keep FSDP2 offload buffers on compute device
YLlllllllllll Aug 10, 2026
8d1738c
fix: resolve conflicts with upstream main
YLlllllllllll Aug 10, 2026
d12960e
fix: resolve FSDP2 merge conflict with upstream main
YLlllllllllll Aug 10, 2026
1059c6f
chore: align FSDP2 file with upstream main before branch update
YLlllllllllll Aug 10, 2026
e8bc2d6
chore: align CI workflows with upstream main before branch update
YLlllllllllll Aug 10, 2026
1526c68
Merge branch 'main' into fix/fsdp2-cpu-offload-compute-buffers
YLlllllllllll Aug 10, 2026
5fc05b9
fix: reapply FSDP2 CPU-offload fix after syncing upstream main
YLlllllllllll Aug 10, 2026
8eff52e
[dist] merge: keep FSDP2 buffer aliases while absorbing main material…
YLlllllllllll Aug 25, 2026
601ec99
[ci] fix: run DCP checkpointer tests once per workflow
YLlllllllllll Aug 25, 2026
0c299c3
[fsdp, tests] fix: reconcile offload buffer gates with model runtime
YLlllllllllll Oct 9, 2026
9bc6f37
[dist] fix: sync buffer offload with selective recomputation
YLlllllllllll Oct 15, 2026
5654f92
[dist] fix: preserve compute buffers across current-main CPU offload …
YLlllllllllll Oct 20, 2026
bad1835
Merge upstream main and preserve PR #967 coverage
YLlllllllllll Oct 22, 2026
7bc7ccc
Merge upstream main and preserve CPU-offload buffer contracts
YLlllllllllll Oct 23, 2026
804d743
[ci] test: schedule native CPU-offload buffer regression on NPU
YLlllllllllll Oct 23, 2026
425774b
Merge fused load tests while preserving FSDP buffer offload coverage
YLlllllllllll Oct 26, 2026
23a86a0
[checkpoint] fix: preserve shared buffers during HF loading
YLlllllllllll Oct 26, 2026
75ec473
[checkpoint] fix: retain constructor buffers during random initializa…
YLlllllllllll Oct 26, 2026
b53ccf5
[checkpoint] test: cover random buffer materialization on accelerators
YLlllllllllll Oct 26, 2026
8a5d06f
[dist] fix: preserve persistent buffers during random initialization
YLlllllllllll Oct 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions scripts/ci/accelerator/suites/npu.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,16 @@
"tests/utils/test_save_safetensor_utils.py"
]
},
{
"name": "fsdp-cpu-offload-native-unit",
"suite": "unit",
"args": [
"-v",
"-s",
"-x",
"tests/utils/test_rank0_load_and_broadcast_weights.py::test_fsdp_cpu_offload_training_keeps_buffers_on_compute_device"
]
},
{
"name": "npu-e2e-40",
"suite": "e2e",
Expand Down
38 changes: 35 additions & 3 deletions tests/checkpoints/test_dcp_checkpointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,23 +505,44 @@ def test_build_parallelize_model_forwards_should_skip_hf_weight_load(self, monke
assert result is parallelized_model
assert parallelize_fsdp2.call_args.kwargs["should_skip_hf_weight_load"] is True

def test_dcp_resume_preserves_nonpersistent_buffers_and_forward(self, monkeypatch, tmp_path):
def test_cpu_offload_dcp_resume_restores_persistent_and_nonpersistent_buffers(self, monkeypatch, tmp_path):
"""CPU regression for the accelerator-only FSDP2 offload subprocess tests.

The persistent registration is checkpoint-authoritative while the
non-persistent-only alias keeps its config-derived value.
"""

class ModelWithDerivedBuffer(nn.Module):
_no_split_modules = []

def __init__(self):
super().__init__()
self.weight = nn.Parameter(torch.tensor([[1.0, 2.0], [3.0, 4.0]]))
self.register_buffer("scale", torch.tensor([0.25, 2.0]), persistent=False)
shared_scale = torch.tensor([0.25, 2.0])
self.register_buffer("scale", shared_scale, persistent=False)
self.register_buffer("checkpointed_scale", shared_scale)
offset = torch.tensor([1.5, -0.5])
self.register_buffer("offset", offset)
self.register_buffer("offset_alias", offset)
runtime_cache = torch.tensor([7.0])
self.register_buffer("runtime_cache", runtime_cache, persistent=False)
self.register_buffer("runtime_cache_alias", runtime_cache, persistent=False)

def forward(self, x):
return (x @ self.weight) * self.scale
return (x @ self.weight) * self.scale + self.offset

def init_weights(self):
raise AssertionError("DCP resume must not initialize model parameters")

original = ModelWithDerivedBuffer()
assert "scale" not in original.state_dict()
assert "checkpointed_scale" in original.state_dict()
assert "offset" in original.state_dict()
assert "runtime_cache" not in original.state_dict()
assert original.scale is original.checkpointed_scale
assert original.offset is original.offset_alias
assert original.runtime_cache is original.runtime_cache_alias
original.scale.copy_(torch.tensor([0.5, 3.0]))
inputs = torch.tensor([[2.0, -1.0]])
expected_output = original(inputs)
checkpoint_dir = tmp_path / "dcp"
Expand All @@ -531,6 +552,9 @@ def init_weights(self):
resumed = ModelWithDerivedBuffer()
assert resumed.weight.is_meta
assert not resumed.scale.is_meta
assert resumed.scale is resumed.checkpointed_scale
assert resumed.offset is resumed.offset_alias
assert resumed.runtime_cache is resumed.runtime_cache_alias
parallel_state = SimpleNamespace(any_extra_parallel_enabled=False, extra_parallel_names=[], fsdp_mesh=None)
monkeypatch.setattr(torch_parallelize, "get_parallel_state", lambda: parallel_state)
monkeypatch.setattr(torch_parallelize, "fully_shard", lambda *args, **kwargs: None)
Expand All @@ -541,11 +565,19 @@ def init_weights(self):
weights_path="unused-hf-path",
mixed_precision=SimpleNamespace(enable=False),
should_skip_hf_weight_load=True,
enable_fsdp_offload=True,
fsdp_offload_pin_memory=False,
init_device="meta",
)
dcp.load({"model": resumed}, checkpoint_id=checkpoint_dir)

assert resumed.scale is resumed.checkpointed_scale
assert resumed.offset is resumed.offset_alias
assert resumed.runtime_cache is resumed.runtime_cache_alias
torch.testing.assert_close(resumed.scale, original.scale, rtol=0, atol=0)
torch.testing.assert_close(resumed.checkpointed_scale, original.checkpointed_scale, rtol=0, atol=0)
torch.testing.assert_close(resumed.offset, original.offset, rtol=0, atol=0)
torch.testing.assert_close(resumed.runtime_cache, original.runtime_cache, rtol=0, atol=0)
torch.testing.assert_close(resumed(inputs), expected_output, rtol=0, atol=0)


Expand Down
Loading
Loading