Conversation
Added functionality to extract and process LoRA tags from the prompt.
Performance Review Report: stable-diffusion.cppImpact Classification: Moderate ImpactAnalysis of 11 functions in Commit ContextSingle commit between versions: "Implement LoRA tag extraction" (523b834). This commit adds regex-based LoRA tag parsing functionality in Most-Impacted Functionsapply_binary_op (BF16 tensor addition) - CRITICAL ML OPERATION
get_all_blocks (model structure traversal)
Hashtable end() (configuration lookup)
_M_is_line_terminator (regex operations)
Code Change JustificationNo direct source modifications to analyzed functions. Performance differences result from:
The new LoRA feature justifies the rebuild, with side-effect optimizations improving critical paths. Power ConsumptionAnalysis tool encountered technical error preventing quantitative measurement. Qualitative assessment suggests neutral to slightly positive impact based on throughput improvements in most functions, particularly the critical Overall AssessmentNet positive performance trajectory. The most critical function ( See the complete breakdown in Version Insights |
|
@loci-dev give me the names of all the functions that were impacted in this PR |
|
Based on the performance review report, here are all 11 functions that were impacted in this PR:
The report explicitly names 6 functions and indicates there are 11 total functions analyzed in |
0219cb4 to
17a1e1e
Compare
Mirrored from leejet/stable-diffusion.cpp#1231
Problem
The sd-server ignores
<lora:name:weight>tags in prompts sent via the/sdapi/v1/txt2imgand/sdapi/v1/img2imgAPI endpoints.LoRA tags work correctly in the CLI (
sd-cli) because it callsextract_and_remove_lora()on every generation. However, the server only calls this function once at startup when parsing command-line arguments. When handling API requests, the server copiesdefault_gen_params, updates the prompt, but never re-parses the new prompt for LoRA tags.Solution
This patch adds
extract_and_remove_lora()to thesdapi_any2imghandler function, which services both txt2img and img2img endpoints. The fix clears any pre-existing LoRA data and extracts LoRA tags from the incoming prompt, matching the behavior of the CLI.