Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Read LoRA factors named without .weight and explain acceleration LoRAs
Bowen Xue6e5d9b0ca0ba
diff --git a/freevideo_engine/lora_check.py b/freevideo_engine/lora_check.pyindex c031fac..0532161 100644--- a/freevideo_engine/lora_check.py+++ b/freevideo_engine/lora_check.py@@ -11,7 +11,7 @@ import reimport structimport threading-from .lora_names import INT8_UNMERGEABLE, _targets, adapter_keys, int8_skip_reason, resolve_target+from .lora_names import INT8_UNMERGEABLE, _targets, adapter_keys, int8_skip_reason, resolve_target, supportedMAX_HEADER_BYTES = 64 * 1024 * 1024BLOCKS, REFINER_BLOCKS = 50, 2@@ -58,6 +58,11 @@ def _layout():LAYOUT = _layout()UNUSABLE = 'This LoRA was not trained for the FreeVideo model and cannot be used.'+ACCELERATION = ('This acceleration LoRA was made for the original model and cannot be used. '+ 'The FreeVideo model is already accelerated and does not need one.')+# Step-distillation adapters (for example parallel-decoding ones) ship a bank of+# whole replacement output heads, one per stretch of the sampling schedule.+HEADS = ('proj_out', 'audio_proj_out')_CACHE, _LOCK = {}, threading.Lock()@@ -115,6 +120,17 @@ def _bad(reason, keys, **detail):return dict(reason=reason, family=family(keys) if reason == 'other-model' else None, **detail)+def _head_bank(shapes):+ """The first tensor that is a stack of whole output-head weights, or None."""+ for key, shape in shapes.items():+ if not key.endswith('.weight') or len(shape) != 3:+ continue+ name = _targets(key[:-7])[0][0]+ if name in HEADS and list(shape[1:]) == list(LAYOUT[name]):+ return key+ return None++def _block(target):found = re.search(r'blocks\.(\d+)\.', target)return int(found[1]) + 1 if found else None@@ -122,15 +138,22 @@ def _block(target):def assess(shapes, *, int8_targets=None, skipped=None):"""None when the adapter fits, else why not: reason 'other-model' (names of another model), 'shape' (our names,- a different size) or 'format' (not a LoRA we can read). 'layer' and the sizes say where. A layer name the table- does not list, in a file that matches no other known model, is let through.+ a different size), 'acceleration' (a step-distillation adapter that replaces the output heads and needs its own+ sampler) or 'format' (not a LoRA we can read; 'layer' names the first tensor that is not a LoRA factor).+ 'layer' and the sizes say where. A layer name the table does not list, in a file that matches no other known+ model, is let through.With int8_targets, use the installed linear shapes and collect the runtime'sskipped patch categories; 'int8-unmergeable' means every patch was skipped."""keys = list(shapes)+ heads = _head_bank(shapes)+ if heads:+ return _bad('acceleration', keys, layer=heads)try:pairs, full = adapter_keys(keys)except ValueError:- return _bad('other-model' if family(keys) else 'format', keys, layer=None)+ if family(keys):+ return _bad('other-model', keys, layer=None)+ return _bad('format', keys, layer=next((key for key in keys if not supported(key)), None))if not any('A' in pair for pair in pairs.values()) and not full:return _bad('format', keys, layer=None)wrong, applied = [], set()@@ -263,4 +286,4 @@ def require_usable(path):"""Stop a request before generation starts when a LoRA cannot work with the model."""result = check_installed_file(path)if not result['usable']:- raise ValueError(INT8_UNMERGEABLE if result['reason'] == 'int8-unmergeable' else UNUSABLE)+ raise ValueError({'int8-unmergeable': INT8_UNMERGEABLE, 'acceleration': ACCELERATION}.get(result['reason'], UNUSABLE))diff --git a/freevideo_engine/lora_names.py b/freevideo_engine/lora_names.pyindex 16a2ca5..41d6483 100644--- a/freevideo_engine/lora_names.py+++ b/freevideo_engine/lora_names.py@@ -8,17 +8,33 @@ INT8_UNMERGEABLE = ('This LoRA changes parts of the model that the int8 version'so it cannot be used for now. LoRAs that change only linear layers work.')+# Factor names trainers write: PEFT lora_A/lora_B, Kohya and diffusers+# lora_down/lora_up, each with or without the trailing ".weight".+_FACTOR = re.compile(r'(.+)\.lora_(A|B|down|up)(?:\.weight)?')+_SIDE = {'A': 'A', 'down': 'A', 'B': 'B', 'up': 'B'}+++def _canonical(key):+ return key.replace('.default.', '.')+++def supported(key):+ """Whether adapter_keys can index this tensor name."""+ canonical = _canonical(key)+ return bool(_FACTOR.fullmatch(canonical)) or canonical.endswith(('.alpha', '.diff', '.diff_b'))++def adapter_keys(keys):"""Index factor/difference names without reading any tensors."""pairs, full = {}, []for key in keys:- canonical = key.replace('.default.', '.').replace('.lora_down.weight', '.lora_A.weight').replace('.lora_up.weight', '.lora_B.weight')- match = re.fullmatch(r'(.+)\.lora_([AB])\.weight', canonical)+ canonical = _canonical(key)+ match = _FACTOR.fullmatch(canonical)if match:- pair = pairs.setdefault(match[1], {})- if match[2] in pair:+ pair, side = pairs.setdefault(match[1], {}), _SIDE[match[2]]+ if side in pair:raise ValueError('Duplicate LoRA factor: ' + key)- pair[match[2]] = key+ pair[side] = keyelif canonical.endswith('.alpha'):pairs.setdefault(canonical[:-6], {})['alpha'] = keyelif canonical.endswith(('.diff', '.diff_b')):diff --git a/freevideo_engine/lora_online_cache.py b/freevideo_engine/lora_online_cache.pyindex 92b2c7d..c00096f 100644--- a/freevideo_engine/lora_online_cache.py+++ b/freevideo_engine/lora_online_cache.py@@ -21,7 +21,7 @@ def _supported(adapters, linears, skip_modulation=False):for adapter in adapters:with open_tensors(adapter['path']) as source:for key in source.keys():- name = re.sub(r'\.(?:lora_[AB]\.weight|lora_(?:down|up)\.weight|alpha)$',+ name = re.sub(r'\.(?:lora_(?:A|B|down|up)(?:\.weight)?|alpha)$','', key.replace('.default.', '.'))for target, _, _ in _targets(name):if target not in linears and '.attn.' in target:diff --git a/web/error_panel.js b/web/error_panel.jsindex 5316c60..fbdeee1 100644--- a/web/error_panel.js+++ b/web/error_panel.js@@ -65,6 +65,10 @@ const PLAIN_ERRORS = ['Unsupported LoRA tensor (no patches are ignored): ', 'Adapter contains no LoRA factors', 'Expected matching 2-D LoRA factors', 'Incomplete LoRA pair'],title: ['This LoRA cannot be used', '此 LoRA 无法使用'],summary: ['This LoRA is not made for the FreeVideo model. Turn it off or remove it, then generate again.', '此 LoRA 不适用于 FreeVideo 的模型。请关闭或移除后重新生成。']},+ {key: 'lora-acceleration', message: 'This acceleration LoRA was made for the original model and cannot be used. The FreeVideo model is already accelerated and does not need one.',+ title: ['This LoRA cannot be used', '此 LoRA 无法使用'],+ summary: ['The FreeVideo model is already accelerated and does not need an acceleration LoRA. Turn this LoRA off or remove it, then generate again.',+ 'FreeVideo 的模型已经加速,无需加速 LoRA。请关闭或移除此 LoRA 后重新生成。']},{key: 'lora-int8', message: 'This LoRA changes parts of the model that the int8 version cannot merge yet, so it cannot be used for now. LoRAs that change only linear layers work.',title: ['This LoRA cannot be used', '此 LoRA 无法使用'],summary: ['The int8 version cannot merge the layers this LoRA changes yet. Turn it off or remove it, then generate again.',@@ -637,7 +641,7 @@ export function createErrorPanel(t) {copy.hidden = generated; copyInside.hidden = !generated; copyInside.textContent = copy.textContent;// For a generation failure the note on removed text sits in the technical details, beside the copy button.privacy.hidden = generated; privacyInside.hidden = !generated;- const lora = advice.kind === 'lora-unusable' || advice.kind === 'lora-int8';+ const lora = ['lora-unusable', 'lora-acceleration', 'lora-int8'].includes(advice.kind);// An int8 limit is not a judgement, so there is no mistake to report.github.hidden = !generated || advice.kind === 'lora-int8'; githubLora = lora;github.textContent = lora ? t('Report a mistake', '报告误判') : t('Report a problem', '提交问题');diff --git a/web/lora_check.js b/web/lora_check.jsindex 39f0c87..1889d7a 100644--- a/web/lora_check.js+++ b/web/lora_check.js@@ -13,6 +13,8 @@ export function describeVerdict(verdict, t) {else if (verdict.reason === 'int8-unmergeable') reason = t('This LoRA cannot be used', '此 LoRA 无法使用');else if (verdict.reason === 'format') reason = t('not a LoRA file FreeVideo can read', '不是 FreeVideo 能读取的 LoRA 文件');else if (verdict.reason === 'shape') reason = t('does not match the current model', '和当前模型的结构不匹配');+ else if (verdict.reason === 'acceleration') reason = t('an acceleration LoRA made for the original model. The FreeVideo model is already accelerated and does not need one',+ '这是为原版模型制作的加速 LoRA。FreeVideo 的模型已经加速,无需此类 LoRA');else reason = family ? t(`made for ${family}`, `这是给 ${family} 训练的 LoRA`) : t('not made for the FreeVideo model', '不适用于 FreeVideo 的模型');const summary = verdict.summary || {};const lines = [];