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 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-mcp Start the MCP server for agent integration

MCP Server

pt-snap-cli provides an MCP (Model Context Protocol) server so AI agents can interact with PyTorch memory snapshots programmatically.

# Start the MCP server
pt-snap-mcp

See the MCP guide for setup and usage details.

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
MCP server MCP Guide
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.3.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.3.0
File Size Uploaded
pt_snap_cli-0.3.0.tar.gz 601.0 kB Details

Built distribution (wheel)

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

Total release size: 755.1 kB

Release files / pt_snap_cli-0.3.0.tar.gz

Download URL pt_snap_cli-0.3.0.tar.gz
Size 601.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4d5bba655ded09fa52662171651d5313fc121f6f765b7d4b1801a211d6920c42
BLAKE2b-256 checksum
How to use checksums
977e471b49caae14fa8787148ee8869f816d398e1e1da24abe3f3a676e0610a7
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 17, 2026.

Transparency log

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

Download URL pt_snap_cli-0.3.0-py3-none-any.whl
Size 154.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8a7ef282bc1f06eed961989216f6b5479bdc3b8d6b0f2918b8d73dd22a7e767
BLAKE2b-256 checksum
How to use checksums
902800b913d6ce7838e5c9d647d3775668bdf863ea3b2eeb904f4fba807de86c
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 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

This release

0.3.0 This release

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