-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
Add kwargs to idist.barrier #2310
Conversation
…mentation update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @fco-dv! Just left a single comment
def _check_barrier_fn_kwargs(self, barrier_fn: Callable, kwargs_dict: Dict[str, Any]) -> Dict[str, Any]: | ||
bnd_keys = set() | ||
for param in signature(barrier_fn).parameters.values(): | ||
if param.kind == param.POSITIONAL_OR_KEYWORD: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we simplify this a bit? I think we can do this inside the loop, for example in the else we delete the key directly maybe? and make a bool flag maybe and raise the warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comment, @KickItLikeShika , I will try to simplify this
if param.kind == param.POSITIONAL_OR_KEYWORD: | ||
bnd_keys.add(param.name) | ||
extra_keys = sorted(list(set(kwargs_dict) - bnd_keys)) | ||
fn_params_name = set( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m wondering whether comprehension list would be more simple.
I think the method bind
of the class Signature
could help.
def barrier(self) -> None: | ||
def barrier(self, **kwargs: Any) -> None: | ||
kwargs = self._check_barrier_fn_kwargs(barrier_fn=hvd.allreduce, kwargs_dict=kwargs) | ||
if "tensor" in kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why redefining these arguments and not simply avoid it ? IMO it’s confusing.
# https://github.com/horovod/horovod/issues/159#issuecomment-424834603 | ||
# hvd.allreduce(torch.tensor(0, device=self.device()), name="barrier") | ||
hvd.allreduce(torch.tensor(0, device="cpu"), name="barrier") | ||
hvd.allreduce(tensor=torch.tensor(0, device="cpu"), name="barrier", **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that a barrier function was recently introduced. We could use it in a next PR (and handle older version).
xm.rendezvous("barrier") | ||
def barrier(self, **kwargs: Any) -> None: | ||
kwargs = self._check_barrier_fn_kwargs(barrier_fn=xm.rendezvous, kwargs_dict=kwargs) | ||
if "tag" in kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark than above
|
||
- | "horovod" : ``average`` (default, None), ``compression`` (default, Compression.none), | ||
| ``op`` (default, None), ``prescale_factor`` (default, 1.0), ``postscale_factor`` (default, 1.0), | ||
| ``process_set`` (default, global_process_set). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition is confusing IMO
@@ -275,8 +277,24 @@ def _do_all_gather(self, tensor: torch.Tensor) -> torch.Tensor: | |||
def _do_broadcast(self, tensor: torch.Tensor, src: int) -> torch.Tensor: | |||
pass | |||
|
|||
def _check_barrier_fn_kwargs(self, barrier_fn: Callable, kwargs_dict: Dict[str, Any]) -> Dict[str, Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is more general than its name suggests. You did a signature checker. It could be called check_method_args
and note that type could be also checked.
Hey @fco-dv I left a few comments. |
* Add doctests for RMSE and MeanPairwiseDistance * Add doctests for RMSE and MeanPairwiseDistance * Make metric name consistent
Co-authored-by: Desroziers <[email protected]>
…actionalAbsoluteError``, ``CanberraMetric``, ``GeometricMeanAbsoluteError``) (pytorch#2323) * added doctest for contrib regression metrics * removed Engine definition and variable name changes * added import of contrib.regression Co-authored-by: Sylvain Desroziers <[email protected]>
* pytorch#2313 fix bug in StateParamScheduler attach method * pytorch#2313 add assert if KeyError is raised * pytorch#2313 update test_multiple_scheduler_with_save_history Co-authored-by: vfdev <[email protected]>
Co-authored-by: Desroziers <[email protected]>
* pytorch#2090 make work EMAHandler with StateParamScheduler * pytorch#2295 update docstring for parameter `create_new` * pytorch#2295 fixing attach method logic and update associated tests * pytorch#2295 fix unused import / remove useless test * pytorch#2295 fix tests * pytorch#2295 rm else statement * Update ignite/handlers/state_param_scheduler.py Co-authored-by: vfdev <[email protected]> * Update ignite/handlers/state_param_scheduler.py Co-authored-by: vfdev <[email protected]> * pytorch#2295 update tests assert messages * pytorch#2295 update tests, add working example with EMAHandler Co-authored-by: vfdev <[email protected]>
Fixes #2213
Description:
Add kwargs to idist.barrier for
native
,xla
andhorovod
backends. Need to add relevant example code.Check list: