한국어
ENN-PyTorch의 저장과 내보내기 계층은 학습된 모델 상태를 재사용 가능한 checkpoint로 보존하거나, 외부 런타임에서 사용할 수 있는 artifact로 변환하는 구조다.
이 장에서 말하는 저장은 단순히 torch.save(model.state_dict())를 호출하는 수준이 아니다. ENN-PyTorch 모델은 weight tensor뿐 아니라 모델 설정, 입력 차원, 출력 shape, task 정보, Scaler/Embedding 상태, PyTorch version, optional metadata가 함께 보존되어야 다시 안정적으로 복원될 수 있다.
내보내기는 저장과 목적이 다르다. 저장은 ENN-PyTorch 또는 PyTorch 환경에서 모델을 다시 로드하기 위한 것이고, 내보내기는 ONNX, ORT, TensorRT, CoreML, LiteRT, PT2, AOTI, ExecuTorch 같은 외부 runtime에서 사용할 수 있는 artifact를 만드는 것이다.
중요한 점은 학습·예측 런타임에서 사용하는 fast path를 그대로 내보내지 않는다는 것이다. 내보내기 과정에서는 trace/export에 불리한 경로를 비활성화하고, 외부 런타임에서 표현 가능한 안전한 경로로 모델을 변환한다.
English
The ENN-PyTorch saving and export layer either preserves trained model state as reusable checkpoints or converts the model into artifacts that can be used in external runtimes.
Saving in this chapter is not just calling torch.save(model.state_dict()). To restore an ENN-PyTorch model reliably, not only weight tensors but also model configuration, input dimension, output shape, task information, Scaler/Embedding state, PyTorch version, and optional metadata must be preserved together.
Export has a different purpose from saving. Saving is for reloading the model in ENN-PyTorch or PyTorch environments, while export creates artifacts for external runtimes such as ONNX, ORT, TensorRT, CoreML, LiteRT, PT2, AOTI, and ExecuTorch.
The important point is that fast paths used in the training and prediction runtime are not exported as-is. During export, paths that are unfavorable for tracing or exporting are disabled, and the model is converted into a safe path that external runtimes can represent.
한국어
모델 저장과 내보내기는 학습·예측 런타임 뒤에 위치한다. Native 저장은 모델을 다시 Python/PyTorch 환경에서 불러오기 위한 경로이고, 내보내기는 모델을 외부 runtime 또는 deployment target에서 실행 가능한 형식으로 바꾸는 경로다.
English
Model saving and export sit after the training and prediction runtime. Native saving is the path for loading the model again in a Python/PyTorch environment, while export converts the model into a format executable by an external runtime or deployment target.
flowchart TD
A["학습 완료 모델<br/>Trained Model"] --> B{"저장 또는 내보내기<br/>Save or Export"}
B -->|native 저장 / native save| C["PyTorch checkpoint<br/>.pt / .pth"]
B -->|safe tensor 저장 / safe tensor save| D["safetensors<br/>.safetensors"]
B -->|분산 checkpoint / distributed checkpoint| E["DCP directory"]
B -->|외부 런타임용 변환 / export for external runtime| F["export-safe context"]
F --> G["fast path 비활성화<br/>Disable fast paths<br/>FlexAttention / SDPA / Triton MSR<br/>selected calibration paths"]
G --> H{"backend 선택<br/>Select Backend"}
H --> I["ONNX / ORT"]
H --> J["TensorRT"]
H --> K["CoreML / LiteRT"]
H --> L["PT2 / AOTI / ExecuTorch"]
H --> M["TensorFlow"]
I --> N["sidecar metadata"]
J --> N
K --> N
L --> N
M --> N