Skip to navigation

nemo_automodel.components.quantization.qlora

View as MarkdownOpen in Claude

Module Contents

Classes

NameDescription
_QuantizationConfigStructural contract for the recipe’s quantization configuration node.

Functions

NameDescription
create_bnb_configCreate the BitsAndBytes configuration used for QLoRA.
verify_qlora_quantizationReturn whether any module carries a BitsAndBytes quantized state.

API

class nemo_automodel.components.quantization.qlora._QuantizationConfig()
Protocol

Structural contract for the recipe’s quantization configuration node.

Recipes pass a ConfigNode (self.cfg.get("quantization")), not a plain dict. Only the keys read by create_bnb_config are declared; the get overloads pin each key to the type transformers expects for it.

nemo_automodel.components.quantization.qlora._QuantizationConfig.__contains__(
key: str
) -> bool
nemo_automodel.components.quantization.qlora.create_bnb_config(
) -> transformers.BitsAndBytesConfig | None

Create the BitsAndBytes configuration used for QLoRA.

Parameters:

config
_QuantizationConfig

The recipe’s quantization section. A ConfigNode satisfies this protocol; only the two load_in_* flags and the four bnb_4bit_* settings are read.

Returns: BitsAndBytesConfig | None

The BitsAndBytes configuration, or None when neither 4-bit nor

Raises:

  • ImportError: If bitsandbytes or transformers is unavailable.
  • ValueError: If the quantization section omits both load flags.
nemo_automodel.components.quantization.qlora.verify_qlora_quantization(
model: torch.nn.Module
) -> bool

Return whether any module carries a BitsAndBytes quantized state.

Parameters:

model
nn.Module

Model to inspect.

Returns: bool

True when at least one module has a quant_state of type