Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: share the runtime-fingerprint parser and pack filenames, and skip the unused latent upsampler load (#6512)
[._.]/ Adam Eivy20d5e1498469
diff --git a/docs/features/video-upscale.md b/docs/features/video-upscale.mdindex a92faf6737..11c914b9ca 100644--- a/docs/features/video-upscale.md+++ b/docs/features/video-upscale.md@@ -113,14 +113,10 @@ the in-context reference at half of it (the adapter'sis the whole conditioning signal — and the distilled 8-sigma schedule is usedas-is.-Both runtimes' `ICLoraPipeline` interpret the size they are handed as the dims-of an optional latent-upsample second stage, rendering the conditioned stage-at half of it. The runners therefore request **twice** the output and skip-that second stage, so the conditioned stage renders at the output size with-the source as a native-resolution reference. Requesting the output size itself-would condition on the source downscaled by another 2× and hand the second-doubling to the latent upsampler — a pixel-faithful refinement the adapter is-not.+Both runtimes' `ICLoraPipeline` render their conditioned stage at half the size+they are handed, so the runners request **twice** the output and skip the+latent-upsample second stage (`PIPELINE_REQUEST_MULTIPLIER` in+`scripts/_upscale_contract.py` records why).On macOS the MLX q8 pack may hold the distilled model either pre-fused(`transformer-distilled.safetensors`) or as the dev transformer plus thediff --git a/scripts/_runner_common.py b/scripts/_runner_common.pyindex 569ab68fdd..1ba93f4425 100644--- a/scripts/_runner_common.py+++ b/scripts/_runner_common.py@@ -100,6 +100,15 @@ def heartbeat(stage: "str | Callable[[], str]", interval: float = 20.0):t.join(timeout=interval + 1)+# The LTX-2.5 MLX q8 pack's dev-layout files. The distilled model ships either+# pre-fused (`transformer-distilled.safetensors`) or as the dev transformer+# plus this 450-step distilled LoRA; both the render bridge+# (`generate_ltx2.py`) and the upscale runner (`upscale_ltx25.py`) resolve the+# same pair, so a re-pin of the adapter is one edit rather than two.+LTX25_DEV_TRANSFORMER_FILENAME = "transformer-dev.safetensors"+LTX25_DISTILLED_LORA_FILENAME = "ltx-2.5-22b-distilled-lora-450.safetensors"++def parse_user_loras(raw: "str | None") -> "list[tuple[str, float]]":"""Parse a `--user-loras` JSON string into a list of (path, strength) tuples.diff --git a/scripts/_upscale_contract.py b/scripts/_upscale_contract.pyindex 1fc3425eac..3702561952 100644--- a/scripts/_upscale_contract.py+++ b/scripts/_upscale_contract.py@@ -33,15 +33,18 @@ from pathlib import Path# runners make (`conditioned_stage_request` below). Temporal compression is 8# and the reference encoder needs a (1 + 8k)-frame input, so `frames % 8 == 1`# with a floor of 9.-SPATIAL_MULTIPLE = 64-FRAME_MODULUS = 8-FRAME_REMAINDER = 1-MIN_FRAMES = 9-# The VAE's spatial compression: the reference clip is resized onto this grid# before it is encoded, so a reference that is not a multiple of it gets# resampled — which for an upscaler means conditioning on a blurred source.VAE_SPATIAL_COMPRESSION = 32+# The shipped adapter's declared `reference_downscale_factor` (measured, and+# declared by `icLoraWeights.js`); `assert_reference_scale_fits` re-derives the+# same rule from the factor read off the file actually fused.+SHIPPED_REFERENCE_DOWNSCALE = 2+SPATIAL_MULTIPLE = SHIPPED_REFERENCE_DOWNSCALE * VAE_SPATIAL_COMPRESSION+FRAME_MODULUS = 8+FRAME_REMAINDER = 1+MIN_FRAMES = 9# How both `ICLoraPipeline`s interpret the `height`/`width` they are handed:# as the dims of the OPTIONAL latent-upsample stage 2, with the IC-conditioned@@ -116,7 +119,7 @@ def validate_args(args: argparse.Namespace) -> None:"""if args.width % SPATIAL_MULTIPLE or args.height % SPATIAL_MULTIPLE:raise SystemExit(- f"The two-stage LTX-2.5 pipeline requires width and height divisible by {SPATIAL_MULTIPLE}; "+ f"The LTX-2.5 upscale requires width and height divisible by {SPATIAL_MULTIPLE}; "f"got {args.width}x{args.height}.")if args.num_frames < MIN_FRAMES or args.num_frames % FRAME_MODULUS != FRAME_REMAINDER:diff --git a/scripts/generate_ltx2.py b/scripts/generate_ltx2.pyindex 306943075d..1e8e13f859 100644--- a/scripts/generate_ltx2.py+++ b/scripts/generate_ltx2.py@@ -67,7 +67,6 @@ import sysfrom pathlib import Pathfrom typing import NoReturn-DISTILLED_LORA_25 = "ltx-2.5-22b-distilled-lora-450.safetensors"DISTILLED_LORA_V11 = "ltx-2.3-22b-distilled-lora-384-1.1.safetensors"DISTILLED_LORA_LEGACY = "ltx-2.3-22b-distilled-lora-384.safetensors"@@ -86,7 +85,16 @@ os.environ.setdefault("LTX2_GEMMA_EVAL_EVERY", "1")# for direct and imported execution. _runner_common is stdlib-only at import time, so# this is safe from the ltx-2-mlx venv (no torch pulled in).sys.path.insert(0, str(Path(__file__).resolve().parent))-from _runner_common import emit_runtime_fingerprint, parse_user_loras, write_stepwise_preview # noqa: E402+from _runner_common import ( # noqa: E402+ LTX25_DISTILLED_LORA_FILENAME,+ emit_runtime_fingerprint,+ parse_user_loras,+ write_stepwise_preview,+)++# The 2.5 pack's distilled adapter, shared with the upscale runner so a re-pin+# is one edit (see _runner_common).+DISTILLED_LORA_25 = LTX25_DISTILLED_LORA_FILENAMEdef emit_status(msg: str) -> None:diff --git a/scripts/upscale_ltx25.py b/scripts/upscale_ltx25.pyindex ade65c0299..49ee05ec08 100755--- a/scripts/upscale_ltx25.py+++ b/scripts/upscale_ltx25.py@@ -22,15 +22,10 @@ gated model card:it and otherwise falls back to the remote 2.3 Gemma 3 id — a wrong encoderAND an unannounced multi-GB download — so `validate_model_dir` refuses apack that lacks it instead of letting that fallback happen.- - The recipe is the standard single-stage IC-LoRA video-to-video pass- (Lightricks' IC-LoRA guide and their ComfyUI reference workflow: distilled- schedule at the set resolution, the low-resolution clip as the reference at- half of it). `ICLoraPipeline.generate` renders its IC-conditioned stage 1- at HALF the dims it is handed and offers a latent-upsample stage 2 for the- other half, so this runner requests twice the output and skips stage 2 —- stage 1 then renders at the output size, conditioned on the source at its- native resolution, and its decode is the deliverable- (`_upscale_contract.conditioned_stage_request`).+ - The recipe is the standard single-stage IC-LoRA video-to-video pass at the+ output size with the source as the reference at half of it — see+ `PIPELINE_REQUEST_MULTIPLIER` in `_upscale_contract.py` for why that means+ requesting twice the output and skipping stage 2.- The schedule is the fixed distilled one: `DISTILLED_SIGMAS` is 8 steps.Passing no step count selects exactly that, which is why this runnerexposes no steps flag.@@ -57,7 +52,12 @@ import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).resolve().parent))-from _runner_common import emit_runtime_fingerprint, heartbeat # noqa: E402+from _runner_common import ( # noqa: E402+ LTX25_DEV_TRANSFORMER_FILENAME,+ LTX25_DISTILLED_LORA_FILENAME,+ emit_runtime_fingerprint,+ heartbeat,+)# The argv, grid and adapter contract this runner shares with the CUDA one# (#6513). Re-exported names stay module attributes, so a caller — or a test —# still reaches them as `upscale_ltx25.validate_args` / `.lora_target_keys`.@@ -76,16 +76,6 @@ from _upscale_contract import ( # noqa: E402# than a fallback — see the module docstring.TEXT_ENCODER_DIRNAME = "text_encoder"-# The two layouts the pinned q8 pack documents for the distilled model. The-# pre-fused `transformer-distilled.safetensors` is what `ICLoraPipeline.load()`-# resolves on its own; a pack that carries only the dev transformer holds the-# SAME model as dev weights plus the 450-step distilled LoRA, which the pack-# README names as the equivalent non-streaming arrangement and the runtime's-# own two-stage pipelines fuse for their distilled stage. The distilled-# schedule this runner drives is only valid on the distilled model, so dev-# WITHOUT that LoRA is a refusal, never a fallback.-DEV_TRANSFORMER_FILENAME = "transformer-dev.safetensors"-DISTILLED_LORA_FILENAME = "ltx-2.5-22b-distilled-lora-450.safetensors"# Full strength turns the dev weights INTO the distilled model — the pack's# README states the pre-fused file is this LoRA at the default strength of 1.0.DISTILLED_LORA_STRENGTH = 1.0@@ -161,23 +151,35 @@ def resolve_transformer_path(model_dir: Path) -> "Path | None":return fallback if fallback.is_file() else None-def resolve_transformer_layout(model_dir: Path) -> "tuple[Path | None, Path | None]":- """`(transformer, distilled_lora)` for the pack — see the layout constants.+def resolve_transformer_layout(model_dir: Path) -> "tuple[Path, list[tuple[str, float]]]":+ """The DiT file to fuse into, plus any LoRA the pack needs to make it the distilled model.- The pre-fused distilled transformer wins whenever present (`distilled_lora`- is then None). Otherwise the dev transformer is returned WITH the distilled- LoRA that turns it into the distilled model, and `(None, None)` when the- pack has neither the distilled file nor a dev file. A dev file whose LoRA is- missing is reported as `(dev, None)` so the caller can refuse it by name.+ The pinned q8 pack documents two layouts for the distilled model. The+ pre-fused `transformer-distilled.safetensors` is what `ICLoraPipeline.load()`+ resolves on its own and wins whenever present (no extra LoRA). A pack that+ carries only the dev transformer holds the SAME model as dev weights plus+ the 450-step distilled LoRA — the layout the pack README names as the+ equivalent non-streaming arrangement and the runtime's own pipelines fuse+ for their distilled stage — so that LoRA is returned beside it. The+ distilled schedule this runner drives is only valid on the distilled model,+ so dev WITHOUT that LoRA is a refusal, never a fallback."""distilled = resolve_transformer_path(model_dir)if distilled is not None:- return distilled, None- dev = model_dir / DEV_TRANSFORMER_FILENAME+ return distilled, []+ dev = model_dir / LTX25_DEV_TRANSFORMER_FILENAMEif not dev.is_file():- return None, None- lora = model_dir / DISTILLED_LORA_FILENAME- return dev, (lora if lora.is_file() else None)+ raise SystemExit(+ f"The LTX-2.5 pack at {model_dir} has no transformer weight file. Repair the model in Video Gen."+ )+ lora = model_dir / LTX25_DISTILLED_LORA_FILENAME+ if not lora.is_file():+ raise SystemExit(+ f"The LTX-2.5 pack at {model_dir} carries only {LTX25_DEV_TRANSFORMER_FILENAME} and not the "+ f"{LTX25_DISTILLED_LORA_FILENAME} that makes it the distilled model the upscale schedule needs. "+ "Repair the model in Video Gen."+ )+ return dev, [(str(lora), DISTILLED_LORA_STRENGTH)]def make_pipeline(pipeline_cls, model_dir: Path, transformer_path: Path, lora_paths):@@ -191,16 +193,26 @@ def make_pipeline(pipeline_cls, model_dir: Path, transformer_path: Path, lora_pathe DiT resident through prompt encoding. `lora_paths` is every adapter`_fuse_loras` will add to the DiT in ONE pass — the IC adapter, and on a devlayout the distilled LoRA beside it.++ `load()` also builds the latent upsampler for a stage 2 this runner never+ runs (`skip_stage_2`), reading a ~1 GB weight into memory that then sits+ beside the DiT for the whole render. Pre-seeding the slot makes `load()`+ skip it; nothing under `skip_stage_2` dereferences the upsampler."""class PackLayoutPipeline(pipeline_cls):def load(self):if self.dit is None and not self._loaded:self.dit = self._load_transformer_with_optional_streaming(transformer_path)+ if self.upsampler is None:+ self.upsampler = _UNUSED_UPSAMPLERsuper().load()return PackLayoutPipeline(model_dir=str(model_dir), lora_paths=list(lora_paths))+_UNUSED_UPSAMPLER = object()++def transformer_weight_keys(transformer_path: Path) -> "set[str]":"""The transformer's fusable parameter names, read from its header alone.@@ -266,9 +278,8 @@ def main() -> None:header = read_safetensors_header(args.ic_lora_path)scale = reference_downscale_factor(header)assert_reference_scale_fits(scale, args.width, args.height)- # Recorded rather than guessed: `icLoraWeights.js` holds `null` for this- # gated weight precisely because nobody had opened it, and this line is the- # measurement (#6508's registry note points here).+ # The per-install measurement the queue records beside the registry's+ # declared value — a re-pinned weight is measured, not trusted.log(f"UPSCALE_REFERENCE_DOWNSCALE:{scale}")log("STAGE:verify-adapter")@@ -282,18 +293,8 @@ def main() -> None:# move this behind a `pipe.load()`: `generate()` deliberately loads the text# encoder, encodes, frees it, and only THEN loads the transformer, so# pre-loading would hold a multi-GB DiT resident through prompt encoding.- transformer_path, distilled_lora = resolve_transformer_layout(model_dir)- if transformer_path is None:- raise SystemExit(- f"The LTX-2.5 pack at {model_dir} has no transformer weight file. Repair the model in Video Gen."- )- if transformer_path.name == DEV_TRANSFORMER_FILENAME and distilled_lora is None:- raise SystemExit(- f"The LTX-2.5 pack at {model_dir} carries only {DEV_TRANSFORMER_FILENAME} and not the "- f"{DISTILLED_LORA_FILENAME} that makes it the distilled model the upscale schedule needs. "- "Repair the model in Video Gen."- )- layout = transformer_path.name + (f" + {distilled_lora.name}" if distilled_lora else "")+ transformer_path, pack_loras = resolve_transformer_layout(model_dir)+ layout = " + ".join([transformer_path.name, *(Path(path).name for path, _ in pack_loras)])log(f"STATUS:Transformer layout: {layout}")fused = assert_adapter_fuses(args.ic_lora_path,@@ -304,21 +305,17 @@ def main() -> None:log("STAGE:load-pipeline")log(f"STATUS:Loading LTX-2.5 MLX upscale pipeline ({args.width}x{args.height}, {args.num_frames} frames)")- lora_paths = [(args.ic_lora_path, 1.0)]- if distilled_lora is not None:- lora_paths.append((str(distilled_lora), DISTILLED_LORA_STRENGTH))- pipe = make_pipeline(ICLoraPipeline, model_dir, transformer_path, lora_paths)+ pipe = make_pipeline(ICLoraPipeline, model_dir, transformer_path, [(args.ic_lora_path, 1.0), *pack_loras])output = Path(args.output)output.parent.mkdir(parents=True, exist_ok=True)request_width, request_height = conditioned_stage_request(args.width, args.height)log("STAGE:inference")with heartbeat("ltx25-upscale-inference"):- # Stage 1 renders at half the requested dims — i.e. AT the output — with- # the source as its native-resolution reference, and `skip_stage_2`- # makes that stage's decode the deliverable (see the module docstring).- # No stage-1 step count: `DISTILLED_SIGMAS` IS the distilled schedule- # (8 steps), and passing a count would truncate it.+ # Twice the output + `skip_stage_2` = one conditioned stage AT the+ # output (see `conditioned_stage_request`). No stage-1 step count:+ # `DISTILLED_SIGMAS` IS the distilled schedule (8 steps), and passing a+ # count would truncate it.pipe.generate_and_save(prompt=args.prompt,output_path=str(output),diff --git a/scripts/upscale_ltx25.test.js b/scripts/upscale_ltx25.test.jsindex 23e6ce766a..25cc779fba 100644--- a/scripts/upscale_ltx25.test.js+++ b/scripts/upscale_ltx25.test.js@@ -311,17 +311,17 @@ describe.skipIf(!pyBin)('upscale_ltx25.py — transformer header (#6512)', () =>// schedule on an un-distilled model is not a fallback, it is a wrong render.it('resolves the dev + distilled-LoRA layout, preferring a pre-fused distilled file', () => {const pack = mkdtempSync(join(tmpdir(), 'portos-ltx25-layout-'));- const layout = (dir) => call(`[p and p.name for p in runner.resolve_transformer_layout(__import__("pathlib").Path(${JSON.stringify(dir)}))]`);- expect(layout(pack)).toBe('[None, None]');+ const layout = (dir) => call(`(lambda t, loras: [t.name, [(__import__("pathlib").Path(p).name, s) for p, s in loras]])(*runner.resolve_transformer_layout(__import__("pathlib").Path(${JSON.stringify(dir)})))`);+ expect(layout(pack)).toMatch(/^REJECTED:.*no transformer weight file/);writeFileSync(join(pack, 'transformer-dev.safetensors'), '');- expect(layout(pack)).toBe("['transformer-dev.safetensors', None]");+ expect(layout(pack)).toMatch(/^REJECTED:.*carries only transformer-dev\.safetensors/);writeFileSync(join(pack, 'ltx-2.5-22b-distilled-lora-450.safetensors'), '');- expect(layout(pack)).toBe("['transformer-dev.safetensors', 'ltx-2.5-22b-distilled-lora-450.safetensors']");+ expect(layout(pack)).toBe("['transformer-dev.safetensors', [('ltx-2.5-22b-distilled-lora-450.safetensors', 1.0)]]");writeFileSync(join(pack, 'transformer-distilled.safetensors'), '');- expect(layout(pack)).toBe("['transformer-distilled.safetensors', None]");+ expect(layout(pack)).toBe("['transformer-distilled.safetensors', []]");}, PY_TEST_TIMEOUT_MS);// `ICLoraPipeline.load()` resolves the transformer only while `dit` is None,@@ -332,7 +332,7 @@ describe.skipIf(!pyBin)('upscale_ltx25.py — transformer header (#6512)', () =>const source = ['class FakeBase:',' def __init__(self, model_dir, lora_paths=None):',- ' self.model_dir = model_dir; self.lora_paths = lora_paths; self.dit = None; self._loaded = False; self.calls = []',+ ' self.model_dir = model_dir; self.lora_paths = lora_paths; self.dit = None; self.upsampler = None; self._loaded = False; self.calls = []',' def _load_transformer_with_optional_streaming(self, path):',' self.calls.append(path.name); return "dit"',' def load(self):',@@ -340,9 +340,11 @@ describe.skipIf(!pyBin)('upscale_ltx25.py — transformer header (#6512)', () =>'from pathlib import Path','pipe = runner.make_pipeline(FakeBase, Path("/pack"), Path("/pack/transformer-dev.safetensors"), [("adapter", 1.0), ("distilled", 1.0)])','pipe.load(); pipe.load()',- 'print(pipe.calls, pipe.lora_paths, pipe.model_dir)',+ // The latent upsampler slot is pre-seeded so the base load() skips the+ // ~1 GB stage-2 weight a skip_stage_2 render never touches.+ 'print(pipe.calls, pipe.lora_paths, pipe.model_dir, pipe.upsampler is not None)',].join('\n');expect(trimmed(runPython(`${importRunner}\n${source}`)))- .toBe("['transformer-dev.safetensors', 'base-load:dit', 'base-load:dit'] [('adapter', 1.0), ('distilled', 1.0)] /pack");+ .toBe("['transformer-dev.safetensors', 'base-load:dit', 'base-load:dit'] [('adapter', 1.0), ('distilled', 1.0)] /pack True");}, PY_TEST_TIMEOUT_MS);});diff --git a/scripts/upscale_ltx25_cuda.py b/scripts/upscale_ltx25_cuda.pyindex 07f7381bfb..c41abd66d1 100644--- a/scripts/upscale_ltx25_cuda.py+++ b/scripts/upscale_ltx25_cuda.py@@ -18,14 +18,11 @@ installs), not inferred from the gated model card:that `generate_ltx25_cuda.py` already drives `DistilledPipeline` with, sothe FP8 cast policy and disk streaming that make a 22B model fit a consumercard carry over unchanged. It fuses the adapter into STAGE 1 only- (`stage_2` is built with `loras=()`), and stage 1 renders at HALF the+ (`stage_2` is built with `loras=()`) and renders that stage at HALF the`height`/`width` it is handed — so, exactly like the MLX runner, this one- requests twice the output and passes `skip_stage_2=True`: the conditioned- stage renders at the output size with the source as a native-resolution- reference and its decode is the deliverable- (`_upscale_contract.conditioned_stage_request`). That is the standard- single-stage IC-LoRA video-to-video recipe Lightricks documents for the- upscaler; the latent-upsample stage 2 never runs.+ requests twice the output and passes `skip_stage_2=True` (see+ `PIPELINE_REQUEST_MULTIPLIER` in `_upscale_contract.py`); the+ latent-upsample stage 2 never runs.- The LoRA is a `LoraPathStrengthAndSDOps(path, strength, sd_ops)` and the`sd_ops` is the runtime's own `LTXV_LORA_COMFY_RENAMING_MAP`. Both comefrom `ltx_core.loader`; naming the map here rather than reimplementing it@@ -252,9 +249,8 @@ def main() -> None:header = read_safetensors_header(args.ic_lora_path)scale = reference_downscale_factor(header)assert_reference_scale_fits(scale, args.width, args.height)- # Recorded rather than guessed: `icLoraWeights.js` holds `null` for this- # gated weight precisely because nobody had opened it, and this line is the- # measurement (#6508's registry note points here).+ # The per-install measurement the queue records beside the registry's+ # declared value — a re-pinned weight is measured, not trusted.log(f"UPSCALE_REFERENCE_DOWNSCALE:{scale}")log("STAGE:verify-adapter")@@ -320,8 +316,8 @@ def main() -> None:request_width, request_height = conditioned_stage_request(args.width, args.height)log("STAGE:inference")with heartbeat("ltx25-cuda-upscale-inference"):- # Stage 1 renders at half the requested dims — i.e. AT the output — and- # `skip_stage_2` makes its decode the deliverable (module docstring).+ # Twice the output + `skip_stage_2` = one conditioned stage AT the+ # output (see `conditioned_stage_request`).# No sigma override: `DISTILLED_SIGMAS` IS the distilled schedule (8)# and is this call's stage-1 default. `images=[]` because the# reference is the clip, not a still.diff --git a/scripts/upscale_ltx25_cuda.test.js b/scripts/upscale_ltx25_cuda.test.jsindex 9811432781..d37ab98abe 100644--- a/scripts/upscale_ltx25_cuda.test.js+++ b/scripts/upscale_ltx25_cuda.test.js@@ -134,7 +134,7 @@ describe.skipIf(!pyBin)('upscale_ltx25_cuda.py — one argv for both backends (#]);}, PY_TEST_TIMEOUT_MS);- // The distilled schedule is fixed at 8 + 3 sigmas on both runtimes, so there+ // The distilled schedule is fixed at 8 sigmas on both runtimes, so there// is nothing for a steps flag to select; and the pass carries no prompt,// because the source clip is the whole conditioning signal.it('exposes no steps flag and defaults the prompt to empty', () => {@@ -316,10 +316,11 @@ describe.skipIf(!pyBin)('upscale_ltx25_cuda.py — adapter fusion guard (#6513)'}, PY_TEST_TIMEOUT_MS);});-// The adapter's declared factor applies to the STAGE-1 dims, which are half the-// output — so a factor of 2 really demands an output divisible by 4. Shared with-// the MLX runner, exercised here because this runner is the one that would-// commit a CUDA render to it.+// The adapter's declared factor applies to the output the conditioned stage+// renders at, and the reference must land on the VAE's 32-pixel grid at the+// source's own size — so a factor of N demands an output divisible by N × 32.+// Shared with the MLX runner, exercised here because this runner is the one+// that would commit a CUDA render to it.describe.skipIf(!pyBin)('upscale_ltx25_cuda.py — reference downscale factor (#6513)', () => {it('reads the factor off the weight and enforces it against the output the conditioned stage renders at', () => {expect(call(`runner.reference_downscale_factor(runner.read_safetensors_header(${JSON.stringify(ADAPTER)}))`))diff --git a/server/lib/icLoraWeights.js b/server/lib/icLoraWeights.jsindex 2b61fcdc90..5fb4bec1b2 100644--- a/server/lib/icLoraWeights.js+++ b/server/lib/icLoraWeights.js@@ -313,11 +313,10 @@ export const assertIcReferenceCount = (spec, count, fail) => {// requires the OUTPUT dimensions to divide evenly by it. Returns a human message// when they don't, else null. Mirrored client-side (icResolutionIssue in// client/src/lib/videoGenParams.js) so the form can warn before submit.-// A `null`/absent factor is UNKNOWN, not 1 — the weight's metadata hasn't been-// read yet (a gated file nobody with accepted terms has opened). Both resolve-// to "assert no rule", but they must stay distinguishable: guessing a factor-// here would either reject valid resolutions or green-light ones the pipeline-// will refuse deep inside a render.+// A `null`/absent factor is UNKNOWN, not 1 — a weight whose metadata has not+// been read. Both resolve to "assert no rule", but they must stay+// distinguishable: guessing a factor here would either reject valid+// resolutions or green-light ones the pipeline will refuse deep inside a render.export const icResolutionIssue = (spec, width, height) => {const scale = spec?.referenceDownscaleFactor;if (typeof scale !== 'number' || !Number.isFinite(scale) || scale <= 1) return null;@@ -328,9 +327,9 @@ export const icResolutionIssue = (spec, width, height) => {/*** The reference downscale factor a spec's DOWNLOADED weight actually declares.*- * `referenceDownscaleFactor` on the registry entry is what this repo could- * verify when the entry was written; for a gated weight that is `null`. This- * reads the truth off the file an install holds — the same+ * `referenceDownscaleFactor` on the registry entry is what was verified when+ * the entry was written (`null` for a weight nobody has opened). This reads+ * the truth off the file an install holds — the same* `__metadata__.reference_downscale_factor` the MLX pipeline itself reads* (`iclora_utils.read_lora_reference_downscale_factor`) — so the resolution* rule can be stated before a render commits to it.diff --git a/server/services/videoGen/generateVideoHelpers.js b/server/services/videoGen/generateVideoHelpers.jsindex f4c7528a8e..493d17299b 100644--- a/server/services/videoGen/generateVideoHelpers.js+++ b/server/services/videoGen/generateVideoHelpers.js@@ -145,17 +145,14 @@ export function makeVideoGenLineHandler({ job, jobId, pythonNoiseRe }) {// job so finalizeGeneratedVideo can persist it on the history record, and// log a single self-documenting line so a render that produced garbled// output can be tied to a specific ltx/mlx/torch + chip + OS stack.- if (line.startsWith('RUNTIME:')) {- try {- const fp = JSON.parse(line.slice('RUNTIME:'.length));- job.runtime = fp;- console.log(`🏷️ runtime [${jobId.slice(0, 8)}] ${formatRuntimeFingerprint(fp) || '?'}`);- return true;- } catch {- // Malformed fingerprint line — fall through to raw-logging so the- // broken payload is visible rather than silently swallowed.- return false;- }+ if (line.startsWith(RUNTIME_LINE_PREFIX)) {+ const fp = parseRuntimeFingerprintLine(line);+ // Malformed fingerprint line — fall through to raw-logging so the+ // broken payload is visible rather than silently swallowed.+ if (!fp) return false;+ job.runtime = fp;+ console.log(`🏷️ runtime [${jobId.slice(0, 8)}] ${formatRuntimeFingerprint(fp) || '?'}`);+ return true;}// What the runner ACTUALLY applied of a requested speed profile// (SPEEDPROFILE:<json> — see scripts/generate_ltx2.py). PortOS asks for a@@ -357,6 +354,29 @@ export function describeRenderConditioning({return kinds.sort();}+// The one-line protocol every helper script announces its stack on at startup+// (`scripts/_runner_common.py emit_runtime_fingerprint`). Parsed here for the+// render path and the upscale job alike, so a payload-shape change has one+// consumer to update.+export const RUNTIME_LINE_PREFIX = 'RUNTIME:';++/**+ * The fingerprint object carried by a `RUNTIME:<json>` line, or null when the+ * line is not one or its payload is malformed — the caller decides whether a+ * broken payload is logged raw or dropped.+ * @param {string} line - one trimmed child-output line+ * @returns {object|null}+ */+export function parseRuntimeFingerprintLine(line) {+ if (typeof line !== 'string' || !line.startsWith(RUNTIME_LINE_PREFIX)) return null;+ try {+ const fp = JSON.parse(line.slice(RUNTIME_LINE_PREFIX.length));+ return fp && typeof fp === 'object' ? fp : null;+ } catch {+ return null;+ }+}+/*** Render a runtime fingerprint (either the `RUNTIME:` payload a helper script* emits — `{ runtime, versions, chip, os, python }` — or the Node-sidediff --git a/server/services/videoGen/upscaleJob.js b/server/services/videoGen/upscaleJob.jsindex d1f864e0de..d089c15360 100644--- a/server/services/videoGen/upscaleJob.js+++ b/server/services/videoGen/upscaleJob.js@@ -38,6 +38,7 @@ import { resolveIcLoraWeightByKey } from '../../lib/icLoraWeights.js';import { hfChildEnv } from '../hfToken.js';import { enqueueJob } from '../mediaJobQueue/index.js';import { videoGenEvents } from './events.js';+import { RUNTIME_LINE_PREFIX, parseRuntimeFingerprintLine, formatRuntimeFingerprint } from './generateVideoHelpers.js';import { getHistoryItem, loadHistory, mutateVideoHistory } from './history.js';import { buildArgs } from './renderArgs.js';import { runtimeIsCacheOnly, runtimeNeedsProcessGroupKill } from './runtimes.js';@@ -51,12 +52,11 @@ import {const MAX_SEED = 2 ** 32 - 1;const STAGE_RE = /^STAGE:\s*(\S+)\s*(.*)$/;// Both runners emit these once, before the pipeline loads: the runtime-// fingerprint (`scripts/_runner_common.py emit_runtime_fingerprint`) and the+// fingerprint (parsed by the same helper the render path uses) and the// adapter's `reference_downscale_factor` read off the weight. They are// provenance, so they are captured here and written onto the history row —// a render can then be tied to the exact ltx/mlx/torch + chip stack and the// factor it enforced, the way a plain render's row carries `runtime`.-const RUNTIME_PREFIX = 'RUNTIME:';const REFERENCE_DOWNSCALE_RE = /^UPSCALE_REFERENCE_DOWNSCALE:\s*(\d+)\s*$/;const STDERR_TAIL_LINES = 20;@@ -229,10 +229,13 @@ const runUpscaleChild = async ({ jobId, bin, args, runtime, entry }) => {if (stderrTail.length > STDERR_TAIL_LINES) stderrTail.shift();}videoGenEvents.emit('activity', { generationId: jobId });- if (text.startsWith(RUNTIME_PREFIX)) {+ if (text.startsWith(RUNTIME_LINE_PREFIX)) {// A malformed payload stays in the stderr tail rather than becoming a// half-parsed fingerprint on the row.- try { provenance.runtime = JSON.parse(text.slice(RUNTIME_PREFIX.length)); } catch { /* keep null */ }+ const fp = parseRuntimeFingerprintLine(text);+ if (!fp) return;+ provenance.runtime = fp;+ console.log(`🏷️ runtime [${jobId.slice(0, 8)}] ${formatRuntimeFingerprint(fp) || '?'}`);return;}const downscale = REFERENCE_DOWNSCALE_RE.exec(text);@@ -414,11 +417,11 @@ export async function runVideoUpscale({upscaleMethod: 'ltx',upscaleRuntime: runtime,upscaleAdapter: adapterKey,- // Measured by the runner off the weight it fused, and the rule it- // enforced — null when the runner did not report one.- upscaleReferenceDownscale: rendered.referenceDownscale ?? null,- // Same shape a plain render's row carries: the exact ltx/mlx/torch +- // chip + OS stack this clip rendered on. Absent when not reported.+ // Measured by the runner off the weight it fused (the rule it enforced),+ // and — in the same shape a plain render's row carries — the exact+ // ltx/mlx/torch + chip + OS stack this clip rendered on. Both are absent+ // sentinels when the runner did not report them, never a guessed value.+ ...(rendered.referenceDownscale !== null ? { upscaleReferenceDownscale: rendered.referenceDownscale } : {}),...(rendered.runtime ? { runtime: rendered.runtime } : {}),// What the grid actually required of this source, kept beside the result// so a reader can tell a padded render from a conforming one.diff --git a/server/services/videoGen/upscaleJob.test.js b/server/services/videoGen/upscaleJob.test.jsindex 1c114077f3..cf6631b6e4 100644--- a/server/services/videoGen/upscaleJob.test.js+++ b/server/services/videoGen/upscaleJob.test.js@@ -348,7 +348,7 @@ describe('runVideoUpscale — success', () => {expect(entry.renderMs).toBeGreaterThanOrEqual(0);// Nothing reported by the runner → explicit absent sentinels, never a// guessed factor or a half-parsed fingerprint.- expect(entry.upscaleReferenceDownscale).toBeNull();+ expect(entry.upscaleReferenceDownscale).toBeUndefined();expect(entry.runtime).toBeUndefined();// The source render's timing must not ride along on a row that only paid// for the upscale.diff --git a/server/services/videoGen/upscaleVideo.js b/server/services/videoGen/upscaleVideo.jsindex d97707d1a0..e66bffac48 100644--- a/server/services/videoGen/upscaleVideo.js+++ b/server/services/videoGen/upscaleVideo.js@@ -92,11 +92,9 @@ const describeLtxRuntime = () => {const describeLtxAdapter = async () => {const spec = icLoraSpecByKey(LTX_UPSCALE_WEIGHT_KEY);const resolved = await resolveIcLoraWeightByKey(LTX_UPSCALE_WEIGHT_KEY);- // Read off the downloaded file when there is one, so the registry's honest- // `null` for this gated weight resolves to the real number on the installs- // that actually hold it (#6512). `measured` keeps "the weight declares 1"- // apart from "nobody has read it yet" — both impose no rule, but only one is- // a fact.+ // Read off the downloaded file when there is one (#6512), so a re-pinned+ // weight is measured rather than trusted; `measured` keeps the registry's+ // declared value apart from the one this install's file actually carries.const { factor, measured } = await readIcLoraReferenceDownscaleFactor(spec);return {key: icLoraWeightKey(spec),