Skip to navigation

nemo_automodel.components.models.nemotron_decision.export

View as MarkdownOpen in Claude

Export a trained Nemotron Decision stage (merged LoRA adapter or full weights) as a complete, servable checkpoint.

Module Contents

Functions

NameDescription
checkpoint_fingerprintSHA-256 over the configuration, the decision contract files and every *.safetensors shard of a checkpoint.
export_full_checkpointWrite a complete checkpoint from consolidated backbone fine-tuning weights, cast to the base dtypes.
merge_lora_checkpointMerge a PEFT LoRA adapter into the base weights and write a complete checkpoint.

Data

_FINGERPRINTED

_NOT_COPIED

API

nemo_automodel.components.models.nemotron_decision.export.checkpoint_fingerprint(
checkpoint_dir: str | pathlib.Path,
chunk_size: int = 1 << 24
) -> str

SHA-256 over the configuration, the decision contract files and every *.safetensors shard of a checkpoint.

Covers config.json, decision.json and decision_template.jinja (each when present) and reads every weight byte, so a base whose interior weights or decision prompt differ (for example, an ordinary fine-tune of the same architecture) gets a different fingerprint.

Parameters:

checkpoint_dir
str | Path

Local checkpoint directory.

chunk_size
intDefaults to 1 << 24

Bytes read per step.

Returns: str

Hex digest.

Raises:

  • FileNotFoundError: If the directory has no *.safetensors shard.
nemo_automodel.components.models.nemotron_decision.export.export_full_checkpoint(
base_dir: str | pathlib.Path,
weights_dir: str | pathlib.Path,
output_dir: str | pathlib.Path
) -> dict

Write a complete checkpoint from consolidated backbone fine-tuning weights, cast to the base dtypes.

Parameters:

base_dir
str | Path

Checkpoint the run started from (configuration, tokenizer and model code are copied from it).

weights_dir
str | Path

Directory of consolidated *.safetensors weights of the trained model.

output_dir
str | Path

New directory (must not exist).

Returns: dict

Receipt &#123;"base", "weights", "tensors"&#125; (also written as export-receipt.json).

Raises:

  • ValueError: If the trained tensor names or shapes differ from the base.
  • FileExistsError: If output_dir exists.
nemo_automodel.components.models.nemotron_decision.export.merge_lora_checkpoint(
base_dir: str | pathlib.Path,
adapter_dir: str | pathlib.Path,
output_dir: str | pathlib.Path
) -> dict

Merge a PEFT LoRA adapter into the base weights and write a complete checkpoint.

Parameters:

base_dir
str | Path

Checkpoint the adapter was trained on.

adapter_dir
str | Path

Directory with adapter_config.json and adapter_model.safetensors.

output_dir
str | Path

New directory (must not exist).

Returns: dict

Receipt &#123;"base", "adapter", "lora_modules", "r", "alpha", "scale"&#125; (also written as merge-receipt.json).

Raises:

  • ValueError: For DoRA/rank-pattern adapters, adapter weights missing from the base, or shape mismatch.
  • FileExistsError: If output_dir exists.
nemo_automodel.components.models.nemotron_decision.export._FINGERPRINTED = ('config.json', DECISION_CONFIG_FILE, DECISION_TEMPLATE_FILE)
nemo_automodel.components.models.nemotron_decision.export._NOT_COPIED = ('*.safetensors', '*.safetensors.index.json', '.cache', 'merge-receipt.json', 'e...