Skip to content

Add python stack tracing option on on-demand flow #80919

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

Closed
wants to merge 1 commit into from

Conversation

slgong-fb
Copy link
Contributor

Summary:
Changes:

  1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
  2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
  3. abstract class also changed.

Test Plan:

  1. launch a python test case with the following command for on-demand flow:
    echo -e "PYTHON_STACK_TRACE=true" > /tmp/scott_kineto.conf && dyno gputrace --gputrace_duration 300ms --gpuconf /tmp/scott_kineto.conf

  2. Then, we can see with_stack enabled as intended from output log:
    INFO:2022-06-27 15:00:16 1009443:1011716 kineto_client_interface.cpp:22] withStack : 1

Differential Revision: D37410204

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jul 5, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

As of commit 7f411f3 (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

slgong-fb added a commit to slgong-fb/kineto that referenced this pull request Jul 6, 2022
Summary:
X-link: pytorch/pytorch#80919

Pull Request resolved: pytorch#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Differential Revision: D37410204

fbshipit-source-id: b7ae9b49d87e58b84123c852ba79fe8e80aecbaf
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

slgong-fb added a commit to slgong-fb/kineto that referenced this pull request Jul 6, 2022
Summary:
X-link: pytorch/pytorch#80919

Pull Request resolved: pytorch#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Differential Revision: D37410204

fbshipit-source-id: 67061846905eeb44aa38f70654731acfde7aa8ad
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

slgong-fb added a commit to slgong-fb/kineto that referenced this pull request Jul 6, 2022
Summary:
X-link: pytorch/pytorch#80919

Pull Request resolved: pytorch#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Differential Revision: D37410204

fbshipit-source-id: f3f98c161897d39e57ce1c3df55d6d69ce8c0214
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

@soulitzer soulitzer removed their request for review July 18, 2022 23:50
Copy link

@robieta robieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, with an action item to clean up the interface in a follow up PR.

slgong-fb added a commit to slgong-fb/kineto that referenced this pull request Jul 19, 2022
Summary:
X-link: pytorch/pytorch#80919

Pull Request resolved: pytorch#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Trace after changes by running //kineto/libkineto/fb/integration_tests/trace_tester.cpp (requested by chaekit)
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree%2Ftraces%2Fdynocli%2F0%2F1657304871%2F127.0.0.1%2Flibkineto_activities_3502962.json.gz&bucket=gpu_traces

Reviewed By: chaekit

Differential Revision: D37410204

fbshipit-source-id: 569c05335ca47701bd0c5a6e821b986846766702
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

slgong-fb added a commit to slgong-fb/kineto that referenced this pull request Jul 20, 2022
Summary:
X-link: pytorch/pytorch#80919

Pull Request resolved: pytorch#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Trace after changes by running //kineto/libkineto/fb/integration_tests/trace_tester.cpp (requested by chaekit)
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree%2Ftraces%2Fdynocli%2F0%2F1657304871%2F127.0.0.1%2Flibkineto_activities_3502962.json.gz&bucket=gpu_traces

Reviewed By: chaekit

Differential Revision: D37410204

fbshipit-source-id: c9d38d0dd925e54153c95ee2322feaa2ed0fa486
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

Summary:
Pull Request resolved: pytorch#80919

X-link: pytorch/kineto#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Trace after changes by running //kineto/libkineto/fb/integration_tests/trace_tester.cpp (requested by chaekit)
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree%2Ftraces%2Fdynocli%2F0%2F1657304871%2F127.0.0.1%2Flibkineto_activities_3502962.json.gz&bucket=gpu_traces

Test Plan:
1. launch a python test case with the following command for on-demand flow:
echo -e "PYTHON_STACK_TRACE=true" > /tmp/scott_kineto.conf && dyno gputrace --gputrace_duration 300ms --gpuconf /tmp/scott_kineto.conf

2. Then, we can see with_stack enabled as intended from output log:
INFO:2022-06-27 15:00:16 1009443:1011716 kineto_client_interface.cpp:22] withStack : 1

Reviewed By: chaekit

Differential Revision: D37410204

fbshipit-source-id: 7962c05b3bccb1359dfc46d832abda10caeb0e81
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37410204

facebook-github-bot pushed a commit to pytorch/kineto that referenced this pull request Jul 22, 2022
Summary:
X-link: pytorch/pytorch#80919

Pull Request resolved: #628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Trace after changes by running //kineto/libkineto/fb/integration_tests/trace_tester.cpp (requested by chaekit)
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree%2Ftraces%2Fdynocli%2F0%2F1657304871%2F127.0.0.1%2Flibkineto_activities_3502962.json.gz&bucket=gpu_traces

Reviewed By: chaekit

Differential Revision: D37410204

fbshipit-source-id: 2df900afc57ddab776b7cf1fd303debd9eafe8a1
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@github-actions
Copy link
Contributor

Hey @slgong-fb.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Jul 22, 2022
Summary:
Pull Request resolved: #80919

X-link: pytorch/kineto#628

Changes:
1. add an option in Config; can use 'PYTHON_STACK_TRACE=true' option (via .conf)
2. deliver PYTHON_STACK_TRACE value to kineto_client_interface start()
3. abstract class also changed.

Trace after changes by running //kineto/libkineto/fb/integration_tests/trace_tester.cpp (requested by chaekit)
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree%2Ftraces%2Fdynocli%2F0%2F1657304871%2F127.0.0.1%2Flibkineto_activities_3502962.json.gz&bucket=gpu_traces

Test Plan:
1. launch a python test case with the following command for on-demand flow:
echo -e "PYTHON_STACK_TRACE=true" > /tmp/scott_kineto.conf && dyno gputrace --gputrace_duration 300ms --gpuconf /tmp/scott_kineto.conf

2. Then, we can see with_stack enabled as intended from output log:
INFO:2022-06-27 15:00:16 1009443:1011716 kineto_client_interface.cpp:22] withStack : 1

Reviewed By: chaekit

Differential Revision: D37410204

fbshipit-source-id: 2df900afc57ddab776b7cf1fd303debd9eafe8a1
@janeyx99
Copy link
Contributor

@pytorchbot revert -m "Sorry, reverting as this broke buck build/test https://hud.pytorch.org/pytorch/pytorch/commit/f50a248a5eacb9a9aa475a9e610486aea136e4f5" -c nosignal

Could you please add ciflow/periodic to the reland PR to capture the signal?

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here

@pytorchmergebot
Copy link
Collaborator

@slgong-fb your PR has been successfully reverted.

@kit1980
Copy link
Contributor

kit1980 commented Jul 22, 2022

@pytorchbot revert -m "Sorry, reverting as this broke buck build/test https://hud.pytorch.org/pytorch/pytorch/commit/f50a248a5eacb9a9aa475a9e610486aea136e4f5" -c nosignal

To be clear, buck build helped to catch an actual issue with the code: void start(bool withStack) override has one bool arg, while the parent's start has no arguments, so you can't override.

@chaekit
Copy link
Contributor

chaekit commented Jul 26, 2022

the buck build failure is legit but not sure why linux-bionic-py3.7-clang9

ERROR [0.001s]: test_bce_with_logits_has_correct_forward_grad (__main__.TestNN)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_nn.py", line 9557, in test_bce_with_logits_has_correct_forward_grad
    (output, target), check_forward_ad=True)
  File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 3148, in gradcheck
    return torch.autograd.gradcheck(fn, inputs, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1418, in gradcheck
    return _gradcheck_helper(**args)
  File "/opt/conda/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1427, in _gradcheck_helper
    func_out = func(*tupled_inputs)
  File "test_nn.py", line 9556, in <lambda>
    gradcheck(lambda self, target: nn.BCEWithLogitsLoss(reduction=reduction)(self, target),
  File "test_nn.py", line 9556, in <lambda>
    gradcheck(lambda self, target: nn.BCEWithLogitsLoss(reduction=reduction)(self, target),
  File "/var/lib/jenkins/torchdynamo/torchdynamo/eval_frame.py", line 93, in _fn
    return fn(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/fx/graph_module.py", line 655, in call_wrapped
    return self._wrapped_call(self, *args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/fx/graph_module.py", line 277, in __call__
    raise e
  File "/opt/conda/lib/python3.7/site-packages/torch/fx/graph_module.py", line 267, in __call__
    return super(self.cls, obj).__call__(*args, **kwargs)  # type: ignore[misc]
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1186, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() takes 2 positional arguments but 3 were given

this is strictly profiler change and does not touch any PyTorch core. also it passed in CI before landing

@robieta
Copy link

robieta commented Jul 26, 2022

the buck build failure is legit but not sure why linux-bionic-py3.7-clang9

ERROR [0.001s]: test_bce_with_logits_has_correct_forward_grad (__main__.TestNN)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_nn.py", line 9557, in test_bce_with_logits_has_correct_forward_grad
    (output, target), check_forward_ad=True)
  File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 3148, in gradcheck
    return torch.autograd.gradcheck(fn, inputs, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1418, in gradcheck
    return _gradcheck_helper(**args)
  File "/opt/conda/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1427, in _gradcheck_helper
    func_out = func(*tupled_inputs)
  File "test_nn.py", line 9556, in <lambda>
    gradcheck(lambda self, target: nn.BCEWithLogitsLoss(reduction=reduction)(self, target),
  File "test_nn.py", line 9556, in <lambda>
    gradcheck(lambda self, target: nn.BCEWithLogitsLoss(reduction=reduction)(self, target),
  File "/var/lib/jenkins/torchdynamo/torchdynamo/eval_frame.py", line 93, in _fn
    return fn(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/fx/graph_module.py", line 655, in call_wrapped
    return self._wrapped_call(self, *args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/fx/graph_module.py", line 277, in __call__
    raise e
  File "/opt/conda/lib/python3.7/site-packages/torch/fx/graph_module.py", line 267, in __call__
    return super(self.cls, obj).__call__(*args, **kwargs)  # type: ignore[misc]
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1186, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() takes 2 positional arguments but 3 were given

this is strictly profiler change and does not touch any PyTorch core. also it passed in CI before landing

It's unrelated to the BCE test. The issue is that before the class hierarchy looked something like:

struct base {
  virtual void foo();
};

struct derived {
  void foo() override;
};

And it got changed to:

struct base {
  virtual void foo();
};

struct derived {
  // Not a legitimate override.
  void foo(bool) override;
};

Honestly, I think the question isn't why did buck fail but rather "why didn't all other CI fail"? (My suspicion is that PyTorch is using Kineto's CMake files so whatever lets it through Kineto CI also lets it through PyTorch CI. But just a hunch.) It didn't fail CI because buck CI doesn't run on PRs, it runs periodically. If it was an issue with buck I would have fought the revert (I have also been bitten by this and it's very annoying), but in this case buck was flagging a real problem as @kit1980 points out.

Speaking of which, this seems like a good reason to put buck build in the per PR group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants