Skip to content

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

fix: record each LoRA application by source and strength, not basename (#12262)

[._.]/ Adam Eivy3c2c7356be2c
diff --git a/scripts/ltx_runtime_lora.py b/scripts/ltx_runtime_lora.py
index d9b8163084..40d836bfac 100644
--- a/scripts/ltx_runtime_lora.py
+++ b/scripts/ltx_runtime_lora.py
@@ -237,15 +237,23 @@ class AdapterReport:
def __init__(self):
self.entries: list[dict] = []
-
- def record(self, role: str, stage: str, summary: dict) -> bool:
- """Returns True the first time this adapter is recorded."""
- for entry in self.entries:
- if entry["role"] == role and entry["name"] == summary["name"]:
- if stage not in entry["stages"]:
- entry["stages"].append(stage)
- return False
- self.entries.append({"role": role, "stages": [stage], **summary})
+ # Identity is the full source path + strength, never the basename: two
+ # files sharing a name, or one file at two strengths, are distinct
+ # applications. The path stays out of the emitted record (history is
+ # user-facing and machine paths are private).
+ self._index: dict[tuple, dict] = {}
+
+ def record(self, role: str, stage: str, source: str, summary: dict) -> bool:
+ """Returns True the first time this application is recorded."""
+ key = (role, str(source), summary["strength"])
+ entry = self._index.get(key)
+ if entry is not None:
+ if stage not in entry["stages"]:
+ entry["stages"].append(stage)
+ return False
+ entry = {"role": role, "stages": [stage], **summary}
+ self._index[key] = entry
+ self.entries.append(entry)
return True
def emit(self, stream=None) -> None:
@@ -282,7 +290,7 @@ def install_pipeline_adapters(
if ic:
merged += [("ic", "stage-1", spec) for spec in getattr(pipe, "_lora_paths", [])]
for role, stage, (path, strength) in merged:
- report.record(role, stage, _requantized_summary(path, strength))
+ report.record(role, stage, path, _requantized_summary(path, strength))
if merged:
names = ", ".join(Path(path).name for _role, _stage, (path, _s) in merged)
status(
@@ -296,8 +304,8 @@ def install_pipeline_adapters(
def attach(dit, role: str, stage: str, specs) -> None:
loaded = [(path, load_adapter(path), strength) for path, strength in specs]
- for summary in attach_adapters(dit, loaded):
- if report.record(role, stage, summary):
+ for (path, _tensors, _strength), summary in zip(loaded, attach_adapters(dit, loaded)):
+ if report.record(role, stage, path, summary):
status(
f"{role} LoRA {summary['name']}: {summary['strategy']} "
f"({summary['quantizedTargets']} quantized, {summary['fusedTargets']} float projection(s))"
diff --git a/scripts/ltx_runtime_lora_test.py b/scripts/ltx_runtime_lora_test.py
index 62fc2097f8..689d9b4c8b 100644
--- a/scripts/ltx_runtime_lora_test.py
+++ b/scripts/ltx_runtime_lora_test.py
@@ -195,6 +195,19 @@ class ValidationTest(unittest.TestCase):
self.assertEqual(summary["quantizedTargets"], 1)
+class AdapterReportTest(unittest.TestCase):
+ def test_same_basename_or_strength_change_is_a_separate_application(self):
+ report = runtime.AdapterReport()
+ summary = lambda strength: {"name": "style.safetensors", "strength": strength, "strategy": runtime.STRATEGY_RUNTIME,
+ "quantizedTargets": 1, "fusedTargets": 0}
+ self.assertTrue(report.record("user", "all", "a/style.safetensors", summary(0.5)))
+ self.assertFalse(report.record("user", "all", "a/style.safetensors", summary(0.5)))
+ self.assertTrue(report.record("user", "all", "b/style.safetensors", summary(0.5)))
+ self.assertTrue(report.record("user", "all", "a/style.safetensors", summary(0.9)))
+ self.assertEqual([e["strength"] for e in report.entries], [0.5, 0.5, 0.9])
+ self.assertNotIn("a/", repr(report.entries))
+
+
class FakeICLoraPipeline:
"""The upstream ICLoraPipeline surface install_pipeline_adapters drives.
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index 0fb01ff993..b4c67e6e41 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -809,6 +809,14 @@ describe('stitchVideos — history provenance', () => {
expect(stitched).not.toHaveProperty('loraStrategyApplied');
});
+
+ it('omits the outcome when the chunks used the adapter at different strengths', async () => {
+ const weaker = applied('runtime-delta');
+ weaker.loraStrategyApplied.adapters[0].strength = 0.4;
+ const stitched = await stitchHistory(applied('runtime-delta'), weaker);
+
+ expect(stitched).not.toHaveProperty('loraStrategyApplied');
+ });
});
});
diff --git a/server/services/videoGen/stitchVideos.js b/server/services/videoGen/stitchVideos.js
index d851237fe8..f3cd287a1c 100644
--- a/server/services/videoGen/stitchVideos.js
+++ b/server/services/videoGen/stitchVideos.js
@@ -56,11 +56,12 @@ const unanimousStreamingPolicyOutcome = (videos) => {
};
// Fold the per-chunk LORASTRATEGY: reports into one claim, or none (#12262).
-// Unanimity is on each adapter's name + strategy, so a chain whose chunks all
-// applied the same adapters the same way keeps the claim and a chain that
-// mixed strategies makes none.
+// Unanimity is on every field the stitched record would claim for each adapter
+// (role, name, strength, stages, strategy) — only the per-chunk target counts
+// may differ — so a chain whose chunks applied the same adapters the same way
+// keeps the claim and any other chain makes none.
const loraStrategySignature = (applied) => JSON.stringify(
- (applied?.adapters || []).map((a) => [a?.role, a?.name, a?.strategy]),
+ (applied?.adapters || []).map((a) => [a?.role, a?.name, a?.strength, a?.stages, a?.strategy]),
);
const unanimousLoraStrategyOutcome = (videos) => {
const first = videos[0]?.loraStrategyApplied;