-
Notifications
You must be signed in to change notification settings - Fork 66
add support to metrics calculation #195
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 support to metrics calculation #195
Conversation
briancoutinho
left a comment
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.
Left some suggestions. @shengfukevin also saw black formatting issues, which we would need to fix to pass linter, Sheng is there someway we can share the lint suggestions? Let's do that after next iteration of the PR
| return retObj | ||
|
|
||
| def barrier_all_ranks(self): | ||
| dist.barrier(device_ids=[self.get_device().index] if dist.get_backend() == "nccl" else None) |
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.
question, why is this changed from the simplle barrie() before?
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 is new added util function, not exist before. To make all dist API call be encapsulated in backend module.
Another point is, if not specify device id, there is warning in log to use GPU0 for barrier. So we should take here as a reference.
| device_ids=( |
| } | ||
|
|
||
| # refer to: https://github.com/NVIDIA/nccl-tests/blob/master/doc/PERFORMANCE.md | ||
| _busbw_correction_factors_tbl: Dict[str, Callable[[int], float]] = { |
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.
nit maybe call these functions?
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.
_busbw_correction_factors_fns
| return correction_factor_func(group_size) | ||
|
|
||
| def calculate_bw_(trace_data): | ||
| nccl_events = [i for i in trace_data['traceEvents'] if i.get('cat', '') == 'kernel' and i['name'].startswith('ncclDevKernel_')] |
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.
nit could be startswith('nccl') for older nccl kernel names that did not start with Device
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.
You mean, older nccl kernel in latest nccl verion? Is there some examples? I don't assume we need to be compatible with old nccl version. But if new nccl version has older nccl kernels, we need to consider refine this.
| return correction_factor_func(group_size) | ||
|
|
||
| def calculate_bw_(trace_data): | ||
| nccl_events = [i for i in trace_data['traceEvents'] if i.get('cat', '') == 'kernel' and i['name'].startswith('ncclDevKernel_')] |
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.
to save memory consider using generator
nccl_events = (e for e in trace_data['traceEvents'] if e.get('cat', '') == 'kernel' and e['name'].startswith('ncclDevKernel_'))
| evt['args']['busbw (GB/sec)'] = busbw | ||
| evt['args']['busbw_factor'] = busbw_factor | ||
| except ValueError as e: | ||
| logger.error('Error processing event: %s', e) |
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.
we could events processing that failed and print at bottom
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.
Done
| if not len(nccl_events): | ||
| return 0 | ||
|
|
||
| total_data_size = sum([_calculate_event_data_size(evt) * _get_event_busbw_factor(evt) for evt in nccl_events]) |
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.
nit this will work
total_data_size = sum(_calculate_event_data_size(evt) * _get_event_busbw_factor(evt) for evt in nccl_events)
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.
Done
|
|
||
| return total_data_size / (end_time_point - begin_time_point - total_idle_time) / 1e3 | ||
|
|
||
| def pick_iter_e2e_time_(trace_data, tl): |
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.
please add some doc on this function, not clear what it is doing, and what is tl
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.
done
|
|
||
| total_data_size = sum([_calculate_event_data_size(evt) * _get_event_busbw_factor(evt) for evt in nccl_events]) | ||
|
|
||
| time_range_tree = IntervalTree([Interval(evt['ts'], evt['ts'] + evt['dur']) for evt in nccl_events]) |
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.
Today i learned Interval tree class nice :)
|
|
||
| # dump summary report | ||
| with open(os.path.join(report_dir, 'profiler_trace_summary_report.txt'), 'w', encoding='utf-8') as f: | ||
| f.write(f'avg. E2ETime of iters among all ranks: {sum(iter_e2e_time) / len(iter_e2e_time) / 1e3 :.3f} ms\n') |
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.
You can consider using tabulate library since you are considering adding dependency.
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Differential Revision: D68038126 Pulled By: shengfukevin
|
@briancoutinho @sanshang-nv @TaekyungHeo , I copied this PR and imported to Meta, this is the new diff #196. Please update on PR 196. I have two issues that need fix:
|
|
|
PR196 seems not include this commit: 57f619e |
|
Hi, @shengfukevin
|
|
@sanshang-nv, after took another look, MetaProfiler seems an overkill to provide a Meta internal profiler. The difference between MetaProfiler and public profiler are 1. the supported activities 2. the call back function when trace is ready. Inside Meta, we already have fb directory, it seems redundant to have vendor_internal directory. When you create the profiler, can you just pass in different activities and callback function like the following: try: except ImportError: if has_internal_libs: Thanks |
I don't think so.
I don't find Then, we remove the usage to these 3 fb functions, right? Because this is black box to me, it's hard to decide which implementation is the best from my side.
Considering add this option back. |
|
ok, then let's keep vendor_internal. fb.internal got filtered out when export param from meta. You can call from param_bench.et_replay.fb.internals import ( inside vendor_internal/fb_internal.py Remove fbInitProfiler, Thanks |
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Test Plan: /usr/local/fbcode/platform010/bin/mpirun -np 2 buck2 run mode/opt param_bench/et_replay:comm_replay -- --trace-path manifold://pytorch_execution_trace/tree/traces/shengfu/icvr --enable-profiler --output-path work-dir Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin
Summary: Add support to metrics calculation. 1. Iteration E2E time 2. bandwidth This is the copy of #195 for importing it into Meta. Pull Request resolved: #197 Test Plan: /usr/local/fbcode/platform010/bin/mpirun -np 2 buck2 run mode/opt param_bench/et_replay:comm_replay -- --trace-path manifold://pytorch_execution_trace/tree/traces/shengfu/icvr --enable-profiler --output-path work-dir Reviewed By: briancoutinho Differential Revision: D69155629 Pulled By: shengfukevin fbshipit-source-id: d3b21731cd2edfd5a8c570421cbd96cde780fa59
summary
Add support to metrics calculation.
test plan