Skip to content

Update profiling setup - #354

Merged
max-models merged 28 commits into
develfrom
update-dependencies
Aug 22, 2026
Merged

Update profiling setup#354
max-models merged 28 commits into
develfrom
update-dependencies

Conversation

@max-models

@max-models max-models commented Aug 20, 2026

Copy link
Copy Markdown
Member

Updated scope-profiler to 0.3.3. There are some big improvements in the postprocessing in this version. Especially for GPU profiling and also line-by-line profiling for the regions we already defined using the tool without having to use line_profiler directly.

For example, please try running this param file:

from struphy import ProfilingOptions, Simulation
from struphy.models import Poisson

model = Poisson()

profiling_opts = ProfilingOptions(use_line_profiler=True)

sim = Simulation(
    model=model,
    profiling_opts=profiling_opts,
)

sim.run(profiling_activated=True)

Then inspect the profiling file in the terminal with

scope-profiler tui sim_1/profiling_data.h5
image

With scope-profiler > 0.3.0, there is a new optional syntax for the profiling manager. Instead of writing ProfilingManager.setup(...) and then ProfilingManager.finalize(), it is now possible to define the start and stop of the profiling manager work using contexts, just as is done with the profiling regions.

For example (from the scope-profiler readme

from scope_profiler import ProfileManager

with ProfileManager.session():
    @ProfileManager.profile("main")
    def main():
        with ProfileManager.profile_region("work"):
            sum(range(100))  # replace with the code you want to measure

    main()
# writes profiling_data.h5 and prints a summary

For us, this means we can use this syntax in sim.run(), so we don't need the _setup_profiling() method. Everything in sim.run() is just indented by one tab after with ProfileManager.session(...):, but in the diff it looks like there is a much bigger diff... I promise there isn't though.

Changes in the code:

  1. Added functions=[...] to ProfileManager.profile_region calls which are profiling a very small scope, most likely just a function. When line profiling is turned on, this means that the lines inside that function are profiled, not just the line for the function call itself.

For example:

with ProfileManager.profile_region(self._solve_region, functions=[self._A_inv.solve]):
            _u = self._A_inv.solve(rhs, out=self._u_new)
  1. Added a ProfilingOptions class to specify profiling option in the parameter files, this class is automatically added to the scripts with struphy params MODEL. This class basically mirrors the parameters used in scope-profiler
  2. Deprecated profiling_activated from the EnvironmentOptions class and moved it to sim.run(profiling_activated=profiling_activated) instead
  3. Added tutorials/tutorial_scope_profiling.ipynb
  4. Updated docs
  5. Updated dependencies for gvec, vtk, feectools. I also set lower bounds for feectools and scope-profiler.

@max-models
max-models force-pushed the update-dependencies branch from 42cc75a to 68e9906 Compare August 21, 2026 08:16
@max-models
max-models marked this pull request as ready for review August 21, 2026 08:28
@max-models max-models changed the title Update dependencies Update profiling setup Aug 21, 2026
@max-models
max-models marked this pull request as draft August 21, 2026 12:08
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview: https://struphy-hub.github.io/docs-preview/pr-354/

@max-models
max-models marked this pull request as ready for review August 21, 2026 12:37
@max-models
max-models requested a review from spossann August 21, 2026 12:37
@max-models
max-models enabled auto-merge (squash) August 21, 2026 13:06
@max-models
max-models disabled auto-merge August 22, 2026 09:54
@max-models
max-models merged commit 1985884 into devel Aug 22, 2026
26 checks passed
@max-models
max-models deleted the update-dependencies branch August 22, 2026 09:54
@spossann

Copy link
Copy Markdown
Member

That looks great - looking forward to testing it!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants