This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
update previous flaky naive engine test #15651
Merged
Merged
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cc0efb8
update precious flaky naive engine test
Zha0q1 b52662b
retriever tests
Zha0q1 af6931c
retrigger tests
Zha0q1 ae288eb
retrigger tests
Zha0q1 2947358
retrigger tests
Zha0q1 62377d0
retrigger tests
Zha0q1 ca354af
retrigger tests
Zha0q1 59bc518
Update test_profiler.py
Zha0q1 42c54b7
retrigger tests
Zha0q1 7301151
retrigger tests
Zha0q1 583f2ef
retrigger tests
Zha0q1 e13825f
retrigger tests
Zha0q1 39ae04f
retrigger tests
Zha0q1 c6930bc
retrigger tests
Zha0q1 4c9b3d6
Update test_profiler.py
Zha0q1 beb4169
retrigger tests
Zha0q1 49b25bb
retrigger tests
Zha0q1 e8a25a9
retrigger tests
Zha0q1 0ca0dc2
retrigger tests
Zha0q1 6065642
Update test_profiler.py
Zha0q1 f88b7b0
retrigger tests
Zha0q1 96c7342
Update test_profiler.py
Zha0q1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,6 +275,8 @@ def test_aggregate_duplication(): | |
file_name = 'test_aggregate_duplication.json' | ||
enable_profiler(profile_filename = file_name, run=True, continuous_dump=True, \ | ||
aggregate_stats=True) | ||
# clear aggregate stats | ||
profiler.dumps(reset = True) | ||
inp = mx.nd.zeros(shape=(100, 100)) | ||
y = mx.nd.sqrt(inp) | ||
inp = inp + 1 | ||
|
@@ -332,6 +334,8 @@ def create_operator(self, ctx, in_shapes, in_dtypes): | |
file_name = 'test_custom_operator_profiling.json' | ||
enable_profiler(profile_filename = file_name, run=True, continuous_dump=True,\ | ||
aggregate_stats=True) | ||
# clear aggregate stats | ||
profiler.dumps(reset = True) | ||
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. nit: remove space around '='. |
||
x = mx.nd.array([0, 1, 2, 3]) | ||
x.attach_grad() | ||
with mx.autograd.record(): | ||
|
@@ -347,8 +351,15 @@ def create_operator(self, ctx, in_shapes, in_dtypes): | |
and 'MySigmoid::_zeros' in target_dict['Time']['Custom Operator'] | ||
profiler.set_state('stop') | ||
|
||
def test_custom_operator_profiling_multiple_custom_ops_imperative(seed = None, \ | ||
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.
|
||
mode = 'imperative', file_name = None): | ||
def check_custom_operator_profiling_multiple_custom_ops_output(debug_str): | ||
target_dict = json.loads(debug_str) | ||
assert 'Time' in target_dict and 'Custom Operator' in target_dict['Time'] \ | ||
and 'MyAdd1::pure_python' in target_dict['Time']['Custom Operator'] \ | ||
and 'MyAdd2::pure_python' in target_dict['Time']['Custom Operator'] \ | ||
and 'MyAdd1::_plus_scalar' in target_dict['Time']['Custom Operator'] \ | ||
and 'MyAdd2::_plus_scalar' in target_dict['Time']['Custom Operator'] | ||
|
||
def custom_operator_profiling_multiple_custom_ops(seed, mode, file_name): | ||
class MyAdd(mx.operator.CustomOp): | ||
def forward(self, is_train, req, in_data, out_data, aux): | ||
self.assign(out_data[0], req[0], in_data[0] + 1) | ||
|
@@ -392,65 +403,44 @@ def infer_shape(self, in_shape): | |
def create_operator(self, ctx, shapes, dtypes): | ||
return MyAdd() | ||
|
||
if file_name is None: | ||
file_name = 'test_custom_operator_profiling_multiple_custom_ops_imperative.json' | ||
enable_profiler(profile_filename = file_name, run=True, continuous_dump=True,\ | ||
aggregate_stats=True) | ||
# clear aggregate stats | ||
profiler.dumps(reset = True) | ||
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. nit: remove space around '='. |
||
inp = mx.nd.zeros(shape=(100, 100)) | ||
if mode == 'imperative': | ||
x = inp + 1 | ||
y = mx.nd.Custom(inp, op_type='MyAdd1') | ||
z = mx.nd.Custom(inp, op_type='MyAdd2') | ||
elif mode == 'symbolic': | ||
a = mx.symbol.Variable('a') | ||
b = a + 1 | ||
c = mx.symbol.Custom(data=a, op_type='MyAdd1') | ||
d = mx.symbol.Custom(data=a, op_type='MyAdd2') | ||
b = mx.symbol.Custom(data=a, op_type='MyAdd1') | ||
c = mx.symbol.Custom(data=a, op_type='MyAdd2') | ||
b.bind(mx.cpu(), {'a': inp}).forward() | ||
c.bind(mx.cpu(), {'a': inp}).forward() | ||
d.bind(mx.cpu(), {'a': inp}).forward() | ||
mx.nd.waitall() | ||
profiler.dump(False) | ||
debug_str = profiler.dumps(format = 'json') | ||
target_dict = json.loads(debug_str) | ||
''' | ||
We are calling _plus_scalar within MyAdd1 and MyAdd2 and outside both the custom | ||
operators, so in aggregate stats we should have three different kinds of | ||
_plus_scalar under domains "Custom Operator" and "operator" | ||
''' | ||
assert 'Time' in target_dict and 'Custom Operator' in target_dict['Time'] \ | ||
and 'MyAdd1::pure_python' in target_dict['Time']['Custom Operator'] \ | ||
and 'MyAdd2::pure_python' in target_dict['Time']['Custom Operator'] \ | ||
and 'MyAdd1::_plus_scalar' in target_dict['Time']['Custom Operator'] \ | ||
and 'MyAdd2::_plus_scalar' in target_dict['Time']['Custom Operator'] \ | ||
and '_plus_scalar' not in target_dict['Time']['Custom Operator'] \ | ||
and 'operator' in target_dict['Time'] \ | ||
and '_plus_scalar' in target_dict['Time']['operator'] | ||
check_custom_operator_profiling_multiple_custom_ops_output(debug_str) | ||
profiler.set_state('stop') | ||
|
||
@unittest.skip("Flaky test https://github.com/apache/incubator-mxnet/issues/15406") | ||
|
||
def test_custom_operator_profiling_multiple_custom_ops_symbolic(): | ||
run_in_spawned_process(test_custom_operator_profiling_multiple_custom_ops_imperative, \ | ||
{'MXNET_EXEC_BULK_EXEC_INFERENCE' : 0, \ | ||
'MXNET_EXEC_BULK_EXEC_TRAIN' : 0}, \ | ||
'symbolic', \ | ||
custom_operator_profiling_multiple_custom_ops(None, 'symbolic', \ | ||
'test_custom_operator_profiling_multiple_custom_ops_symbolic.json') | ||
|
||
@unittest.skip("Flaky test https://github.com/apache/incubator-mxnet/issues/15406") | ||
def test_custom_operator_profiling_multiple_custom_ops_imperative(): | ||
custom_operator_profiling_multiple_custom_ops(None, 'imperative', \ | ||
'test_custom_operator_profiling_multiple_custom_ops_imperative.json') | ||
|
||
def test_custom_operator_profiling_naive_engine(): | ||
# run the three tests above using Naive Engine | ||
run_in_spawned_process(test_custom_operator_profiling, \ | ||
{'MXNET_ENGINE_TYPE' : "NaiveEngine"}, \ | ||
'test_custom_operator_profiling_naive.json') | ||
run_in_spawned_process(test_custom_operator_profiling_multiple_custom_ops_imperative, \ | ||
{'MXNET_ENGINE_TYPE' : "NaiveEngine"}, \ | ||
'imperative', \ | ||
run_in_spawned_process(custom_operator_profiling_multiple_custom_ops, \ | ||
{'MXNET_ENGINE_TYPE' : "NaiveEngine"}, 'imperative', \ | ||
'test_custom_operator_profiling_multiple_custom_ops_imperative_naive.json') | ||
run_in_spawned_process(test_custom_operator_profiling_multiple_custom_ops_imperative, \ | ||
{'MXNET_ENGINE_TYPE' : "NaiveEngine", \ | ||
'MXNET_EXEC_BULK_EXEC_INFERENCE' : 0, \ | ||
'MXNET_EXEC_BULK_EXEC_TRAIN' : 0}, \ | ||
'symbolic', \ | ||
run_in_spawned_process(custom_operator_profiling_multiple_custom_ops, \ | ||
{'MXNET_ENGINE_TYPE' : "NaiveEngine"}, 'symbolic', \ | ||
'test_custom_operator_profiling_multiple_custom_ops_symbolic_naive.json') | ||
|
||
if __name__ == '__main__': | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: remove space around '='.
FYI: http://google.github.io/styleguide/pyguide.html#36-whitespace