Skip to content

Commit 56c1a61

Browse files
committed
Update header of main.py
Signed-off-by: Fabrice Normandin <[email protected]>
1 parent 228a537 commit 56c1a61

File tree

2 files changed

+42
-48
lines changed

2 files changed

+42
-48
lines changed

docs/examples/LLMs/accelerate_example/README.rst

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,26 @@ Click here to see `the code for this example
128128
"""HuggingFace Example from https://github.com/huggingface/accelerate/blob/main/examples/by_feature/checkpointing.py
129129
130130
Differences with the reference example:
131-
- Uses the slurm job ID
132-
131+
- Supports checkpointing using the slurm job ID as part of the checkpoint directory
132+
133+
This is a fully working simple example to use Accelerate,
134+
specifically showcasing the checkpointing capability,
135+
and builds off the `nlp_example.py` script.
136+
This example trains a Bert base model on GLUE MRPC
137+
in any of the following settings (with the same script):
138+
- single CPU or single GPU
139+
- multi GPUS (using PyTorch distributed mode)
140+
- (multi) TPUs
141+
- fp16 (mixed-precision) or fp32 (normal precision)
142+
143+
To help focus on the differences in the code, building `DataLoaders`
144+
was refactored into its own function.
145+
New additions from the base script can be found quickly by
146+
looking for the # New Code # tags
147+
148+
To run it in each of these various modes, follow the instructions
149+
in the readme for examples:
150+
https://github.com/huggingface/accelerate/tree/main/examples
133151
"""
134152
135153
# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
@@ -176,28 +194,7 @@ Click here to see `the code for this example
176194
)
177195
from transformers.optimization import get_linear_schedule_with_warmup
178196
from accelerate.logging import get_logger
179-
########################################################################
180-
# This is a fully working simple example to use Accelerate,
181-
# specifically showcasing the checkpointing capability,
182-
# and builds off the `nlp_example.py` script.
183-
#
184-
# This example trains a Bert base model on GLUE MRPC
185-
# in any of the following settings (with the same script):
186-
# - single CPU or single GPU
187-
# - multi GPUS (using PyTorch distributed mode)
188-
# - (multi) TPUs
189-
# - fp16 (mixed-precision) or fp32 (normal precision)
190-
#
191-
# To help focus on the differences in the code, building `DataLoaders`
192-
# was refactored into its own function.
193-
# New additions from the base script can be found quickly by
194-
# looking for the # New Code # tags
195-
#
196-
# To run it in each of these various modes, follow the instructions
197-
# in the readme for examples:
198-
# https://github.com/huggingface/accelerate/tree/main/examples
199-
#
200-
########################################################################
197+
201198
202199
MAX_GPU_BATCH_SIZE = 16
203200
EVAL_BATCH_SIZE = 32

docs/examples/LLMs/accelerate_example/main.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
"""HuggingFace Example from https://github.com/huggingface/accelerate/blob/main/examples/by_feature/checkpointing.py
22
33
Differences with the reference example:
4-
- Uses the slurm job ID
5-
4+
- Supports checkpointing using the slurm job ID as part of the checkpoint directory
5+
6+
This is a fully working simple example to use Accelerate,
7+
specifically showcasing the checkpointing capability,
8+
and builds off the `nlp_example.py` script.
9+
This example trains a Bert base model on GLUE MRPC
10+
in any of the following settings (with the same script):
11+
- single CPU or single GPU
12+
- multi GPUS (using PyTorch distributed mode)
13+
- (multi) TPUs
14+
- fp16 (mixed-precision) or fp32 (normal precision)
15+
16+
To help focus on the differences in the code, building `DataLoaders`
17+
was refactored into its own function.
18+
New additions from the base script can be found quickly by
19+
looking for the # New Code # tags
20+
21+
To run it in each of these various modes, follow the instructions
22+
in the readme for examples:
23+
https://github.com/huggingface/accelerate/tree/main/examples
624
"""
725

826
# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
@@ -49,28 +67,7 @@
4967
)
5068
from transformers.optimization import get_linear_schedule_with_warmup
5169
from accelerate.logging import get_logger
52-
########################################################################
53-
# This is a fully working simple example to use Accelerate,
54-
# specifically showcasing the checkpointing capability,
55-
# and builds off the `nlp_example.py` script.
56-
#
57-
# This example trains a Bert base model on GLUE MRPC
58-
# in any of the following settings (with the same script):
59-
# - single CPU or single GPU
60-
# - multi GPUS (using PyTorch distributed mode)
61-
# - (multi) TPUs
62-
# - fp16 (mixed-precision) or fp32 (normal precision)
63-
#
64-
# To help focus on the differences in the code, building `DataLoaders`
65-
# was refactored into its own function.
66-
# New additions from the base script can be found quickly by
67-
# looking for the # New Code # tags
68-
#
69-
# To run it in each of these various modes, follow the instructions
70-
# in the readme for examples:
71-
# https://github.com/huggingface/accelerate/tree/main/examples
72-
#
73-
########################################################################
70+
7471

7572
MAX_GPU_BATCH_SIZE = 16
7673
EVAL_BATCH_SIZE = 32

0 commit comments

Comments
 (0)