-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support PPE profiling for Local
#340
Conversation
4974a73
to
df1c1d3
Compare
Can be specified in the `trace` argument when creating a Local() instance.
df1c1d3
to
8fef411
Compare
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.
Overall LGTM. I have one minor suggestion.
setup.py
Outdated
@@ -52,7 +52,7 @@ | |||
packages=find_packages(), | |||
package_data={'pfio': package_data}, | |||
extras_require={ | |||
'test': ['pytest', 'flake8', 'autopep8', 'parameterized', 'isort', 'moto[server]>=5.0.0', 'numpy', 'mypy'], |
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 can also place the pytorch-pfn-extras
package under the extras_require
section by adding new presets (e.g., trace
), not only for testing purposes.
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.
Agree. We'd rather add something like trace
than adding the dependency to test
. PFIO users shall be using profiling without this extra requires and will be installing PFIO with pip install pfio
. In that case, PPE won't be installed even though they need it.
@kuenishi Could you take a look? Please let us know if you have any comments on the tag naming rule and the granularity of the tests. |
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.
The Python implementation itself looks good, but I have a few request to align with current style and options.
setup.py
Outdated
@@ -52,7 +52,7 @@ | |||
packages=find_packages(), | |||
package_data={'pfio': package_data}, | |||
extras_require={ | |||
'test': ['pytest', 'flake8', 'autopep8', 'parameterized', 'isort', 'moto[server]>=5.0.0', 'numpy', 'mypy'], |
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.
Agree. We'd rather add something like trace
than adding the dependency to test
. PFIO users shall be using profiling without this extra requires and will be installing PFIO with pip install pfio
. In that case, PPE won't be installed even though they need it.
tests/v2_tests/test_local.py
Outdated
@@ -291,6 +293,45 @@ def test_from_url_create_option(self): | |||
from_url(path, create=True) | |||
assert os.path.exists(path) and os.path.isdir(path) | |||
|
|||
def test_ppe_profiling(self): |
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 don't extend the TestLocal(unittest.TestCase)
class. We're slowly moving on from the unitest
style, to a more pytest-like style where each test is defined as a single and independent function (sometimes with fixtures or parameterized). Please refer to test_s3.py
.
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.
Changed to not use TestLocal(unittest.TestCase)
.
Currently, foo.txt
is generated in the directory where pytest runs, do you want to use a different path? (e.g. /tmp/...
)
pfio/v2/local.py
Outdated
@@ -4,9 +4,54 @@ | |||
import shutil | |||
from typing import Optional | |||
|
|||
try: |
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.
Refer to: #326 (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.
Split into pfio/v2/_profiler.py
and changed to import from _profiler.py
.
4301abd
to
87e3eaf
Compare
setup.py
Outdated
@@ -52,11 +52,12 @@ | |||
packages=find_packages(), | |||
package_data={'pfio': package_data}, | |||
extras_require={ | |||
'test': ['pytest', 'flake8', 'autopep8', 'parameterized', 'isort', 'moto[server]>=5.0.0', 'numpy', 'mypy'], | |||
'test': ['pytest', 'flake8', 'autopep8', 'parameterized', 'isort', 'moto[server]>=5.0.0', 'numpy', 'mypy', 'pytorch-pfn-extras'], |
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.
As we discussed offline, PPE shouldn't be here but tests must be switched in the test code using something like skipif.
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.
Changed to using importorskip()
to skip if no ppe.
- no ppe
test_local.py ................s
- exist ppe
test_local.py .................
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 may also need to tweak the tox.ini to enable CI testing for the tracing code, which we're adding this PR if we remove PPE from the test section in setup.py:
Lines 4 to 20 in b874d49
[testenv] | |
deps = .[test] | |
skipsdist = True | |
commands = | |
flake8 pfio tests | |
autopep8 -r pfio tests --diff | |
isort . --check --diff | |
mypy pfio | |
pytest -W error::deprecation.UnsupportedWarning tests -s -v | |
[testenv:doc] | |
deps = .[doc] | |
skipsdist = True | |
changedir = docs | |
commands = | |
make html | |
allowlist_externals=make |
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.
Good catch
87e3eaf
to
e6c128c
Compare
e6c128c
to
c40bdba
Compare
98259ec
to
0c1d1e1
Compare
Offline discussion summary: the code itself looks nice, but the example script at the issue description doesn't provide valid JSON file and I'm not sure how to verify the output JSON(-like) file by loading onto Chrome tracing. After a minimal script to test this patch provided, I'll revisit and retry validation. |
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 leave the summary of offline discussion with PPE developer why we don't need complete JSON file and it works fine without it.
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.
Ah, and don't forget to update tox.ini to include trace
option as @k5342 pointed out.
Offline discussion summary: Chrome Tracing does not require valid json and can be rendered with just ref. Trace Event Format
|
0c1d1e1
to
19f5bae
Compare
fix |
* Profiling with PPE * Profiling with PPE * Make mypy happy * Make flake8 happy * Make isort and mypy even happier * Support all methods * Align tag naming rule with PPE (module.Klass:method) * Support PPE tracing * Local: Support io class method * Add trace switching Can be specified in the `trace` argument when creating a Local() instance. * Split PPE methods * mypy: ignore ppe * add trace test * setup: add trace context * doc: add output tracer results tips --------- Co-authored-by: UENISHI Kota <[email protected]>
This PR resolves the
Local
task in #258Note
To enable tracing,
trace=True
must be added duringLocal()
initialization (orfrom_url()
).Sample program to check tracing
output
drawing of the output json file (
trace.json
) withchrome://tracing
is shown below