registry#
Registries dispatching per-module logic for the unified HF export path.
This mirrors the registration-and-dispatch idiom of
QuantModuleRegistry,
but not its mechanism: quantization registers replacement classes and converts modules
in place, whereas export registers functions that emit compressed weights and scale
buffers for a module without changing its class.
Preparation and export use separate registries because they have independent matching
precedence. Registering a handler for a new module type replaces what previously required
editing if/elif chains inside unified_export_hf.py.
Classes
Shared state for a single export invocation, passed to every handler call. |
- class ExportContext#
Bases:
objectShared state for a single export invocation, passed to every handler call.
Tied-weight dedup is not a handler concern: the driver builds one name-based
TiedWeightMapand feeds it tosync_tied_input_amaxandpostprocess_state_dictdirectly. Both dense and fused-MoE tied weights are packed independently and their duplicate keys are dropped by name there, so the context carries no tied-weight map (handlers never consulted it).- __init__(model, dtype, is_modelopt_qlora=False, model_type=None)#
- Parameters:
model (Module)
dtype (dtype)
is_modelopt_qlora (bool)
model_type (str | None)
- Return type:
None
- dtype: dtype#
- is_modelopt_qlora: bool = False#
- model: Module#
- model_type: str | None = None#
The model’s HF model type (
model.config.model_type), used to resolve the model’s spec inmodelopt.torch.models.Nonemeans unknown: spec lookups then fail loudly instead of guessing.