Archived
LoRA for image and video generators: - civitai and Hugging Face adapter files as published: kohya, ComfyUI and diffusers/PEFT key names; LoRA, LoCon, LoHa, LoKr and full-weight diffs; DoRA, OFT and Tucker are refused by name - stacked per request with a strength each, through the `loras` field or <lora:name:strength> tags in the prompt; --lora-dir serves every file in a directory, GET /v1/loras lists them, and --max-loras / --max-lora-rank size the slots on the card (generators default to rank 64) - Krea 2, Qwen-Image 2.1, FLUX.3 [klein], MiniMax H3, LTX-2.5, Anima and SDXL New models: - Anima (base, aesthetic and turbo): Cosmos-Predict2 DiT with the Qwen3-0.6B text encoder and the Qwen-Image VAE, on one card - Stable Diffusion XL and its single-file finetunes (Illustrious, NoobAI including V-Pred, Pony), read as civitai ships them, with the Euler, Euler a and DPM++ 2M samplers Recipes: - q38-27b-mxfp4-df2: any bf16 Qwen3.8-27B or finetune at MXFP4 with the DFlash2 drafter - Krea 2 finetunes from civitai: scripts/krea2_native.py reads Krea's own key names, and krea-2-fp8-unscaled keeps a plain-fp8 file's codes exactly Changes: --max-num-batched-tokens defaults to 2048 (was 8192). Plugin ABI 25: out-of-tree plugins must be rebuilt.
48 lines
2.2 KiB
C++
48 lines
2.2 KiB
C++
/* lora/config.h -- what runtime LoRA was started with (--lora, --lora-dir, --max-loras,
|
|
* --max-lora-rank, --lora-target-modules). Read by declare (which sites and pools exist), by the
|
|
* adapter manager (what may be loaded into them) and by nothing else.
|
|
*
|
|
* Off unless asked for: with no adapter named, no --lora-dir and no --max-loras, `enabled()` is
|
|
* false, declare appends nothing, the program has no pool and no extra op, and no step carries an
|
|
* adapter slot.
|
|
*
|
|
* A text model's slot holds one adapter; a generator's holds the combination one request asks for
|
|
* (several adapter files at their strengths, core/lora/adapter.h), so its slots are not tied to
|
|
* the number of adapters named. */
|
|
#pragma once
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace rad {
|
|
|
|
struct LoraConfig {
|
|
/* NAME=PATH pairs to load at startup, in the order given: a PEFT directory, or for a
|
|
* generator one .safetensors file. */
|
|
std::vector<std::pair<std::string, std::string>> adapters;
|
|
/* A generator's adapter directory: a request may name any NAME.safetensors under it. */
|
|
std::string dir;
|
|
/* Adapter slots resident at once. 0: as many as were named, and two with --lora-dir alone. */
|
|
int max_loras = 0;
|
|
/* The rank every slot is sized for; an adapter of lower rank is zero-padded into it. 0: the
|
|
* default, kDefaultRank for a text model and kDefaultGenRank for a generator, whose adapter
|
|
* files run to rank 32 and are stacked. */
|
|
int max_rank = 0;
|
|
static constexpr int kDefaultRank = 16, kDefaultGenRank = 64;
|
|
int rank(bool generator) const {
|
|
return max_rank > 0 ? max_rank : generator ? kDefaultGenRank : kDefaultRank;
|
|
}
|
|
/* HF module leaf names (q_proj, gate_proj, in_proj_qkv, ...) the sites are built for, sorted
|
|
* and unique. Empty: the union of the startup adapters' target_modules. */
|
|
std::vector<std::string> targets;
|
|
|
|
bool enabled() const { return max_loras > 0 || !adapters.empty() || !dir.empty(); }
|
|
int slots() const {
|
|
const int named = (int)adapters.size();
|
|
if (max_loras > 0) return max_loras;
|
|
return named > 0 ? named : (dir.empty() ? 0 : 2);
|
|
}
|
|
};
|
|
|
|
} /* namespace rad */
|