Skip to content

[Bug] LoRA adapters are accumulating instead of being replaced during unload/load cycle #705

@Signorlimone

Description

@Signorlimone

Description:

When switching between different LoRA adapters in the Gradio UI, the previous adapter is not correctly removed from the model's memory. Instead of replacing the existing adapter, the system appends the new one, leading to multiple active adapters and potential VRAM/quality issues.
Steps to reproduce:

Load a LoRA adapter (e.g., final).

Click on Unload LoRA.

Load a different LoRA adapter (e.g., best).

Check the console logs.

Expected behavior:

Only the newly loaded adapter should be active (adapters=['best']).
Actual behavior:

The logs show that both adapters remain active, and the number of targets doubles:
LoRA adapter 'best' loaded ... (adapters=['best', 'final'], targets=384)

Additionally, the unload_lora function triggers several WARNING messages regarding missing/unexpected keys:
Plaintext

WARNING | acestep.core.generation.handler.lora.lifecycle:unload_lora:442 - Missing keys when restoring decoder: ['layers.0.self_attn.q_proj.base_layer.weight', ...]
WARNING | acestep.core.generation.handler.lora.lifecycle:unload_lora:444 - Unexpected keys when restoring decoder: ['layers.0.self_attn.q_proj.weight', ...]

The VRAM is not freed after unload (freed: 0.00GB), suggesting the PEFT wrapper is not being correctly detached or the active_adapters list is not being cleared.
Environment:

Ace-Step Version: 1.5 (Gradio UI)

OS: Windows

Hardware: NVIDIA GPU (approx. 11GB VRAM used)

Text from terminal during load/unload phase:

2026-02-25 21:28:48.179 | INFO | acestep.core.generation.handler.lora.lifecycle:unload_lora:474 - VRAM after LoRA unload: 10.55GB (freed: 0.00GB)
2026-02-25 21:28:48.179 | INFO | acestep.core.generation.handler.lora.lifecycle:unload_lora:476 - LoRA unloaded, base decoder restored
2026-02-25 21:29:05.644 | INFO | acestep.core.generation.handler.lora.lifecycle:add_lora:238 - Loading LoRA adapter from C:\AI\Side-Step\lora-output\AiC_Dirt_Gemini\best as 'best'
2026-02-25 21:29:06.285 | INFO | acestep.core.generation.handler.lora.lifecycle:add_lora:256 - VRAM after LoRA load: 10.55GB
2026-02-25 21:29:06.301 | INFO | acestep.core.generation.handler.lora.lifecycle:add_lora:274 - LoRA adapter 'best' loaded from C:\AI\Side-Step\lora-output\AiC_Dirt_Gemini\best (adapters=['best', 'final'], targets=384)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions