-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix comms logger KeyError when log_name is omitted #8267
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
base: master
Are you sure you want to change the base?
Changes from all commits
657bd1a
b12c086
1f95164
cbbf47b
2ceaa9c
59e91c0
3d200a0
7f2bc2d
b2d7396
0d6c92d
90d37a2
9a92148
6e53430
9a6a995
09ec337
7c5f496
02b5350
7ad8e53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
|
|
||
| import torch | ||
| from torch.distributed import GradBucket # noqa: F401 | ||
| import inspect | ||
| import os | ||
| from typing import Any, Optional, TYPE_CHECKING | ||
|
|
||
|
|
@@ -104,16 +105,23 @@ def configure( | |
|
|
||
| # Logging wrapper for timing ops | ||
| def timed_op(func): | ||
| default_log_name = get_default_args(func).get('log_name', func.__name__) | ||
| # Cache the signature to avoid inspecting it on every communication call. | ||
| func_signature = inspect.signature(func) | ||
|
|
||
| def log_wrapper(*args, **kwargs): | ||
| should_profile = False | ||
| # Add enabled flag so that overhead to each comm op is two if conditions at most | ||
| if comms_logger.enabled: | ||
| if ('prof' in kwargs | ||
| and kwargs['prof']) or comms_logger.prof_all or ('log_name' in kwargs | ||
| and kwargs['log_name'] in comms_logger.prof_ops): | ||
| # Need func args for their defaults | ||
| func_args = get_default_args(func) | ||
| func_args.update(kwargs) | ||
| bound_args = func_signature.bind_partial(*args, **kwargs) | ||
| bound_args.apply_defaults() | ||
| func_args = bound_args.arguments | ||
| selected_log_name = func_args.get('log_name', default_log_name) | ||
| should_profile = (func_args.get('prof', False) or comms_logger.prof_all | ||
| or selected_log_name in comms_logger.prof_ops) | ||
| if should_profile: | ||
| # Ops that do not declare a log_name are logged under their own name | ||
| func_args['log_name'] = selected_log_name | ||
| msg_size = get_msg_size_from_args(func, *args, **kwargs) | ||
| log_name = get_debug_log_name(func_args, comms_logger.debug) | ||
| timers(log_name).start() | ||
|
|
@@ -127,8 +135,7 @@ def log_wrapper(*args, **kwargs): | |
| # If we're using MPI, we can't simply sync the stream | ||
| if cdb.using_mpi: | ||
| cdb.barrier() | ||
| if ('prof' in kwargs and kwargs['prof']) or comms_logger.prof_all or ( | ||
| 'log_name' in kwargs and kwargs['log_name'] in comms_logger.prof_ops): | ||
| if should_profile: | ||
| log_name = get_debug_log_name(func_args, comms_logger.debug) | ||
| raw_name = func.__name__ | ||
| timers(log_name).stop() | ||
|
|
@@ -230,7 +237,13 @@ def broadcast(tensor, src, group=None, async_op=False, prof=False, log_name='bro | |
|
|
||
|
|
||
| @timed_op | ||
| def broadcast_object_list(object_list, src, group=None, device=None): | ||
| def broadcast_object_list(object_list, | ||
| src, | ||
| group=None, | ||
| device=None, | ||
| prof=False, | ||
| log_name='broadcast_object_list', | ||
| debug=get_caller_func()): | ||
| global cdb | ||
| return cdb.broadcast_object_list(object_list=object_list, src=src, group=group, device=device) | ||
|
|
||
|
|
@@ -364,7 +377,13 @@ def all_to_all_single(output, | |
|
|
||
|
|
||
| @timed_op | ||
| def all_to_all(output_tensor_list, input_tensor_list, group=None, async_op=False): | ||
| def all_to_all(output_tensor_list, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be added to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed — positional |
||
| input_tensor_list, | ||
| group=None, | ||
| async_op=False, | ||
| prof=False, | ||
| log_name='all_to_all', | ||
| debug=get_caller_func()): | ||
| global cdb | ||
| return cdb.all_to_all(output_tensor_list, input_tensor_list, group=group, async_op=async_op) | ||
|
|
||
|
|
||
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 should be added to
calc_bw_log.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.
profandlog_namewill be ignored if they are passed as positional args.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.
Fixed — added
broadcast_object_listandall_to_alltocalc_bw_log. Thanks!