Skip to content

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

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

feat(subsystembenchmarks): add PyTorch Lightning checkpointing save benchmark#994
Yonghui-Lee wants to merge 3 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 (f6c9534).
⚠️ 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.

Comment thread cloudbuild/subsystembenchmarks/subsystembenchmarks-cloudbuild.yaml Outdated
Comment thread cloudbuild/subsystembenchmarks/subsystembenchmarks_schema.json Outdated
Comment thread gcsfs/tests/perf/subsystembenchmarks/checkpointing/checkpoint_case.py Outdated
@Yonghui-Lee

Copy link
Copy Markdown
Collaborator Author

E2E failed because of limited resources in the region.

- {axis: "strategy", strategy: "fsdp_sharded"}
- {axis: "strategy", strategy: "fsdp_full"}
- {axis: "strategy", strategy: "model_parallel_full", tensor_parallel_size: 4, data_parallel_size: 2, world_size: 8}
- {axis: "strategy", strategy: "model_parallel_sharded", tensor_parallel_size: 4, data_parallel_size: 2, world_size: 8}

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.

Should tensor_parallel_size and data_parallel_size be added to cloudbuild/subsystembenchmarks/subsystembenchmarks_schema.json?

super().__init__()
self.params = params

model_id = os.getenv("MODEL_ID", params.model_id)

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 just params.model_id?

rounds: 1
baseline:
model_id: "meta-llama/Llama-3.1-8B"
strategy: "single"

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.

Should the world_size be 1 for baseline?

strategy: "single"

scenarios:
- scenario: "checkpoint_write"

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 use name here for benchmark filtering?

"measurement_window_end_unix_seconds": int(window_end),
}
)
if result.extra_columns:

@zhixiangli zhixiangli Aug 6, 2026

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.

Would you mind extracting a func like publish_environment_metadata from gcsfs/tests/perf/subsystembenchmarks/dataloading/read_case.py and apply here too? including distributed_backend, compute_accelerator_type, machine_type, benchmark_source_commit_sha, requirements_override, requirements_resolved, config_sweep_axes_requested, etc.

"checkpoint_physical_size_bytes": physical_size_bytes,
"checkpoint_strategy": params.strategy,
"measurement_window_start_unix_seconds": int(window_start),
"measurement_window_end_unix_seconds": int(window_end),

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.

How about world_size, tensor_parallel_size, data_parallel_size?


model_id: str
strategy: str # single, ddp, fsdp, model_parallel_*
world_size: int = 2

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.

Should world_size be default 1?

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