| 1 |
# Copyright 2024 The HuggingFace Team. All rights reserved. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
from manim import * |
| 16 |
|
| 17 |
class Stage4(Scene): |
| 18 |
def construct(self): |
| 19 |
|
| 20 |
step_1 = MarkupText( |
| 21 |
f"To understand the next part fully, let's define two terms,\n<span fgcolor='{RED}'>`batch_size`</span> and <span fgcolor='{BLUE}'>`global_batch_size`</span>:", |
| 22 |
font_size=18 |
| 23 |
) |
| 24 |
step_1.move_to([0, 1.5, 0]) |
| 25 |
# <span fgcolor='{YELLOW}'>ā</span> |
| 26 |
step_2 = MarkupText( |
| 27 |
f"\n\nā <span fgcolor='{RED}'>`batch_size`</span>: \n\tThis will be defined as the batch size seen on a given\n\t*individual* GPU", |
| 28 |
font_size=18, |
| 29 |
).next_to(step_1, direction=DOWN, aligned_edge=LEFT) |
| 30 |
|
| 31 |
step_3 = MarkupText( |
| 32 |
f"\n\nā <span fgcolor='{BLUE}'>`global_batch_size`</span>:\n\tThis will be defined as the *total* number of\n\tdifferent items seen in the dataset, across all GPUs", |
| 33 |
font_size=18, |
| 34 |
).next_to(step_2, direction=DOWN, aligned_edge=LEFT) |
| 35 |
|
| 36 |
step_4 = MarkupText( |
| 37 |
f"\n\nSo if we have a dataset of 64 items, 8 GPUs, \nand a `batch_size` of 8, each *step* will go through\nthe entire dataset one time as 8*8=64", |
| 38 |
font_size=18, |
| 39 |
).next_to(step_3, direction=DOWN, aligned_edge=LEFT) |
| 40 |
self.play( |
| 41 |
Write(step_1, run_time=4), |
| 42 |
) |
| 43 |
self.play( |
| 44 |
Write(step_2, run_time=4) |
| 45 |
) |
| 46 |
self.play( |
| 47 |
Write(step_3, run_time=4) |
| 48 |
) |
| 49 |
self.play( |
| 50 |
Write(step_4, run_time=6) |
| 51 |
) |
| 52 |
self.wait() |