Skip to content

fix: gzip torch profiler traces by default - #4747

Merged
lvhan028 merged 2 commits into
InternLM:mainfrom
CUHKSZzxy:fix/torch-profiler-gzip
Jul 14, 2026
Merged

fix: gzip torch profiler traces by default#4747
lvhan028 merged 2 commits into
InternLM:mainfrom
CUHKSZzxy:fix/torch-profiler-gzip

Conversation

@CUHKSZzxy

@CUHKSZzxy CUHKSZzxy commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Motivation

PyTorch profiler traces can grow large, while LMDeploy currently exports them as plain JSON. vLLM enables gzip by default for the same export_chrome_trace flow to reduce storage use.

Changes

  • Export LMDeploy PyTorch profiler traces as .json.gz by default.
  • Allow uncompressed JSON with LMDEPLOY_PROFILE_USE_GZIP=0.
  • Document the setting in the English and Chinese profiling guides.

Validation

  • Verified that the default output is valid gzip-compressed JSON.
  • A profiler smoke capture decreased from 49,729 bytes to 4,508 bytes (90.9% smaller).
  • Verified that the opt-out writes valid uncompressed JSON.
  • File-level pre-commit hooks passed.

Assistance

Assisted with Codex + GPT-5.5 xHigh Fast, reviewed manually

Copilot AI review requested due to automatic review settings July 13, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the storage footprint of LMDeploy’s PyTorch profiler Chrome trace exports by switching the default trace output to gzip-compressed JSON, while keeping an environment-variable opt-out for plain JSON.

Changes:

  • Add LMDEPLOY_PROFILE_USE_GZIP (default True) to control whether profiler traces are written as .json.gz or .json.
  • Update the profiler dump path logic to emit .json.gz by default.
  • Document the new setting in both English and Chinese profiling guides.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lmdeploy/pytorch/envs.py Introduces torch_profile_use_gzip env-backed flag (LMDEPLOY_PROFILE_USE_GZIP, default on).
lmdeploy/pytorch/engine/model_agent/profiler.py Switches trace output suffix to .json.gz when gzip is enabled.
docs/zh_cn/advance/pytorch_profiling.md Documents default gzip behavior and the opt-out env var.
docs/en/advance/pytorch_profiling.md Documents default gzip behavior and the opt-out env var.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CUHKSZzxy
CUHKSZzxy requested a review from grimoire July 13, 2026 12:18
@CUHKSZzxy
CUHKSZzxy requested a review from lvhan028 July 13, 2026 12:29
@lvhan028
lvhan028 merged commit 9aed37d into InternLM:main Jul 14, 2026
4 checks passed
@CUHKSZzxy
CUHKSZzxy deleted the fix/torch-profiler-gzip branch July 14, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants