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 Lightning-like Profiler to Keras #19023

Open
innat opened this issue Jan 4, 2024 · 4 comments
Open

Add Lightning-like Profiler to Keras #19023

innat opened this issue Jan 4, 2024 · 4 comments
Assignees
Labels
stat:contributions welcome A pull request to fix this issue would be welcome. type:feature The user is asking for a new feature.

Comments

@innat
Copy link

innat commented Jan 4, 2024

Reopening from here.

Describe the feature and the current behavior/state

In PyTorch-Lightning, you can identify bottlenecks in your code using Profiler API. And I've found it super useful and easy to inspect the pros and cons of the code. This API offers 3 type of inferface, namely simple, advance and pytorch. I mostly use simple that summarize the execution time of medium to high level training + validation + inference API. The saved log files look something as follows.

# by passing a string
trainer = Trainer(..., profiler="simple")

# or by passing an instance
from pytorch_lightning.profiler import SimpleProfiler

profiler = SimpleProfiler()
trainer = Trainer(..., profiler=profiler)

a

I don't know, in keras, if we have anything like this already. By having such high-level functionality in keras would really great. It will help to inspect the bottleneck of dataloader, model, callbacks etc, by reporting the time and memory consumption in the system.

I looked for it before, discussion.

Will this change the current api? How?

This can be considered as a Callback, I think.

keras.callbacks.Profiler
or
keras.utils.Profiler

Who will benefit from this feature?

The keras community. Engineers and researchers, both. Mostly engineers in production phase for code optimization.

Contributing

  • Do you want to contribute a PR? (yes/no):
  • If yes, please read this page for instructions
  • Briefly describe your candidate solution(if contributing):
@sachinprasadhs sachinprasadhs added type:feature The user is asking for a new feature. keras-team-review-pending Pending review by a Keras team member. labels Jan 11, 2024
@nkovela1
Copy link
Contributor

Hi @innat, this would be a good addition as a Callback! Would you be willing to contribute a PR to add this Profiler Callback?

@sachinprasadhs sachinprasadhs added stat:contributions welcome A pull request to fix this issue would be welcome. and removed keras-team-review-pending Pending review by a Keras team member. labels Jan 18, 2024
@innat
Copy link
Author

innat commented Jan 18, 2024

Yes, I'm willing to contribute. Before that, could you please give some thought on this. Thanks.

@fchollet
Copy link
Member

Before that, could you please give some thought on keras-team/tf-keras#350 (comment). Thanks.

There are no profiling plans from our side at this time -- if you want to create this feature, you're welcome to do it, it would be a very valuable addition.

@ghsanti
Copy link
Contributor

ghsanti commented Aug 2, 2024

I've tried something hereI don't know if it's a meaningful plot yet, using Trace. Seems to be ok for CPU only though.

GIST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:contributions welcome A pull request to fix this issue would be welcome. type:feature The user is asking for a new feature.
Projects
None yet
Development

No branches or pull requests

5 participants