﻿# Torch export strict and non-strict: tracing modes are not eager fallback at deployment

Understand explicit torch.export strict modes as capture strategies with different Python-level assumptions, while preserving the exported graph contract for deployment.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-torch-export-strict-nonstrict-capture-not-eager-fallback/
Language: en

## A successful non-strict export is misunderstood

A model fails strict tracing because of a Python feature, then exports through the non-strict path. A deployment engineer assumes the resulting artifact retains the original Python code and will fall back to ordinary execution whenever needed. That is not the meaning of the capture-mode choice. Distinguish how the exporter observes the program during capture from what the exported artifact represents afterward. Both routes still produce an exported program whose assumptions and supported inputs must match the intended inference deployment.

## The modes use different capture mechanisms

The [programming-model guide](https://docs.pytorch.org/docs/2.15/user_guide/torch_compiler/export/programming_model.html) describes strict analysis through TorchDynamo and non-strict tracing through the Python interpreter with tensor proxies. The modes have different Python-level safety and coverage considerations. Choose explicit strict=True or strict=False when documenting a release rather than relying on an assumed default from another documentation revision. Python execution during capture does not establish that arbitrary Python behavior remains dynamically executable in a compiled deployment using the resulting exported graph.

## Shape assumptions still belong to export validity

The [export API](https://docs.pytorch.org/docs/2.15/user_guide/torch_compiler/export/api_reference.html) explains that non-strict capture still validates critical assumptions such as shape safety and that toggling strict does not define a different serialized IR specification. Review the actual exported constraints and behavior. [Attention-axis semantics](/journal/broadcasting-attention-mask-axes/) provide related background: a tensor's acceptable representation must preserve its intended meaning. Relaxing a capture mechanism is not a license to supply arbitrary future inputs that violate the graph's supported domain.

## The IR contract is the deployment boundary

The [IR specification](https://docs.pytorch.org/docs/2.15/user_guide/torch_compiler/export/ir_spec.html) documents the exported representation. Treat this representation and its declared state as the compiler input, rather than describing the artifact as a copy of unrestricted application Python. [Artifact verification](/journal/artifact-signature-verification/) helps connect deployment evidence to the actual captured release. A successful export event identifies an artifact-producing step, but does not alone demonstrate numerical correctness or establish that every backend can compile every operator contained in that artifact.

## Validate the artifact on supported future inputs

Replay representative inputs through the exported program and the intended compiled path, comparing with the original reference. Include cases that exercise assumptions previously hidden in Python, plus inputs near the declared shape boundaries. Record capture mode and exporter version with the artifact. A useful conclusion states what was captured and validated, without confusing non-strict tracing with permissive runtime fallback or promoting successful capture into an unsupported guarantee of complete backend compatibility.
