33#include <unordered_map>
39struct llama_adapter_lora;
69 bool load(
const std::string& name,
70 const std::filesystem::path& adapter_path,
202 struct AdapterEntry {
204 std::filesystem::path path;
209 size_t ram_bytes = 0;
210 std::string tier_name;
211 std::unordered_map<std::string, std::string> metadata;
220 static AdapterInfo make_info(
const AdapterEntry& entry);
230 bool fire_swap_hook(
const std::string&
current,
231 const std::string& target,
234 std::unordered_map<std::string, AdapterEntry> adapters_;
235 std::string active_name_;
236 mutable std::mutex adapter_mutex_;
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 release_handles_for_model(llama_model *model, llama_context *ctx)
Free a base model's adapter handles, KEEPING the registrations (gh#164).
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).
@ optional
optional: every escape asks the host's path approver
AdapterState
LoRA adapter lifecycle state.
@ COLD
Not loaded. No resources consumed.
Metadata for a loaded LoRA adapter.