Skip to content

Profiling

SD.Next has built-in support for both Python and Torch profiling.

You can start profiling for the full session with the --profile command line flag. You can also start and stop profiling on demand from UI -> System -> Start/Stop profiling.

When profiling is enabled, analysis runs:

  • at the end of server startup, to identify startup bottlenecks
  • at the end of each generation workflow

Warning

Collecting profile information may take significant resources and time

Saving

You can save a full torch profiling dump for external analysis by setting an environment variable with the output path:

SD_PROFILE_FOLDER=/tmp/profile

Each profiling run creates a JSON file in the specified folder. You can open it in tools such as:

Warning

Each profile trace file is over 100MB in size

Advanced

You can increase profiling detail with additional environment variables:

  • SD_PROFILE_STACK=true: enable torch stack information
  • SD_PROFILE_FLOPS=true: enable torch flops calculations
  • SD_PROFILE_SHAPES=true: group torch profile information per each shape