Skip to content

🥓 [docs] add CP docs#3994

Merged
qgallouedec merged 31 commits intomainfrom
cp-docs
Sep 9, 2025
Merged

🥓 [docs] add CP docs#3994
qgallouedec merged 31 commits intomainfrom
cp-docs

Conversation

@kashif
Copy link
Copy Markdown
Collaborator

@kashif kashif commented Sep 2, 2025

What does this PR do?

Add example and docs for CP SFT training.

@kashif kashif requested a review from lewtun September 2, 2025 10:48
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment thread docs/source/reducing_memory_usage.md Outdated

**Option 1: Using SFTConfig**

**With Wrapped Strategy:**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I recommend not mentionning "wrapped" in the documentation. I feel like this is a very advanced use, and it somewhat distracts from the message of this section.

Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
kashif and others added 7 commits September 3, 2025 09:44
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
@kashif
Copy link
Copy Markdown
Collaborator Author

kashif commented Sep 3, 2025

i'll undo my change

Copy link
Copy Markdown
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

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

Nice doc! Overall LGTM with @qgallouedec comments about avoiding the wrapped example

Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
from trl import SFTConfig

training_args = SFTConfig(
max_seq_length=2048, # Long sequence length
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we can make this truly long like 16384 tokens?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment thread docs/source/reducing_memory_usage.md Outdated

#### Accelerate Configuration

Create an accelerate config file (e.g. `context_parallel_config.yaml` for 2 GPUs):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if it makes sense to have a copy of this in accelerate_configs/fsdp2_cp.yaml so there's a standard reference people can work from? If you agree, I'd make it to run on 8 GPUs which is the default for our other configs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok yes good idea with 8 gpus

Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
@kashif
Copy link
Copy Markdown
Collaborator Author

kashif commented Sep 3, 2025

still needs huggingface/transformers#40619

kashif and others added 3 commits September 4, 2025 12:56
Co-authored-by: Sergio Paniego Blanco <sergiopaniegoblanco@gmail.com>
Co-authored-by: Sergio Paniego Blanco <sergiopaniegoblanco@gmail.com>
@kashif
Copy link
Copy Markdown
Collaborator Author

kashif commented Sep 4, 2025

@qgallouedec forgot to checkin the yaml... try now

Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
kashif and others added 3 commits September 4, 2025 17:31
Co-authored-by: Sergio Paniego Blanco <sergiopaniegoblanco@gmail.com>
Co-authored-by: Sergio Paniego Blanco <sergiopaniegoblanco@gmail.com>
Co-authored-by: Sergio Paniego Blanco <sergiopaniegoblanco@gmail.com>
Comment thread docs/source/reducing_memory_usage.md Outdated
@qgallouedec qgallouedec changed the title [docs] add CP docs 🥓 [docs] add CP docs Sep 9, 2025
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Comment thread docs/source/reducing_memory_usage.md Outdated
Copy link
Copy Markdown
Member

@qgallouedec qgallouedec left a comment

Choose a reason for hiding this comment

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

lgtm!!

Comment thread docs/source/reducing_memory_usage.md Outdated

#### Training Configuration

You can configure context parallelism training either programmatically or via command line:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just realized that this is not accurate, as you always have to pass the accelerate config. I'll refactor a bit

@qgallouedec qgallouedec merged commit 1b799a2 into main Sep 9, 2025
2 checks passed
@qgallouedec qgallouedec deleted the cp-docs branch September 9, 2025 03:46
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.

5 participants