33#include <unordered_map>
39struct llama_adapter_lora;
69 bool load(
const std::string& name,
70 const std::filesystem::path& adapter_path,
80 void unload(
const std::string& name, llama_context* ctx);
89 bool activate(
const std::string& name, llama_context* ctx);
105 bool swap(
const std::string& name, llama_context* ctx);
178 struct AdapterEntry {
180 std::filesystem::path path;
181 llama_adapter_lora* handle =
nullptr;
182 llama_model* model =
nullptr;
185 size_t ram_bytes = 0;
186 std::string tier_name;
187 std::unordered_map<std::string, std::string> metadata;
196 static AdapterInfo make_info(
const AdapterEntry& entry);
206 bool fire_swap_hook(
const std::string& current,
207 const std::string& target,
208 const std::filesystem::path& target_path);
210 std::unordered_map<std::string, AdapterEntry> adapters_;
211 std::string active_name_;
212 mutable std::mutex adapter_mutex_;
213 HookInterface hooks_;
LoRA adapter lifecycle manager.
bool swap(const std::string &name, llama_context *ctx)
Swap to a different adapter atomically.
std::vector< AdapterInfo > list_adapters() const
List all known adapters.
bool activate(const std::string &name, llama_context *ctx)
Activate adapter on context (WARM -> HOT).
std::string active_adapter() const
Get the currently HOT adapter name.
void unload_all_for_model(llama_model *model, llama_context *ctx)
Unload all adapters for a given base model.
void deactivate(llama_context *ctx)
Deactivate current HOT adapter (HOT -> WARM).
bool load(const std::string &name, const std::filesystem::path &adapter_path, llama_model *model, float scale=1.0f)
Load a LoRA adapter into RAM (COLD -> WARM).
void unload(const std::string &name, llama_context *ctx)
Unload adapter (any state -> COLD).
AdapterInfo info(const std::string &name) const
Get metadata for an adapter.
void unload_all()
Free every loaded adapter handle (gh#58 close-out, v2.3.0).
AdapterState state(const std::string &name) const
Get adapter state.
void set_hook_interface(const HookInterface &hooks)
Set hook interface for ON_ADAPTER_SWAP dispatch.
Configuration structs with defaults.
Hook dispatch interface injected into engine subsystems.
Activate model on GPU (WARM → ACTIVE).
AdapterState
LoRA adapter lifecycle state.
@ COLD
Not loaded. No resources consumed.
Metadata for a loaded LoRA adapter.