🚨 Exporters: `ExportedModel`, Hub save/load, one backend registry
The Issue & Context
Previously, exporting a model returned backend-specific objects without a standard way to save, share, or track export provenance, causing inconsistent handling and difficulty in reuse or inspection.
Root Cause Analysis
Each backend implemented its own export output and saving logic, with no common abstraction or metadata recording, leading to fragmented APIs and side-effect file writes (e.g., quantization files written outside export calls). The registry was split across multiple mappings and functions, complicating backend discovery and usage.
Solution Strategy & Architectural Pattern
Introduced an ExportedModel abstraction that wraps backend export outputs and metadata, providing unified save_pretrained, push_to_hub, and from_pretrained methods. Backends now implement export_program, save_program, and load_program to integrate with this model. A single backend registry replaces multiple mappings and functions, centralizing backend management. Export provenance is recorded in export.json, capturing config, inputs, and environment details. Quantization no longer writes files as side effects but integrates with ExportedModel saving.
Key Takeaway for Contributors
When supporting multiple backend formats, centralizing export outputs and metadata into a single abstraction simplifies downstream usage, provenance tracking, and sharing, while reducing backend-specific side effects and registry fragmentation.