Add Parallelism getter property to Accelerator class#3703
Add Parallelism getter property to Accelerator class#3703S1ro1 merged 4 commits intohuggingface:mainfrom
Conversation
Signed-off-by: WoosungMyung <dntjd517@naver.com>
Signed-off-by: WoosungMyung <dntjd517@naver.com>
src/accelerate/accelerator.py
Outdated
| Returns the local rank for shard-based data parallelism (e.g., FSDP). | ||
| Raises an error if not enabled. | ||
| """ | ||
| if not self.parallelism_config or not self.parallelism_config.dp_shard_enabled: |
There was a problem hiding this comment.
I think we want to adapt this a little, sorry for wrong assumption yesterday. I'd say the best thing UX wise is: return the rank if enabled, return 0 if parallelism config is enabled but no parallelism {x} is enabled (in this case all ranks are esentially 0) and raise a RuntimeError if neither of these 2 met. Do you think that is reasonable?
There was a problem hiding this comment.
@S1ro1
Thanks for your fast feedback! I think it makes sense that parallelism configuration is set & parallelism is not enable, it should return rank 0 for all process. I'd appreciate it if you could take a look and let me know your thoughts.
Signed-off-by: WoosungMyung <dntjd517@naver.com>
|
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. |
|
@S1ro1 |
We thank you for the contribution and look forward to more 🤗 Pleasure to be of help! |
This PR adds a @Property method for simply get parallelism rank in HF Accelerate.
Motivation:
Changes:
rankproperty in accelerator.pyThis PR is from issue #3702 with S1ro1.
Let me know if there’s anything I should improve.
Thanks a lot for giving opportunity for this amazing PJ!