From 66da5a4338b9ad7bd04875b1961608f02bbb4969 Mon Sep 17 00:00:00 2001 From: Albatross1382 Date: Sat, 2 May 2026 10:20:29 +1000 Subject: [PATCH] fix(text-embeddings): compare text_encoder_norm_type case-insensitively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LTX-V 22B distilled checkpoints serialise text_encoder_norm_type as the enum name (PER_TOKEN_RMS) rather than the lowercase token (per_token_rms) the assertion expects. The assertion at text_embeddings_connectors.py:362 strict-equality fails on every load, blocking the local-encode path entirely. Fix: compare string-typed expectations case-insensitively via casefold(). Type-guarded so the bool-typed siblings (caption_projection_first_linear etc.) keep their strict-equality semantics. Repro: load any LTX-V 22B distilled-1.1 checkpoint via LTXVGemmaCLIPModelLoader. Stack: LTXVGemmaCLIPModelLoader → comfy.sd.CLIP.__init__ → gemma_encoder.GemmaCLIP.__init__ (gemma_encoder.py:182) → text_embeddings_connectors.load_text_embeddings_pipeline (text_embeddings_connectors.py:362) → AssertionError: Unexpected config for dual-aggregate model: text_encoder_norm_type='PER_TOKEN_RMS', expected 'per_token_rms' Failing checkpoint: ltx-2.3-22b-distilled-1.1.safetensors sha256:b33b7fe4bbfe084f484be4aaf90b0f1d95dca20d403ac4c0e037eb8c4f0af7cc. No existing tests in repo to update; verified manually by smoke-running a minimal T2V workflow that wires LTXVGemmaCLIPModelLoader → CLIPTextEncode → KSampler against the patched assertion with the failing checkpoint. Pre-commit (isort, ruff, end-of-file-fixer, trailing-whitespace) passes; black 24.4.2 with --target-version py310 reports the patched file unchanged. Co-authored-by: Claude Opus 4.7 (1M context) --- text_embeddings_connectors.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/text_embeddings_connectors.py b/text_embeddings_connectors.py index a5a7688..df7196f 100644 --- a/text_embeddings_connectors.py +++ b/text_embeddings_connectors.py @@ -359,7 +359,15 @@ def load_text_embeddings_pipeline( } for key, expected_val in _expected.items(): actual = transformer_config.get(key) - assert actual == expected_val, ( + # LTX-V checkpoint metadata serialises text_encoder_norm_type as + # the enum name (e.g. "PER_TOKEN_RMS") rather than the value + # ("per_token_rms"). Compare strings case-insensitively; keep + # strict equality for the bool-typed siblings. + if isinstance(expected_val, str) and isinstance(actual, str): + ok = actual.casefold() == expected_val.casefold() + else: + ok = actual == expected_val + assert ok, ( f"Unexpected config for dual-aggregate model: " f"{key}={actual!r}, expected {expected_val!r}" )