Skip to content

[peft] Add support for LoRA merge#418

Closed
ananthsub wants to merge 7 commits intoNVIDIA-NeMo:mainfrom
ananthsub:lora-merge
Closed

[peft] Add support for LoRA merge#418
ananthsub wants to merge 7 commits intoNVIDIA-NeMo:mainfrom
ananthsub:lora-merge

Conversation

@ananthsub
Copy link
Contributor

@ananthsub ananthsub commented Aug 18, 2025

Offer API to merge base model weights with LoRA adapters given a path to a LoRA checkpoint generated from megatron bridge.

  1. Use the serialized ConfigContainer in the run_config.yaml to read the pretrained_checkpoint field from the CheckpointConfig - this points to the path for the base model checkpoint directory.
  2. We re-use the existing functionality from model_load_save for initializing the base model from the serialized config and loading the base weights.
  3. Then use the instantiated LoRA transform from the run_config.yaml and apply the transform.
  4. After the transform is applied, we load the adapter weights from the provided LoRA checkpoint path.
  5. Once the adapter weights are loaded, the LoRA Merge transform is applied.
  6. Finally, we generate the config metadata for the merged checkpoint, and save the weights for the merged model.

Parity with https://github.com/NVIDIA/NeMo/blob/42bc4b20b170cb65ed15e4691f9e769ca2941865/nemo/collections/llm/peft/api.py#L76-L80

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@copy-pr-bot
Copy link

copy-pr-bot bot commented Aug 18, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ananthsub
Copy link
Contributor Author

/ok to test d8ded7c

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@ananthsub
Copy link
Contributor Author

/ok to test 71d4668

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@ananthsub
Copy link
Contributor Author

/ok to test 34f6564

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
@marcromeyn
Copy link
Contributor

/ok to test 38d0ed2

@marcromeyn
Copy link
Contributor

/ok to test ba5deb5

@github-actions
Copy link
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants