Skip to content
fn

get_default_qconfig_mapping

→QConfigMapping
get_default_qconfig_mapping()

Build the default static-PTQ QConfigMapping.

Convenience constructor returning a fresh mapping whose global tier is get_default_qconfig and whose per-type / per-name tiers are empty. Every eligible module is therefore quantized with the standard histogram-activation / per-channel-weight recipe unless you add an override. This is the mapping lucid.quantization.prepare uses when called without an explicit mapping.

Returns

QConfigMapping

A mapping whose global QConfig is the default static-PTQ config and whose type / name tiers are empty (ready to receive overrides).

Notes

  • Add exceptions with QConfigMapping.set_object_type / QConfigMapping.set_module_name (e.g. map a sensitive head to None).
  • For quantization-aware training use get_default_qat_qconfig_mapping instead — it installs lucid.quantization.FakeQuantize recipes.

Examples

>>> import lucid.nn as nn
>>> import lucid.quantization as Q
>>> mapping = Q.get_default_qconfig_mapping()
>>> mapping.get_qconfig(nn.Conv2d, "features.0") is not None
True
>>> # Keep the classifier in float while quantizing the rest:
>>> _ = mapping.set_module_name("classifier", None)
>>> mapping.get_qconfig(nn.Linear, "classifier") is None
True

See Also

  • get_default_qconfig—The recipe installed as the global tier.
  • get_default_qat_qconfig_mapping—The QAT counterpart.
  • QConfigMapping—The three-tier resolution object this returns.

Used by 2