Skip to content

feat(subsystembenchmarks): add PyTorch Lightning checkpointing save benchmark - #994

Open
Yonghui-Lee wants to merge 2 commits into
fsspec:mainfrom
Yonghui-Lee:ckp-save-ssb
Open

feat(subsystembenchmarks): add PyTorch Lightning checkpointing save benchmark#994
Yonghui-Lee wants to merge 2 commits into
fsspec:mainfrom
Yonghui-Lee:ckp-save-ssb

Conversation

@Yonghui-Lee

Copy link
Copy Markdown
Collaborator

Summary

This PR implements the PyTorch Lightning checkpointing save subsystem benchmark to measure checkpoint write performance under various strategies in CPU-simulated environments.

Detailed Changes

  • Hugging Face PyTorch Lightning Driver:
    • Implemented PLCheckpointDriver which configures a dummy PyTorch Model and Dataset.
    • Uses a Gloo CPU distributed backend (via loopback sockets) to simulate distributed training processes on a CPU-only VM environment without requiring GPU resources.
    • Spawns worker processes using torch.multiprocessing.spawn, synchronizes ranks using dist.barrier() to accurately time the checkpoint write, and aggregates durations.
  • Supported Strategies:
    • single: Single device checkpointing.
    • ddp: Distributed Data Parallel.
    • fsdp_sharded: Fully Sharded Data Parallel with sharded checkpoint state dicts.
    • fsdp_full: FSDP with consolidated full checkpoint state dicts.
    • model_parallel_full / model_parallel_sharded: Combined Tensor Parallel (TP=4) and Data Parallel (DP=2) strategies (up to 8 ranks).

@Yonghui-Lee
Yonghui-Lee requested a review from zhixiangli August 4, 2026 06:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new checkpointing subsystem benchmark group (checkpointing/pytorch_lightning) to measure checkpoint write performance using PyTorch Lightning and various training strategies (DDP, FSDP, Model Parallel) on CPU-simulated environments. It includes the necessary driver, configuration, and test files, along with updates to Cloud Build scripts and schemas to support checkpointing metrics. The review feedback highlights two key improvement opportunities: preventing a potential ZeroDivisionError in checkpoint_case.py when the durations list is empty, and initializing the dummy model's linear layer directly with dtype=torch.bfloat16 in driver.py to avoid memory overhead and potential Out-Of-Memory (OOM) errors during initialization.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.69%. Comparing base (370ca0b) to head (5f7c393).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #994   +/-   ##
=======================================
  Coverage   89.68%   89.69%           
=======================================
  Files          16       16           
  Lines        3579     3581    +2     
=======================================
+ Hits         3210     3212    +2     
  Misses        369      369           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

_MACHINE_TYPE: "c4-standard-192" # CPU now; point at a GPU type later (auto-detect handles backend)
_REQUIREMENTS: ""
_SWEEP_AXES: ""
_STRATEGY: ""

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.

Could we avoid adding a checkpoint-specific _STRATEGY substitution?

If individual-case execution is operationally necessary, a generic case filter shared by all subsystem benchmarks would be a cleaner API.

{"name": "checkpoint_physical_size_bytes", "type": "INTEGER", "description": "Total physical size in bytes of the saved checkpoint files."},
{"name": "checkpoint_strategy", "type": "STRING", "description": "Checkpointing strategy used (single, ddp, fsdp, etc.)."},
{"name": "checkpoint_write_throughput_mean_bytes_per_second", "type": "FLOAT", "description": "Mean write throughput in bytes per second for the checkpoint save operation."},
{"name": "model_size_mb", "type": "INTEGER", "description": "Simulated model size parameter in Megabytes."}

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.

Is this useful to have model_size_mb. where model_size_mb describes the requested size of the synthetic Linear rather than the real model or persisted checkpoint. How about model id instead?

return torch.randn(self.in_features)


class DummyModel(L.LightningModule):

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.

A single very large Linear exercises Lightning’s save API, but it does not preserve the Llama workload’s tensor count and shapes, layerwise FSDP wrapping, architecture-specific tensor-parallel plan, or optimizer-state layout.

Shall we use the real model, so it can be a bridge between microbenchmarks and macrobenchmarks.

return durations


class PLCheckpointDriver:

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.

Is params.rounds ignored?

)
logging.info("Physical checkpoint size: %d bytes", physical_size_bytes)
except Exception as e:
logging.warning("Could not measure physical checkpoint size: %s", e)

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.

Why not fail loudly here?

model = model.to(torch.bfloat16)

# Trigger save checkpoint
trainer.fit(model, train_dataloaders=dataloader)

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.

Why perform a untimed automatic checkpoint before the measured save

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