Skip to content

[WIP] Prototype original-parameter AdamW8bit state for FSDP1 - #2081

Open
gss10282025 wants to merge 1 commit into
bitsandbytes-foundation:mainfrom
gss10282025:prototype-fsdp-original-parameter-state
Open

gss10282025 wants to merge 1 commit into
bitsandbytes-foundation:mainfrom
gss10282025:prototype-fsdp-original-parameter-state

Conversation

@gss10282025

Copy link
Copy Markdown

Summary

Add an executable reference for keeping AdamW8bit state attached to original parameters under FSDP1. It gathers each original parameter's gradients, updates per-parameter shadow state, and copies the resulting values back into the flat shards.

Related to #2080.

This is a draft for discussing the state-layout contract. The reference replicates optimizer state and uses private FSDP1 metadata. A production version still needs a supported metadata interface and sharded state; checkpointing, AMP, and offload are outside this example.

Validation

Run with:

torchrun --standalone --nproc-per-node=2 examples/fsdp1_original_parameter_state.py --device cpu

Passed on PyTorch 2.13.0+cpu and bitsandbytes 0.50.2, with two CPU/Gloo ranks and two optimizer updates:

  • Native AdamW8bit chooses FP32 state for the four small parameters with fine wrapping, and 8-bit state with coarse wrapping. The maximum absolute difference across the complete parameter-update vectors is 6.15e-5.
  • The reference keeps those four states in FP32 under both layouts, and all parameter updates match exactly.
  • The separate 8,192-element parameter keeps 8-bit state in both layouts.

Ruff lint/format checks and Python compilation pass. The example also accepts --device cuda; that command was not rerun for this PR.

Signed-off-by: gss10282025 <326855337+gss10282025@users.noreply.github.com>
@gss10282025
gss10282025 marked this pull request as ready for review September 10, 2026 17:03
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.

1 participant