A few fixes to the profiler IPython magics#7108
Merged
rapids-bot[bot] merged 1 commit intorapidsai:branch-25.10from Aug 13, 2025
Merged
A few fixes to the profiler IPython magics#7108rapids-bot[bot] merged 1 commit intorapidsai:branch-25.10from
rapids-bot[bot] merged 1 commit intorapidsai:branch-25.10from
Conversation
- For cells with outputs, still render the output when run under the profiler magics. - Ensure composing the profiler magics in either order works appropriately. - Ensure that code from previous cells isn't mistakenly traced, leading to incorrect measurements. - Make matching the source to executed lines more robust to IPython source transformations. - A few small formatting nicities.
betatim
approved these changes
Aug 13, 2025
Member
betatim
left a comment
There was a problem hiding this comment.
Kicked the tyres on this in both jupyter (classic) notebook and IPython proper. Can't break it and only found things that worked as expected and/or as the PR comment says they should.
| cell = self.shell.transform_cell(cell) | ||
| exec_source(cell, self.shell.user_ns, line_profile=True) | ||
|
|
||
| profiler = profilers.LineProfiler(source=source, filename=None) |
Member
There was a problem hiding this comment.
For my education: I was expecting source=cell, what did I miss?
Member
Author
There was a problem hiding this comment.
At this point cell is any remaining magics + source (and then transformed to standard python code). In the absence of remaining magics they're the same, but in their presence source should be what's finally exec'd by the nested cell magic. It's a bit convoluted, but it works.
Member
Author
|
/merge |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This fixes several bugs and UX rough edges with the
cuml.accelIPython magics:%%time) in the same cell without issue.SyntaxError), but do for execution errors.The first 2 issues were found and reported by others through internal usage, the rest I found while debugging and testing.