Skip to content

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.

Show partial LoRA application for int8 models

Bowen Xue4c5ace3cf8d5
diff --git a/freevideo_engine/comfy_upload.py b/freevideo_engine/comfy_upload.py
index 81389b1..cc7b408 100644
--- a/freevideo_engine/comfy_upload.py
+++ b/freevideo_engine/comfy_upload.py
@@ -99,12 +99,12 @@ def register():
@server.routes.get('/freevideo/lora/check')
async def lora_check(request):
from .comfy_assets import resolve_loras
- from .lora_check import check_file
+ from .lora_check import check_installed_file
try:
name = request.query.get('name')
path = resolve_loras(json.dumps([dict(name=name)]), folder_paths.get_filename_list('loras'),
lambda n: folder_paths.get_full_path_or_raise('loras', n))[0]['path']
- result = await asyncio.to_thread(check_file, path)
+ result = await asyncio.to_thread(check_installed_file, path)
except (OSError, ValueError, TypeError) as error:
return web.json_response({'error': str(error)}, status=400)
return web.json_response(result, headers={'Cache-Control': 'no-store'})
diff --git a/freevideo_engine/lora_cache.py b/freevideo_engine/lora_cache.py
index 4434a42..2395969 100644
--- a/freevideo_engine/lora_cache.py
+++ b/freevideo_engine/lora_cache.py
@@ -20,7 +20,7 @@ import time
from safetensors.torch import save_file
import torch
-from .lora_names import _targets
+from .lora_names import INT8_UNMERGEABLE, MODULATION, _targets, adapter_keys, int8_skip_reason, resolve_target
from .tensor_io import open_tensors
from .media_request import digest, verify_files
from .monitoring import save
@@ -28,37 +28,10 @@ from .storage import fingerprint
from . import disk_space
-# Per-block AdaLN projections that the int8 package keeps only as precomputed tables.
-MODULATION = re.compile(r'transformer_blocks\.\d+\.adaln_proj\.')
-
-
-INT8_UNMERGEABLE = ('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.')
-
-
def index_adapter(row, targets, skipped=None):
- pairs = {}
- full = []
with open_tensors(row['path']) as source:
metadata = source.metadata() or {}
- keys = source.keys()
- 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)
- if match:
- pair = pairs.setdefault(match[1], {})
- if match[2] in pair:
- raise ValueError('Duplicate LoRA factor: ' + key)
- pair[match[2]] = key
- elif canonical.endswith('.alpha'):
- pairs.setdefault(canonical[:-6], {})['alpha'] = key
- elif canonical.endswith(('.diff', '.diff_b')):
- bias = canonical.endswith('.diff_b')
- full.append((canonical[:-7] if bias else canonical[:-5], key, bias))
- else:
- raise ValueError('Unsupported LoRA tensor (no patches are ignored): ' + key)
- if not pairs and not full:
- raise ValueError('Adapter contains no LoRA factors')
+ pairs, full = adapter_keys(source.keys())
global_alpha = row.get('alpha') is not None or 'alpha' in metadata
if global_alpha:
ranks = {source.get_slice(pair['A']).get_shape()[0] for pair in pairs.values() if 'A' in pair
@@ -78,10 +51,10 @@ def index_adapter(row, targets, skipped=None):
if not math.isfinite(alpha):
raise ValueError('Nonfinite LoRA alpha')
for target, split, swap in _targets(name):
- if target not in targets and '.attn.' in target:
- target = target.replace('.attn.', '.attn.orig.', 1)
- if skipped is not None and target not in targets:
- skipped.append(('modulation' if MODULATION.match(target) else 'other_layer', target))
+ target = resolve_target(target, targets)
+ reason = int8_skip_reason(target, targets) if skipped is not None else None
+ if reason:
+ skipped.append((reason, target))
continue
expected = targets.get(target)
rows = bshape[0] if split is None else bshape[0] // 3
@@ -94,16 +67,11 @@ def index_adapter(row, targets, skipped=None):
shape = source.get_slice(key).get_shape()
for target, split, swap in _targets(name):
target += '#bias' if bias else ''
- if target not in targets and '.attn.' in target:
- target = target.replace('.attn.', '.attn.orig.', 1)
+ target = resolve_target(target, targets)
if skipped is not None:
# Quantized weights cannot take a full difference, and the int8 package
# keeps no bias or non-linear patch path yet: count each one, apply the rest.
- if target.endswith('#bias'):
- skipped.append(('bias', target))
- else:
- skipped.append(('quantized_diff' if target in targets or
- target.replace('.attn.', '.attn.orig.', 1) in targets else 'other_layer', target))
+ skipped.append((int8_skip_reason(target, targets, full=True), target))
continue
expected = targets.get(target)
actual = list(shape)
@@ -190,6 +158,7 @@ def prepare(cache, adapters, output_root=None):
changes_embedding |= target.startswith(('time_embedder.', 'time_proj.'))
changes_modulation |= bool(re.match(r'transformer_blocks\.\d+\.adaln_proj\.', target))
identity = {'source_manifest_sha256': digest(manifest_path), 'implementation_sha256': digest(__file__),
+ 'names_sha256': digest(Path(__file__).with_name('lora_names.py')),
'torch': str(torch.__version__), 'adapters': [{k: v for k, v in row.items() if k != 'path'} for row in adapters],
'arithmetic': 'prepared FP8 dequantization; FP32 delta, weight-dtype merge; original FP8 granularity'}
key = hashlib.sha256(json.dumps(identity, sort_keys=True).encode()).hexdigest()
diff --git a/freevideo_engine/lora_check.py b/freevideo_engine/lora_check.py
index f2dd6ff..cba3a75 100644
--- a/freevideo_engine/lora_check.py
+++ b/freevideo_engine/lora_check.py
@@ -1,8 +1,9 @@
"""Tell from a LoRA file's header alone whether it can be used with the FreeVideo model.
-Only the key names and tensor shapes are read; no weights are loaded. The module
-list below is the model's fixed layout, so the verdict needs no prepared model.
-The engine still makes the exact check when it merges the adapter.
+Only the key names and tensor shapes are read; no weights are loaded. The fixed
+layout supports precision-independent checks without a prepared model. The UI
+also uses the active int8 manifest's linear index to count skipped patches.
+The engine still makes the exact check when it prepares the adapter.
"""
import json
import os
@@ -10,7 +11,7 @@ import re
import struct
import threading
-from .lora_names import _targets
+from .lora_names import INT8_UNMERGEABLE, _targets, adapter_keys, int8_skip_reason, resolve_target
MAX_HEADER_BYTES = 64 * 1024 * 1024
BLOCKS, REFINER_BLOCKS = 50, 2
@@ -119,47 +120,55 @@ def _block(target):
return int(found[1]) + 1 if found else None
-def assess(shapes):
+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."""
+ 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's
+ skipped patch categories; 'int8-unmergeable' means every patch was skipped."""
keys = list(shapes)
- 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)
- if match:
- pairs.setdefault(match[1], {})[match[2]] = shapes[key]
- elif canonical.endswith('.alpha'):
- pairs.setdefault(canonical[:-6], {})
- elif canonical.endswith(('.diff', '.diff_b')):
- bias = canonical.endswith('.diff_b')
- full.append((canonical[:-7] if bias else canonical[:-5], shapes[key], bias))
- else:
- return _bad('other-model' if family(keys) else 'format', keys, layer=key)
+ try:
+ pairs, full = adapter_keys(keys)
+ except ValueError:
+ return _bad('other-model' if family(keys) else 'format', keys, layer=None)
if not any('A' in pair for pair in pairs.values()) and not full:
return _bad('format', keys, layer=None)
- wrong = []
+ wrong, applied = [], set()
+ skipped = [] if skipped is None else skipped
for name, pair in pairs.items():
if not {'A', 'B'} <= pair.keys():
return _bad('format', keys, layer=name)
- a, b = pair['A'], pair['B']
+ a, b = shapes[pair['A']], shapes[pair['B']]
if len(a) != 2 or len(b) != 2 or a[0] != b[1] or a[0] <= 0:
return _bad('format', keys, layer=name)
for target, split, swap in _targets(name):
- found = _find(target)
+ if int8_targets is not None:
+ target = resolve_target(target, int8_targets)
+ reason = int8_skip_reason(target, int8_targets)
+ if reason:
+ skipped.append((reason, target))
+ continue
+ if target in applied:
+ return _bad('format', keys, layer=target)
+ applied.add(target)
+ found = target if int8_targets is not None else _find(target)
if found is None:
if family(keys):
return _bad('other-model', keys, layer=name)
continue # a name this table does not list: the engine makes the exact check
- expected = LAYOUT[found]
+ expected = int8_targets[found] if int8_targets is not None else LAYOUT[found]
rows = b[0] if split is None else b[0] // 3
if expected is UNCHECKED:
continue
if (split is not None and b[0] % 3) or (swap and rows % 2) or list(expected) != [rows, a[1]]:
wrong.append((found, list(expected), [rows, a[1]]))
- for name, shape, bias in full:
+ for name, key, bias in full:
+ shape = shapes[key]
for target, split, swap in _targets(name):
+ if int8_targets is not None:
+ target = resolve_target(target + ('#bias' if bias else ''), int8_targets)
+ skipped.append((int8_skip_reason(target, int8_targets, full=True), target))
+ continue
found = _find(target)
if found is None:
if family(keys):
@@ -179,6 +188,8 @@ def assess(shapes):
if wrong:
layer, expected, actual = wrong[0]
return dict(reason='shape', family=None, layer=layer, block=_block(layer), expected=expected, actual=actual, count=len(wrong))
+ if int8_targets is not None and not applied:
+ return _bad('int8-unmergeable', keys)
return None
@@ -192,11 +203,14 @@ def summarize(shapes, metadata):
return dict(keys=len(shapes), first=first, base=base)
-def check_file(path):
+def check_file(path, *, int8_targets=None):
"""{'usable', 'reason', ...} for a LoRA file, remembered until the file changes."""
try:
stat = os.stat(path)
- stamp = (str(path), stat.st_size, stat.st_mtime_ns)
+ # The same file can be checked against a different installed model while
+ # the page stays open. Never reuse its int8 verdict for another index.
+ target_stamp = None if int8_targets is None else tuple(sorted((name, tuple(shape)) for name, shape in int8_targets.items()))
+ stamp = (str(path), stat.st_size, stat.st_mtime_ns, target_stamp)
except OSError:
return {'usable': False, 'reason': 'unreadable'}
with _LOCK:
@@ -204,8 +218,11 @@ def check_file(path):
return dict(_CACHE[stamp])
try:
shapes, metadata = read_header(path)
- problem = assess(shapes)
+ skipped = []
+ problem = assess(shapes, int8_targets=int8_targets, skipped=skipped)
result = {'usable': problem is None, 'reason': None, **(problem or {}), 'summary': summarize(shapes, metadata)}
+ if int8_targets is not None:
+ result['partial'] = len(skipped)
except (OSError, ValueError):
result = {'usable': False, 'reason': 'unreadable'}
with _LOCK:
@@ -215,7 +232,31 @@ def check_file(path):
return dict(result)
+def check_installed_file(path):
+ """Header check for the same installed cache generation uses; no Torch import.
+
+ Unknown installation/manifest means the precision-independent check, never an
+ assumed int8 warning. Only the precision leaves the server, not model paths.
+ """
+ from .comfy_bridge import installation
+ from .long_paths import io_path
+ precision, targets = None, None
+ try:
+ _, machine = installation()
+ manifest = json.loads((io_path(machine['cache']) / 'manifest.json').read_text(encoding='utf-8'))
+ precision = manifest.get('precision')
+ if precision == 'int8':
+ targets = {name: spec['weight_shape'] for name, spec in manifest['linears'].items()}
+ if any(not isinstance(shape, list) or len(shape) != 2 or
+ any(type(n) is not int or n <= 0 for n in shape) for shape in targets.values()):
+ raise ValueError('Invalid linear index')
+ except (OSError, ValueError, KeyError, TypeError, AttributeError):
+ precision, targets = None, None
+ return dict(check_file(path, int8_targets=targets), precision=precision)
+
+
def require_usable(path):
"""Stop a request before generation starts when a LoRA cannot work with the model."""
- if not check_file(path)['usable']:
- raise ValueError(UNUSABLE)
+ result = check_installed_file(path)
+ if not result['usable']:
+ raise ValueError(INT8_UNMERGEABLE if result['reason'] == 'int8-unmergeable' else UNUSABLE)
diff --git a/freevideo_engine/lora_names.py b/freevideo_engine/lora_names.py
index 9694bb8..16a2ca5 100644
--- a/freevideo_engine/lora_names.py
+++ b/freevideo_engine/lora_names.py
@@ -2,6 +2,52 @@
import re
+# Per-block projections absent from the int8 package's linear index.
+MODULATION = re.compile(r'transformer_blocks\.\d+\.adaln_proj\.')
+INT8_UNMERGEABLE = ('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.')
+
+
+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)
+ if match:
+ pair = pairs.setdefault(match[1], {})
+ if match[2] in pair:
+ raise ValueError('Duplicate LoRA factor: ' + key)
+ pair[match[2]] = key
+ elif canonical.endswith('.alpha'):
+ pairs.setdefault(canonical[:-6], {})['alpha'] = key
+ elif canonical.endswith(('.diff', '.diff_b')):
+ bias = canonical.endswith('.diff_b')
+ full.append((canonical[:-7] if bias else canonical[:-5], key, bias))
+ else:
+ raise ValueError('Unsupported LoRA tensor (no patches are ignored): ' + key)
+ if not pairs and not full:
+ raise ValueError('Adapter contains no LoRA factors')
+ return pairs, full
+
+
+def resolve_target(target, targets):
+ if target not in targets and '.attn.' in target:
+ target = target.replace('.attn.', '.attn.orig.', 1)
+ return target
+
+
+def int8_skip_reason(target, targets, *, full=False):
+ """The online int8 patch policy, shared with the header-only check."""
+ if full:
+ if target.endswith('#bias'):
+ return 'bias'
+ return 'quantized_diff' if resolve_target(target, targets) in targets else 'other_layer'
+ if target not in targets:
+ return 'modulation' if MODULATION.match(target) else 'other_layer'
+ return None
+
+
def _targets(name):
prefixes = ('base_model.model.', 'diffusion_model.', 'model.diffusion_model.', 'transformer.')
while any(name.startswith(prefix) for prefix in prefixes):
diff --git a/freevideo_engine/lora_online_cache.py b/freevideo_engine/lora_online_cache.py
index 879ed47..92b2c7d 100644
--- a/freevideo_engine/lora_online_cache.py
+++ b/freevideo_engine/lora_online_cache.py
@@ -57,6 +57,7 @@ def prepare(cache, adapters, output_root=None):
return path, dict(report, mode='fused', reason='Adapter includes non-linear or modulation patches')
identity = dict(source_manifest_sha256=digest(cache / 'manifest.json'),
implementation_sha256=digest(__file__), index_sha256=digest(Path(__file__).with_name('lora_cache.py')),
+ names_sha256=digest(Path(__file__).with_name('lora_names.py')),
adapters=[{k: v for k, v in row.items() if k != 'path'} for row in adapters],
arithmetic=('FP8' if precision == 'fp8' else 'ConvRot int8') + ' base plus independent BF16 low-rank branches')
key = hashlib.sha256(json.dumps(identity, sort_keys=True).encode()).hexdigest()
diff --git a/web/lora_check.js b/web/lora_check.js
index 14db459..39f0c87 100644
--- a/web/lora_check.js
+++ b/web/lora_check.js
@@ -2,12 +2,15 @@
const FAMILIES = {wan: 'Wan 2.x', hunyuan: 'HunyuanVideo', ltx: 'LTX-Video', sd: 'Stable Diffusion'};
const size = shape => Array.isArray(shape) ? shape.join('×') : '';
-/** One short reason, and the lines behind it for the "Details" fold. Null when the LoRA can be used. */
+/** Row notice: partial application has no details; unusable files keep their explanation. */
export function describeVerdict(verdict, t) {
- if (!verdict || verdict.usable !== false) return null;
+ if (!verdict) return null;
+ if (verdict.usable !== false) return verdict.usable === true && verdict.precision === 'int8' && verdict.partial > 0
+ ? {partial: true, reason: t('Partly applied', '此 LoRA 部分生效')} : null;
const family = FAMILIES[verdict.family];
let reason;
if (verdict.reason === 'unreadable') reason = t('the file could not be read. It may be incomplete; download it again.', '文件无法读取,可能未下载完整,请重新下载');
+ 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 reason = family ? t(`made for ${family}`, `这是给 ${family} 训练的 LoRA`) : t('not made for the FreeVideo model', '不适用于 FreeVideo 的模型');
@@ -37,23 +40,24 @@ export function feedbackDraft(name, verdict, described, t = (en) => en) {
return {title: (t('[Feedback] LoRA compatibility misjudged: ', '[Feedback] LoRA 兼容判断有误:') + base).slice(0, 120), text, diagnostics};
}
-/** Verdicts by LoRA name, read once per list refresh. A check that fails to run says nothing, so the LoRA stays usable. */
+/** Verdicts by name. Refresh also checks the currently installed model; failures say nothing. */
export function createVerdicts(fetchApi) {
let known = new Map(), pending = new Map();
return {
peek: name => known.get(name),
clear() { known = new Map(); pending = new Map(); },
- async get(name) {
- if (known.has(name)) return known.get(name);
+ async get(name, {refresh = false} = {}) {
+ if (!refresh && known.has(name)) return known.get(name);
if (!pending.has(name)) {
const mine = pending, request = (async () => {
try {
const response = await fetchApi('/freevideo/lora/check?' + new URLSearchParams({name}), {cache: 'no-store'});
const verdict = response.ok ? await response.json() : null;
- if (verdict && typeof verdict.usable === 'boolean' && mine === pending) known.set(name, verdict);
- if (!verdict && mine === pending) pending.delete(name);
+ if (mine !== pending) return null;
+ if (verdict && typeof verdict.usable === 'boolean') known.set(name, verdict);
return verdict;
} catch { return null; }
+ finally { mine.delete(name); }
})();
pending.set(name, request);
}
diff --git a/web/studio.css b/web/studio.css
index 47ebee4..360665d 100644
--- a/web/studio.css
+++ b/web/studio.css
@@ -220,7 +220,7 @@
@media(max-width:680px){.fv-studio .fv-chain-part{gap:8px;padding-left:4px}}
.fv-studio .fv-request-assets{font-size:12px;line-height:1.5;margin:0 0 8px}
-.fv-lora-problem{grid-column:var(--lora-lead,2)/span 3;grid-row:4;display:flex;flex-direction:column;align-items:flex-start;gap:6px;font-size:var(--fv-micro)}.fv-lora-problem p{margin:0;color:var(--fv-danger)}.fv-lora-problem[hidden]{display:none}.fv-lora-why summary{cursor:pointer;color:var(--fv-muted)}.fv-lora-why pre{margin:6px 0 0;white-space:pre-wrap;word-break:break-all;color:var(--fv-muted);font:inherit;font-family:ui-monospace,monospace}.fv-lora-row[data-unusable=true] select{color:var(--fv-muted)}
+.fv-lora-problem{grid-column:var(--lora-lead,2)/span 3;grid-row:4;display:flex;flex-direction:column;align-items:flex-start;gap:6px;font-size:var(--fv-micro)}.fv-lora-problem p{margin:0;color:var(--fv-danger)}.fv-lora-problem.fv-lora-partial{color:var(--fv-muted)}.fv-lora-problem[hidden]{display:none}.fv-lora-why summary{cursor:pointer;color:var(--fv-muted)}.fv-lora-why pre{margin:6px 0 0;white-space:pre-wrap;word-break:break-all;color:var(--fv-muted);font:inherit;font-family:ui-monospace,monospace}.fv-lora-row[data-unusable=true] select{color:var(--fv-muted)}
.fv-lora-row[data-unusable=true]{cursor:default}.fv-lora-row[data-unusable=true] :is(input[type=number],input[type=checkbox]){opacity:.45}.fv-lora-row[data-unusable=true] select{opacity:1}.fv-lora-row[data-unusable=true] :is(.fv-lora-trigger,.fv-lora-range){display:none}
/* The queued count follows the part number; when the line is too narrow it wraps out of sight. */
.fv-studio .fv-chain-position:has(.fv-chain-queued){display:flex;flex-wrap:wrap;column-gap:0;line-height:1.4;max-height:1.4em;overflow:hidden}
diff --git a/web/studio.js b/web/studio.js
index 1174493..552ec4c 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -298,6 +298,7 @@ export function loraPanel(node, panel, {promptNode = null} = {}) {
let skipped = 0;
const idleNote = () => loraWarning() + (skipped ? t(skipped === 1 ? ' 1 other LoRA file in the folder is not in .safetensors format and is not listed.' : ` ${skipped} other LoRA files in the folder are not in .safetensors format and are not listed.`, ` 文件夹中另有 ${skipped} 个 LoRA 文件不是 .safetensors 格式,未列出。`) : '');
const verdicts = createVerdicts((path, options) => api.fetchApi(path, options));
+ let rowChecks = [];
let focusGrip = null;
const read = () => { const rows = JSON.parse(value(node, 'adapters') || '[]'); if (!Array.isArray(rows) || rows.length > 32) throw new Error(t('Use at most 32 LoRAs', '最多使用 32 个 LoRA')); return rows; };
function syncPrompt(rows) {
@@ -391,6 +392,7 @@ export function loraPanel(node, panel, {promptNode = null} = {}) {
if (rendering) { renderAgain = true; return; }
rendering = true;
try {
+ rowChecks = [];
list.replaceChildren(); clear.remove();
const rows = read();
syncPrompt(rows);
@@ -443,11 +445,22 @@ export function loraPanel(node, panel, {promptNode = null} = {}) {
if (row.enabled !== false || wrap.dataset.unusable === 'true' || event.target.closest('button,select,input,.fv-lora-grip')) return;
row.enabled = true; write(rows);
};
+ let marked = null;
const mark = verdict => {
+ const stamp = JSON.stringify(verdict);
+ if (stamp === marked) return;
+ marked = stamp;
const described = describeVerdict(verdict, t);
- wrap.dataset.unusable = String(Boolean(described));
- problem.hidden = !described; off.hidden = off.hidden || Boolean(described);
+ const unusable = verdict.usable === false;
+ wrap.dataset.unusable = String(unusable);
+ problem.classList.toggle('fv-lora-partial', Boolean(described?.partial));
+ problem.hidden = !described || (described.partial && (row.enabled === false || Number(row.strength ?? 1) === 0));
+ off.hidden = row.enabled !== false || unusable;
+ enabled.checked = row.enabled !== false; enabled.disabled = unusable;
+ strength.disabled = trigger.disabled = unusable || row.enabled === false;
+ select.disabled = !unusable && row.enabled === false;
if (!described) return;
+ if (described.partial) { problem.textContent = described.reason; return; }
enabled.checked = false; enabled.disabled = true; strength.disabled = trigger.disabled = true; select.disabled = false;
const fold = el('details', null, 'fv-lora-why'), why = el('pre', described.lines.join('\n'));
const report = button(t('Report a mistake', '报告误判'), () => {
@@ -455,12 +468,16 @@ export function loraPanel(node, panel, {promptNode = null} = {}) {
window.open(feedbackIssueURL(draft.text, productVersion(), draft.diagnostics, draft.title), '_blank', 'noopener');
});
fold.append(el('summary', t('Details', '详情')), why, report);
- problem.replaceChildren(el('p', t('Cannot be used: ', '不能使用:') + described.reason), fold);
+ problem.replaceChildren(el('p', (verdict.reason === 'int8-unmergeable' ? '' : t('Cannot be used: ', '不能使用:')) + described.reason), fold);
if (row.enabled !== false) queueMicrotask(() => disableUnusable(row.name));
};
+ const check = refresh => verdicts.get(row.name, {refresh}).then(verdict => {
+ if (verdict && !disposed && wrap.isConnected && select.value === row.name) mark(verdict);
+ });
+ rowChecks.push(check);
const known = verdicts.peek(row.name);
if (known) mark(known);
- else verdicts.get(row.name).then(verdict => { if (verdict && !disposed && wrap.isConnected && select.value === row.name) mark(verdict); });
+ else check(false);
list.append(wrap);
loadTriggers(row.name).catch(error => { if (!disposed && trigger.isConnected) note.textContent = error.message; });
});
@@ -494,8 +511,11 @@ export function loraPanel(node, panel, {promptNode = null} = {}) {
const configure = node.onConfigure;
// Only the persistent node panel participates in graph loading.
if (panel.classList.contains('fv-lora-panel')) node.onConfigure = function (...args) { const result = configure?.apply(this, args); queueMicrotask(render); return result; };
+ // Setup can bind another installation while this panel stays open. Recheck
+ // its model context without rebuilding rows or interrupting edits.
+ const modelTimer = setInterval(() => { for (const check of rowChecks) check(true); }, 5000);
render(); refresh();
- const dispose = () => { disposed = true; window.removeEventListener('freevideo-loras', changed); window.removeEventListener('freevideo-lora-triggers', triggersChanged); };
+ const dispose = () => { disposed = true; clearInterval(modelTimer); window.removeEventListener('freevideo-loras', changed); window.removeEventListener('freevideo-lora-triggers', triggersChanged); };
dispose.refresh = refresh;
return dispose;
}