Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: stop two lines repeating in the server log for the whole session (#8306)
Daniel Hanc5994723433c
diff --git a/studio/backend/core/rag/embeddings.py b/studio/backend/core/rag/embeddings.pyindex 95b8a866b2d..642117c77bd 100644--- a/studio/backend/core/rag/embeddings.py+++ b/studio/backend/core/rag/embeddings.py@@ -16,7 +16,9 @@ from __future__ import annotationsimport loggingimport os+import reimport threading+from contextlib import contextmanagerfrom functools import lru_cachefrom typing import Callable@@ -167,6 +169,168 @@ def _guard_model_security(name: str, local_only: bool = False) -> None:)+_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")+++class _CaptureLoadReport(logging.Filter):+ """Swallow transformers' multi-line "<Model> LOAD REPORT" table, keeping the text.++ transformers >= 5 emits the report through ``logger.warning`` with embedded ANSI+ colour codes, so it lands in the server log as ~7 unstructured lines that break+ every JSON consumer. It fires on every boot for the RAG embedder because+ bge-small-en-v1.5 ships a legacy ``embeddings.position_ids`` key that the current+ BertModel does not expect, which is benign and identical every time.++ Nothing is lost: the caller re-emits the report (see ``_quiet_transformers_load``)+ at debug when it only reports that known legacy key, and at warning when it+ mentions anything that could change the model's behaviour.+ """++ _SERIOUS = ("MISSING", "MISMATCH", "CONVERSION")+ # The only UNEXPECTED key worth downgrading is the legacy buffer every BERT-era+ # sentence-transformer ships. Any other discarded weight can genuinely change+ # retrieval quality, so it stays a warning. Matched on the whole key, not as a+ # substring: "encoder.position_ids_projection.weight" is a real discarded weight.+ _KNOWN_BENIGN_UNEXPECTED = "embeddings.position_ids"++ def __init__(self) -> None:+ super().__init__()+ self.reports: list[str] = []+ # These filters sit on process-global loggers, so a concurrent load on another+ # thread would otherwise have its report swallowed and attributed here. Only+ # capture what the thread that opened the context emits.+ self.thread_id = threading.get_ident()++ def filter(self, record: logging.LogRecord) -> bool:+ if threading.get_ident() != self.thread_id:+ return True+ try:+ msg = record.getMessage()+ except Exception: # noqa: BLE001 - a broken record must not break loading+ return True+ if "LOAD REPORT" not in msg:+ return True+ self.reports.append(msg)+ return False++ def is_serious(self) -> bool:+ for report in self.reports:+ if any(tag in report for tag in self._SERIOUS):+ return True+ # Row by row over the table only. transformers appends a "Notes:" section+ # explaining each status ("- UNEXPECTED: can be ignored when loading from+ # a different task/architecture"), and reading that as a key row would make+ # every unexpected report serious, including the benign one.+ table = report.split("Notes:", 1)[0]+ for row in table.splitlines():+ if "UNEXPECTED" not in row:+ continue+ key = _ANSI_RE.sub("", row).split("|", 1)[0].strip()+ if key != self._KNOWN_BENIGN_UNEXPECTED and not key.endswith(+ "." + self._KNOWN_BENIGN_UNEXPECTED+ ):+ return True+ return False+++_LOAD_REPORT_LOGGERS = (+ "transformers.utils.loading_report",+ "transformers.modeling_utils",+ # An adapter-backed embedding model reports through the PEFT integration's own+ # logger, which is not a descendant of either of the above.+ "transformers.integrations.peft",+)+++@contextmanager+def _quiet_transformers_load():+ """Keep a transformers weight load from writing raw ANSI/tqdm output to stdout.++ Scoped to the embedder load only, so a user-visible model load keeps its normal+ progress bar and report. Restores the progress-bar setting exactly as found, so+ a caller that had already disabled bars stays disabled.+ """+ capture = _CaptureLoadReport()+ attached = []+ for name in _LOAD_REPORT_LOGGERS:+ log = logging.getLogger(name)+ log.addFilter(capture)+ attached.append(log)++ # The weight-load bar is transformers.utils.logging.tqdm, so disable_progress_bar()+ # reaches it. The "is it on right now" probe has been spelled both ways across+ # versions (is_progress_bar_enabled in 4.x/5.x, are_progress_bars_disabled in+ # some builds), so accept either and skip the restore when neither exists rather+ # than re-enabling a bar the caller had deliberately turned off.+ # transformers' enable_progress_bar() also calls the Hub's enable_progress_bars(),+ # so restoring the transformers flag would clobber a Hub-only disable that someone+ # else installed (unsloth does exactly that in patch_ipykernel_hf_xet for the+ # broken hf-xet/ipykernel pair). Snapshot the Hub state separately and put it back.+ hub_bars_off = None+ try:+ from huggingface_hub.utils import are_progress_bars_disabled+ hub_bars_off = bool(are_progress_bars_disabled())+ except Exception: # noqa: BLE001 - no Hub, or a version without the probe+ hub_bars_off = None++ reenable = False+ hf_logging = None+ try:+ from transformers.utils import logging as hf_logging+ if hasattr(hf_logging, "is_progress_bar_enabled"):+ was_on = bool(hf_logging.is_progress_bar_enabled())+ elif hasattr(hf_logging, "are_progress_bars_disabled"):+ was_on = not bool(hf_logging.are_progress_bars_disabled())+ else:+ was_on = False+ if was_on:+ hf_logging.disable_progress_bar()+ reenable = True+ except Exception: # noqa: BLE001 - older/absent transformers: nothing to disable+ hf_logging = None++ try:+ yield capture+ finally:+ for log in attached:+ log.removeFilter(capture)+ if reenable and hf_logging is not None:+ try:+ hf_logging.enable_progress_bar()+ except Exception: # noqa: BLE001+ pass+ if hub_bars_off:+ try:+ from huggingface_hub.utils import disable_progress_bars+ disable_progress_bars()+ except Exception: # noqa: BLE001+ pass+++def _one_line(text: str) -> str:+ """The report as a single plain-text line.++ This module logs through the stdlib logger, not structlog, so re-emitting the+ captured table verbatim would put the ANSI escapes and embedded newlines straight+ back into the server log, which is the thing being fixed.+ """+ plain = _ANSI_RE.sub("", text)+ return " | ".join(part.strip() for part in plain.splitlines() if part.strip())+++def _emit_load_reports(report) -> None:+ """Re-emit what the filter swallowed, as one record on our own logger: debug for+ the expected legacy-key notice, warning for anything that could change the+ embeddings. Drains the list so a retry does not report the same lines twice."""+ serious = report.is_serious()+ for text in report.reports:+ if serious:+ logger.warning("embedding model load report: %s", _one_line(text))+ else:+ logger.debug("embedding model load report: %s", _one_line(text))+ report.reports.clear()++def _st_accepts_local_files_only(st_cls) -> bool:"""Whether this SentenceTransformer version accepts local_files_only; passing it to anolder constructor raises, so gate on the signature."""@@ -210,7 +374,14 @@ def _get(model_name: str | None = None):load_target = str(snapshot)elif _st_accepts_local_files_only(SentenceTransformer):st_kwargs["local_files_only"] = True- _model = SentenceTransformer(load_target, **st_kwargs)+ with _quiet_transformers_load() as report:+ # The re-emit runs in finally: a load that raises after transformers+ # wrote its report is exactly when a MISSING or MISMATCH line matters,+ # and letting the exception skip the loop would swallow it.+ try:+ _model = SentenceTransformer(load_target, **st_kwargs)+ finally:+ _emit_load_reports(report)_name = namereturn _modeldiff --git a/studio/backend/tests/test_embedding_load_report_quiet.py b/studio/backend/tests/test_embedding_load_report_quiet.pynew file mode 100644index 00000000000..b33f2a1f7e6--- /dev/null+++ b/studio/backend/tests/test_embedding_load_report_quiet.py@@ -0,0 +1,339 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""The RAG embedder load must not write raw transformers output to the server log.++transformers >= 5 prints a multi-line, ANSI-coloured "<Model> LOAD REPORT" table+through logger.warning plus a "Loading weights" tqdm bar. bge-small-en-v1.5 always+trips it (legacy embeddings.position_ids key), so every Studio boot emitted ~7+unstructured lines into an otherwise JSON log. They are captured and re-emitted on+our own logger instead: debug when benign, warning when the report mentions+anything that could change the model.+"""++from __future__ import annotations++import logging+import sys++import pytest+from pathlib import Path++_BACKEND = Path(__file__).resolve().parent.parent+if str(_BACKEND) not in sys.path:+ sys.path.insert(0, str(_BACKEND))++from core.rag.embeddings import _quiet_transformers_load # noqa: E402++_REPORT_LOGGER = "transformers.utils.loading_report"+_BENIGN = (+ "\x1b[1mBertModel LOAD REPORT\x1b[0m from: unsloth/bge-small-en-v1.5\n"+ "Key | Status\n"+ "embeddings.position_ids | UNEXPECTED"+)+_SERIOUS = "BertModel LOAD REPORT from: x\nencoder.layer.0.weight | MISSING"+++class _Sink(logging.Handler):+ def __init__(self) -> None:+ super().__init__()+ self.messages: list[str] = []++ def emit(self, record: logging.LogRecord) -> None:+ self.messages.append(record.getMessage())+++_RESTORE: list = []+++def _attach_sink(name: str = _REPORT_LOGGER):+ """Attach a sink to a process-global logger, remembering what to put back.++ getLogger() is process-global, so leaving propagate = False behind would make+ later tests in the same worker silently drop real records.+ """+ log = logging.getLogger(name)+ sink = _Sink()+ _RESTORE.append((log, sink, log.propagate, log.level))+ log.addHandler(sink)+ log.propagate = False+ log.setLevel(logging.DEBUG)+ return log, sink++[email protected](autouse = True)+def _restore_loggers():+ yield+ while _RESTORE:+ log, sink, propagate, level = _RESTORE.pop()+ log.removeHandler(sink)+ log.propagate = propagate+ log.setLevel(level)+++def test_load_report_is_swallowed_and_captured():+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load() as report:+ log.warning(_BENIGN)+ assert sink.messages == [], sink.messages+ assert len(report.reports) == 1+ assert "LOAD REPORT" in report.reports[0]+ assert report.is_serious() is False+ finally:+ log.removeHandler(sink)+++def test_unrelated_transformers_warnings_still_pass_through():+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load():+ log.warning("something genuinely wrong happened")+ assert sink.messages == ["something genuinely wrong happened"]+ finally:+ log.removeHandler(sink)+++def test_missing_keys_are_flagged_as_serious():+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load() as report:+ log.warning(_SERIOUS)+ assert report.is_serious() is True+ finally:+ log.removeHandler(sink)+++def test_filter_is_removed_after_the_context():+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load():+ pass+ log.warning(_BENIGN)+ assert len(sink.messages) == 1+ finally:+ log.removeHandler(sink)+++def test_progress_bar_state_is_restored(_progress_bar_state):+ from transformers.utils import logging as hf_logging++ enabled_probe = getattr(hf_logging, "is_progress_bar_enabled", None)+ if enabled_probe is None:+ return # nothing to assert on this transformers build++ hf_logging.enable_progress_bar()+ with _quiet_transformers_load():+ assert enabled_probe() is False+ assert enabled_probe() is True+++def test_a_caller_that_already_disabled_bars_stays_disabled(_progress_bar_state):+ from transformers.utils import logging as hf_logging++ enabled_probe = getattr(hf_logging, "is_progress_bar_enabled", None)+ if enabled_probe is None:+ return++ hf_logging.disable_progress_bar()+ with _quiet_transformers_load():+ pass+ assert enabled_probe() is False+++def test_a_concurrent_thread_is_not_captured():+ # The filters sit on process-global loggers; another in-process load must keep+ # its own report rather than have it swallowed and attributed to the embedder.+ import threading+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load() as report:+ t = threading.Thread(target = lambda: log.warning(_SERIOUS))+ t.start()+ t.join()+ assert sink.messages == [_SERIOUS], sink.messages+ assert report.reports == []+ finally:+ log.removeHandler(sink)+ log.propagate = True+++def test_reports_are_re_emitted_when_the_load_fails():+ # A load that raises after transformers wrote its report is exactly when a+ # MISSING line matters, so it must not be lost with the exception.+ from core.rag import embeddings as emb++ log, sink = _attach_sink()+ emitted = []+ real_warning = emb.logger.warning+ emb.logger.warning = lambda msg, *a, **k: emitted.append(msg % a if a else msg)+ try:+ try:+ with _quiet_transformers_load() as report:+ try:+ log.warning(_SERIOUS)+ raise RuntimeError("weight tying blew up")+ finally:+ emb._emit_load_reports(report)+ except RuntimeError:+ pass+ assert any("MISSING" in m for m in emitted), emitted+ finally:+ emb.logger.warning = real_warning+ log.removeHandler(sink)+ log.propagate = True+++def _progress_bar_state():+ """Snapshot and restore the two process-global progress-bar switches.++ Both are global, so a test that leaves them enabled makes later tests in the same+ worker order-dependent and can undo an environment-specific workaround.+ """+ from huggingface_hub.utils import (+ are_progress_bars_disabled,+ disable_progress_bars,+ enable_progress_bars,+ )+ from transformers.utils import logging as hf_logging++ hub_was_off = bool(are_progress_bars_disabled())+ tf_was_on = bool(hf_logging.is_progress_bar_enabled())+ try:+ yield+ finally:+ if tf_was_on:+ hf_logging.enable_progress_bar()+ else:+ hf_logging.disable_progress_bar()+ if hub_was_off:+ disable_progress_bars()+ else:+ enable_progress_bars()+++def test_a_hub_only_progress_disable_survives(_progress_bar_state):+ # transformers' enable_progress_bar() also enables the Hub's bars, which would+ # undo unsloth's patch_ipykernel_hf_xet disable.+ from huggingface_hub.utils import are_progress_bars_disabled, disable_progress_bars+ from transformers.utils import logging as hf_logging++ hf_logging.enable_progress_bar() # transformers on, Hub-only disable after it+ disable_progress_bars()+ with _quiet_transformers_load():+ pass+ assert are_progress_bars_disabled() is True+++def test_an_unexpected_key_other_than_the_legacy_one_stays_a_warning():+ # A discarded encoder weight can genuinely degrade retrieval, so only the+ # bge-style embeddings.position_ids report is quiet enough for debug.+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load() as report:+ log.warning("BertModel LOAD REPORT from: x\nencoder.layer.0.dense | UNEXPECTED")+ assert report.is_serious() is True+ finally:+ log.removeHandler(sink)+ log.propagate = True+++def test_the_legacy_position_ids_report_is_still_benign():+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load() as report:+ log.warning(_BENIGN)+ assert report.is_serious() is False+ finally:+ log.removeHandler(sink)+ log.propagate = True+++def test_the_peft_integration_logger_is_covered():+ # An adapter-backed embedding model reports through transformers.integrations.peft,+ # which is not a descendant of the other two loggers.+ log, sink = _attach_sink("transformers.integrations.peft")+ try:+ with _quiet_transformers_load() as report:+ log.warning(_SERIOUS)+ assert sink.messages == [], sink.messages+ assert len(report.reports) == 1+ finally:+ log.removeHandler(sink)+ log.propagate = True+++def test_a_mixed_report_is_serious():+ # The legacy key and a discarded encoder weight in the same table: the second row+ # is what matters, so the whole report must stay a warning.+ log, sink = _attach_sink()+ mixed = (+ "BertModel LOAD REPORT from: x\n"+ "embeddings.position_ids | UNEXPECTED\n"+ "encoder.layer.0.dense | UNEXPECTED"+ )+ try:+ with _quiet_transformers_load() as report:+ log.warning(mixed)+ assert report.is_serious() is True+ finally:+ log.removeHandler(sink)+ log.propagate = True+++def test_the_notes_section_is_not_read_as_a_key_row():+ # transformers appends "Notes:\n- UNEXPECTED: can be ignored ..." to every report+ # that has unexpected keys; treating that as a row would make the benign bge+ # report serious and defeat the whole change.+ log, sink = _attach_sink()+ with_notes = (+ "BertModel LOAD REPORT from: unsloth/bge-small-en-v1.5\n"+ "embeddings.position_ids | UNEXPECTED\n"+ "\nNotes:\n"+ "- UNEXPECTED:\tcan be ignored when loading from different task/architecture."+ )+ with _quiet_transformers_load() as report:+ log.warning(with_notes)+ assert report.is_serious() is False+++def test_a_serious_report_is_flattened_to_one_plain_line():+ # This module logs through the stdlib logger, so re-emitting the captured table+ # verbatim would put its ANSI escapes and newlines straight back in the log.+ from core.rag import embeddings as emb++ emitted = []+ real_warning = emb.logger.warning+ emb.logger.warning = lambda msg, *a, **k: emitted.append(msg % a if a else msg)+ log, sink = _attach_sink()+ try:+ with _quiet_transformers_load() as report:+ log.warning("\x1b[1mBertModel LOAD REPORT\x1b[0m from: x\nencoder.0 | MISSING")+ emb._emit_load_reports(report)+ finally:+ emb.logger.warning = real_warning+ assert emitted, emitted+ assert "\x1b" not in emitted[0]+ assert "\n" not in emitted[0]+ assert "MISSING" in emitted[0]+++def test_a_key_merely_containing_position_ids_is_serious():+ # "encoder.position_ids_projection.weight" is a real discarded weight, not the+ # legacy buffer, so a substring match would have hidden it.+ log, sink = _attach_sink()+ with _quiet_transformers_load() as report:+ log.warning(+ "BertModel LOAD REPORT from: x\nencoder.position_ids_projection.weight | UNEXPECTED"+ )+ assert report.is_serious() is True+++def test_a_prefixed_legacy_buffer_is_still_benign():+ log, sink = _attach_sink()+ with _quiet_transformers_load() as report:+ log.warning(+ "BertModel LOAD REPORT from: x\n0_Transformer.embeddings.position_ids | UNEXPECTED"+ )+ assert report.is_serious() is Falsediff --git a/studio/backend/tests/test_model_defaults_log_once.py b/studio/backend/tests/test_model_defaults_log_once.pynew file mode 100644index 00000000000..06d1c4d142c--- /dev/null+++ b/studio/backend/tests/test_model_defaults_log_once.py@@ -0,0 +1,88 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""load_model_defaults announces a resolution once, then drops to debug.++GET /api/inference/status resolves the defaults on every poll and the UI polls it+every 5s for as long as a tab is open, so the unconditional info line repeated+forever. The first resolution still logs at info; repeats stay visible at debug.+"""++from __future__ import annotations++import logging+import sys+from pathlib import Path++_BACKEND = Path(__file__).resolve().parent.parent+if str(_BACKEND) not in sys.path:+ sys.path.insert(0, str(_BACKEND))++from utils.models import model_config # noqa: E402+from utils.models.model_config import load_model_defaults # noqa: E402+++class _RecordingLogger:+ """Stand-in for the module's structlog logger; caplog cannot see structlog."""++ def __init__(self) -> None:+ self.calls: list[tuple[str, str]] = []++ def _record(self, level: str):+ def log(msg, *args, **kwargs):+ self.calls.append((level, str(msg)))++ return log++ def __getattr__(self, name: str):+ if name in ("debug", "info", "warning", "error"):+ return self._record(name)+ raise AttributeError(name)++ def at(self, level: str, needle: str) -> list[str]:+ return [m for lvl, m in self.calls if lvl == level and needle in m]+++def _reset(monkeypatch) -> _RecordingLogger:+ model_config._ANNOUNCED_MODEL_DEFAULTS.clear()+ rec = _RecordingLogger()+ monkeypatch.setattr(model_config, "logger", rec)+ return rec+++def test_repeat_resolution_logs_once_at_info(monkeypatch):+ rec = _reset(monkeypatch)+ for _ in range(5):+ load_model_defaults("definitely-not-a-real-model-xyz")+ assert len(rec.at("info", "defaults from")) == 1, rec.calls+++def test_repeats_still_visible_at_debug(monkeypatch):+ rec = _reset(monkeypatch)+ for _ in range(3):+ load_model_defaults("definitely-not-a-real-model-xyz")+ # First call is the info line, the other two are debug: nothing is lost.+ assert len(rec.at("debug", "defaults from")) == 2, rec.calls+++def test_a_different_model_gets_its_own_announcement(monkeypatch):+ rec = _reset(monkeypatch)+ load_model_defaults("definitely-not-a-real-model-xyz")+ load_model_defaults("also-not-a-real-model-abc")+ assert len(rec.at("info", "defaults from")) == 2, rec.calls+++def test_announced_set_is_bounded(monkeypatch):+ _reset(monkeypatch)+ for i in range(model_config._ANNOUNCED_MODEL_DEFAULTS_MAX + 10):+ model_config._log_model_defaults(f"msg {i}", f"key-{i}")+ assert len(model_config._ANNOUNCED_MODEL_DEFAULTS) <= model_config._ANNOUNCED_MODEL_DEFAULTS_MAX+ model_config._ANNOUNCED_MODEL_DEFAULTS.clear()+++def test_returned_config_is_unchanged_by_the_dedup(monkeypatch):+ _reset(monkeypatch)+ first = load_model_defaults("definitely-not-a-real-model-xyz")+ second = load_model_defaults("definitely-not-a-real-model-xyz")+ assert isinstance(first, dict)+ assert first == seconddiff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.pyindex 9851817e0ed..d46cddfed9e 100644--- a/studio/backend/utils/models/model_config.py+++ b/studio/backend/utils/models/model_config.py@@ -3397,6 +3397,35 @@ def get_base_model_from_lora_identifier(UI_STATUS_INDICATORS = [" (Ready)", " (Loading...)", " (Active)", "↓ "]+# Which model defaults have already been announced. GET /api/inference/status is+# polled every 5s for as long as a tab is open and resolves the defaults on every+# poll, so without this the same "Loaded ... defaults from <path>" line repeats+# forever. The first resolution of each (model, path) still logs at info; repeats+# drop to debug, so --verbose and UNSLOTH_STUDIO_LOG_LEVEL=debug still show every+# one. Bounded so a long-lived server with many models cannot grow it without end.+_ANNOUNCED_MODEL_DEFAULTS: set = set()+_ANNOUNCED_MODEL_DEFAULTS_MAX = 4096+# Two request threads can resolve the same unseen model at once, and a bare+# check-then-add would let both decide they were first.+_ANNOUNCED_MODEL_DEFAULTS_LOCK = threading.Lock()+++def _log_model_defaults(+ message: str,+ key: str,+ level: str = "info",+) -> None:+ """Log `message` at `level` the first time `key` is seen, then at debug."""+ with _ANNOUNCED_MODEL_DEFAULTS_LOCK:+ if key in _ANNOUNCED_MODEL_DEFAULTS:+ logger.debug(message)+ return+ if len(_ANNOUNCED_MODEL_DEFAULTS) >= _ANNOUNCED_MODEL_DEFAULTS_MAX:+ _ANNOUNCED_MODEL_DEFAULTS.clear()+ _ANNOUNCED_MODEL_DEFAULTS.add(key)+ getattr(logger, level)(message)++def load_model_defaults(model_name: str) -> Dict[str, Any]:"""Load default training parameters for a model from a YAML file.@@ -3418,7 +3447,10 @@ def load_model_defaults(model_name: str) -> Dict[str, Any]:if config_path.is_file():with open(config_path, "r", encoding = "utf-8") as f:config = yaml.safe_load(f) or {}- logger.info(f"Loaded model defaults from {config_path} (via mapping)")+ _log_model_defaults(+ f"Loaded model defaults from {config_path} (via mapping)",+ f"{model_name}|{config_path}|mapping",+ )return config# For local paths (e.g. .../Spark-TTS-0.5B/LLM from adapter_config.json, or a Windows@@ -3437,8 +3469,9 @@ def load_model_defaults(model_name: str) -> Dict[str, Any]:if config_path.is_file():with open(config_path, "r", encoding = "utf-8") as f:config = yaml.safe_load(f) or {}- logger.info(- f"Loaded model defaults from {config_path} (via path suffix '{suffix}')"+ _log_model_defaults(+ f"Loaded model defaults from {config_path} (via path suffix '{suffix}')",+ f"{model_name}|{config_path}|suffix",)return config@@ -3450,17 +3483,27 @@ def load_model_defaults(model_name: str) -> Dict[str, Any]:if config_path.is_file():with open(config_path, "r", encoding = "utf-8") as f:config = yaml.safe_load(f) or {}- logger.info(f"Loaded model defaults from {config_path}")+ _log_model_defaults(+ f"Loaded model defaults from {config_path}",+ f"{model_name}|{config_path}|exact",+ )return configdefault_config_path = defaults_dir / "default.yaml"if default_config_path.exists():with open(default_config_path, "r", encoding = "utf-8") as f:config = yaml.safe_load(f) or {}- logger.info(f"Loaded default model defaults from {default_config_path}")+ _log_model_defaults(+ f"Loaded default model defaults from {default_config_path}",+ f"{model_name}|{default_config_path}|fallback",+ )return config- logger.warning(f"No default config found for model {model_name}")+ _log_model_defaults(+ f"No default config found for model {model_name}",+ f"{model_name}|<missing>",+ level = "warning",+ )return {}except Exception as e: