Skip to main content

pt-snap-cli

中文文档 | English

A command-line tool for analyzing PyTorch memory snapshots. Set a snapshot database, run built-in queries, and inspect memory usage, leaks, and timelines.

Installation

pip install pt-snap-cli

For a source checkout and contributor setup, see Development.

Quick Start

To start from a raw PyTorch memory snapshot, import the pickle into a SnapshotDB with pt-snap's built-in snapshot support, then list the available query templates:

Security warning: Import only pickle snapshots from a trusted source. Pickle deserialization can execute arbitrary code. The loader rejects non-builtins global objects, but pt-snap import is not a sandbox.

pt-snap import snapshot.pkl
pt-snap metadata snapshot.pkl.db
pt-snap query --list
# Set the snapshot database and device
pt-snap focus snapshot.pkl.db --device 0

# List available queries
pt-snap query --list

# Run a query (automatically uses the focused device)
pt-snap query --template-use memory_peak

# Detect potential memory leaks
pt-snap query --template-use leak_detection --params '{"min_size": 1024}'

To divide a large snapshot into independently replayable files before import, use exactly one split strategy and an output directory that does not exist:

pt-snap split snapshot.pkl --slices 4 --output snapshot-slices

See Splitting Snapshots for device selection, JSON output, deterministic names, replay validation, and failure-safe publication.

See the full quick start guide for a walkthrough.

Commands

Command Description
pt-snap focus Set and manage analysis focus (database + device)
pt-snap import <snapshot.pkl> Import a PyTorch memory snapshot pickle into a SnapshotDB
pt-snap split <snapshot.pkl> Create replayable per-device snapshot slices
pt-snap metadata [database.db] Inspect SnapshotDB import provenance and compatibility metadata
pt-snap capabilities List CLI version, query template contracts, and bundled skills
pt-snap overview [database.db] Read-only device list, per-device event-id bounds, and import-metadata status
pt-snap query Run memory analysis queries
pt-snap report Generate higher-level memory analysis reports
pt-snap config Manage global configuration
pt-snap skill List and install bundled agent skills

pt-snap --help includes an agent hint: prefer --json on the command that supports it, start with the pt-snap-helper skill, use pt-snap capabilities --json and pt-snap overview --json before diagnosing, and check availability with pt-snap skill list --json. focus, import, split, query, config, capabilities, overview, metadata, report peak-memory, and skill list/install/upgrade/uninstall accept --json.

Agent Skills

Install bundled diagnostic workflows with pt-snap skill install. Agent integration uses skills plus the CLI; there is no MCP server. See the Agent Skills guide.

Documentation

See the documentation index for all English and Chinese guides.

Topic Guide
Getting started Quick Start
Managing focus Focus Management
Running queries Querying
Splitting snapshots Splitting Snapshots
Agent skills Agent Skills
Database format SnapshotDB Schema
Python API SnapshotAnalyzer API
Result mapping utility ResultMapper API

Development

pip install -e ".[dev]"         # Install development dependencies
pytest                           # Run all tests
black --check . && ruff check .  # Check formatting and lint
python -m build                  # Build sdist and wheel

Metadata

Release files for pt-snap-cli 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pt-snap-cli 0.4.0
File Size Uploaded
pt_snap_cli-0.4.0.tar.gz 675.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pt-snap-cli 0.4.0
File Interpreter ABI Platform
pt_snap_cli-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 854.1 kB

Release files / pt_snap_cli-0.4.0.tar.gz

Download URL pt_snap_cli-0.4.0.tar.gz
Size 675.3 kB
Tags Source
SHA-256 checksum
How to use checksums
65a55e3b3dc989ba59dfe9cd6c0ef7eed686b36b519522c30862ed82c3655684
BLAKE2b-256 checksum
How to use checksums
3cd146b7dc06ec7a4f8741ce02b3fa6e7b077e53750220e346ad74ec6f12d0e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / pt_snap_cli-0.4.0-py3-none-any.whl

Download URL pt_snap_cli-0.4.0-py3-none-any.whl
Size 178.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ff3c871d3b06e3c83fd039fbd94230d1497dbb4e93c2533506e94b1cd9a129e
BLAKE2b-256 checksum
How to use checksums
e3e8b9a94bdf5a17f4d86ba50de310953034eb9cab70f25d62e27199ea5af597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page