Skip to content
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 profiler_range #59634

Merged
merged 6 commits into from
Dec 7, 2023
Merged

Conversation

AndSonder
Copy link
Contributor

@AndSonder AndSonder commented Dec 3, 2023

PR types

Others

PR changes

Others

Description

添加 profiler_range 工具,方便 便捷地启用 profile 工具:

with profiler_range(step, job_schedule_profiler_start, job_schedule_profiler_end) as enable_profiler:
    engine.enable_job_schedule_profiler = enable_profiler

相关pr:

Copy link

paddle-bot bot commented Dec 3, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@From00 From00 left a comment

Choose a reason for hiding this comment

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

需要加个单测

return

try:
if (iter_id == start) or (iter_id >= start):
Copy link
Contributor

Choose a reason for hiding this comment

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

这个判断逻辑看起来很奇怪,而且在exit_after_prof==false的时候看起来是错的。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个判断逻辑看起来很奇怪,而且在exit_after_prof==false的时候看起来是错的。

已修复

@contextmanager
def job_schedule_profiler_range(iter_id, start, end, exit_after_prof=True):
    if start >= end:
        yield False
        return

    try:
        if iter_id >= start and iter_id < end:
            yield True
        else:
            yield False
    finally:
        if iter_id == end - 1:
            if exit_after_prof:
                sys.exit()



@contextmanager
def profiler_range(iter_id, start, end, exit_after_prof=True):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def profiler_range(iter_id, start, end, exit_after_prof=True):
def job_schedule_profiler_range(iter_id, start, end, exit_after_prof=True):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@AndSonder
Copy link
Contributor Author

需要加个单测

done

Copy link
Contributor

@From00 From00 left a comment

Choose a reason for hiding this comment

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

LGTM

from paddle.profiler.utils import job_schedule_profiler_range


class TestJobScheDuleProfilerRange(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class TestJobScheDuleProfilerRange(unittest.TestCase):
class TestJobScheduleProfilerRange(unittest.TestCase):

@From00 From00 merged commit b9d9b17 into PaddlePaddle:develop Dec 7, 2023
28 of 29 checks passed
@AndSonder AndSonder deleted the add_profiler_guard branch December 7, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants