Files
WildAi db38cbf876 chore: silence load/inference diagnostics in production
The [vvcensus], [vvrss], [vvpull], [vvload], [vvdtype], 'Load diagnostics:'
and 'GGUF forward diagnostics:' lines exist to make a slow load or a slow
autoregressive step explainable. None of them produce audio, and all of
them default to ON, so a normal run prints several of them.

Gate them at the six choke points that already existed (report_census,
RssSampler.report, _install_vbar_observer, _log_conv_dtype_mismatch,
_log_load_diagnostics, log_gguf_forward_counters, plus the two emit sites
in generation.py and base_loader.py) rather than commenting out 18 call
sites: the formatting helpers stay importable and unconditional, so a
probe or a test can still ask for the string directly.

New modules/diagnostics.py owns the switch. VIBEVOICE_DIAGNOSTICS=1 turns
everything on; VIBEVOICE_RAM_CENSUS and VIBEVOICE_VBAR_OBSERVER keep
their existing per-family meaning. Production leaves all three unset.

Tests that assert the CONTENT of a line now set the env var explicitly,
and three tests pin the new silent-by-default contract (census, gguf
counters, vbar observer).
2026-10-01 14:34:56 +03:00

47 lines
1.6 KiB
Python

"""One switch for the load and inference diagnostics this package prints.
Every ``[vv...]`` line, the ``Load diagnostics:`` summary and the
``GGUF forward diagnostics:`` counters exist to make a slow load or a slow
autoregressive step explainable. None of them are part of producing audio, so
they are silent by default and recoverable with one environment variable:
VIBEVOICE_DIAGNOSTICS=1 all of them
VIBEVOICE_RAM_CENSUS=1 only the byte census and the RSS sampler
VIBEVOICE_VBAR_OBSERVER=1 only the vbar residency observer
Production leaves all three unset. The formatting helpers stay importable and
unconditional -- only the ``logger.info`` that publishes them is gated -- so a
caller that wants the string (a probe, a test) can still ask for it directly.
"""
import os
_FALSEY_ENV = frozenset({"0", "false", "no", "off"})
DIAGNOSTICS_ENV = "VIBEVOICE_DIAGNOSTICS"
def _truthy(name: str) -> bool:
return os.environ.get(name, "").strip().lower() not in _FALSEY_ENV and bool(
os.environ.get(name, "").strip()
)
def diagnostics_enabled() -> bool:
"""True when ``VIBEVOICE_DIAGNOSTICS`` is set to a non-falsey value."""
return _truthy(DIAGNOSTICS_ENV)
def census_enabled() -> bool:
"""True when the byte census and RSS sampler may log.
On by default under ``VIBEVOICE_DIAGNOSTICS``, independently switchable
with ``VIBEVOICE_RAM_CENSUS``.
"""
return diagnostics_enabled() or _truthy("VIBEVOICE_RAM_CENSUS")
def vbar_observer_enabled() -> bool:
"""True when the vbar residency observer may install its patch."""
return diagnostics_enabled() or _truthy("VIBEVOICE_VBAR_OBSERVER")