torch-export

Export PyTorch models to ExportedProgram format with dynamic shapes and control flow.

1|1|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/yunseo-kim/agent-toolbox --skill torch-export
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: torch-export
Source: https://github.com/yunseo-kim/agent-toolbox/tree/main/catalog/skills/torch-export
Command: npx skills add https://github.com/yunseo-kim/agent-toolbox --skill torch-export

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of converting trained PyTorch models into a deployable format that can run efficiently across various platforms and runtimes, abstracting away the complexities of model serialization and optimization.

Core Features & Use Cases

  • Symbolic Tracing: Captures PyTorch nn.Module into an ExportedProgram using symbolic tracing.
  • Dynamic Shape Support: Allows for models that handle variable input dimensions.
  • Control Flow Handling: Manages static, shape-dependent, and data-dependent control flow within the exported graph.
  • Debugging Tools: Provides mechanisms like draft_export and verbose logging for troubleshooting export failures.
  • Use Case: Deploying a custom PyTorch image classification model to a mobile device or an edge server by exporting it to a format compatible with inference engines like ONNX or TensorRT.

Quick Start

Export the provided PyTorch model using default settings.

Frequently Asked Questions about torch-export

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I export a PyTorch model for deployment?

Export a PyTorch model for deployment by capturing an nn.Module into an ExportedProgram using symbolic tracing. This serializes the trained model into a .pt2 file, enabling efficient cross-platform execution.

What is the best way to handle dynamic shapes when exporting PyTorch models?

Handle dynamic shapes during PyTorch model export by utilizing built-in dynamic shape support within the torch.export mechanism. This allows the exported graph to process variable input dimensions for flexible inference.

Why does torch.export fail with control flow in my deep learning model?

torch.export may fail with control flow if operators are unhandled. The export process manages static, shape-dependent, and data-dependent control flow within the graph, requiring specific tracing mechanisms to capture execution paths correctly.

How do I debug PyTorch model export failures?

Debug PyTorch model export failures by using draft_export and enabling verbose logging. These tools help identify unhandled operators, tracing errors, and control flow issues during the symbolic capture of the model.

Can I deploy an exported PyTorch model to ONNX or TensorRT?

Yes, exported PyTorch models can be deployed to inference engines like ONNX or TensorRT. The ExportedProgram format abstracts serialization complexities, enabling custom models to run efficiently across mobile and edge platforms.