Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expound PartialState docstring #2589

Merged
merged 10 commits into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/accelerate/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ class PartialState:
control. Designed to be used when only process control and device execution states are needed. Does *not* need to
be initialized from `Accelerator`.

Args:
cpu (`bool`, *optional*):
Whether or not to force the script to execute on CPU. Will ignore any accelerators available if set to
`True` and force the execution on the CPU.
kwargs (additional keyword arguments, *optional*):
Additional keyword arguments to pass to the relevent `init_process_group` function. Valid `kwargs` can be
found in [`utils.InitProcessGroupKwargs`]. See the example section for detailed usage.

**Available attributes:**

- **device** (`torch.device`) -- The device to use.
Expand All @@ -127,6 +135,15 @@ class PartialState:
- **is_main_process** (`bool`) -- Whether or not the current process is the main one.
- **is_local_main_process** (`bool`) -- Whether or not the current process is the main one on the local node.
- **debug** (`bool`) -- Whether or not the current script is being run in debug mode.

Example:
```python
from accelerate.utils import InitProcessGroupKwargs

# To include `InitProcessGroupKwargs`, init then call `.to_kwargs()`
kwargs = InitProcessGroupKwargs(...).to_kwargs()
state = PartialState(**kwargs)
```
"""

_shared_state = SharedDict()
Expand Down
Loading