longcat: let a built INT8 checkpoint actually be served (v0.2.54)

Caught by running the validators against the real checkpoint the moment it
finished downloading:

  variant_problems('int8') -> ["INT8 weights exist only for avatar-1.5;
                               this checkpoint reads as the base model"]

That guard predates the quantise action and contradicts it: the model page can now
BUILD base_model_int8/ for any checkpoint, so the button would have produced the
weights and this would have refused to load them. The feature shipped one commit
ago with a gate that made it useless.

What decides it now is whether the weights are present, not which family wrote
them — upstream still ships INT8 only for avatar-1.5, and that is still accepted
without a local build, but a base checkpoint with base_model_int8/ is served too.
Without them the refusal names the remedy ("use Build INT8 weights on the model
page first") instead of stating a family rule the operator cannot act on.

The checkpoint directory is passed in for that, since the gate could not otherwise
see what had been built.

Checked against the real 78 GB download: checkpoint_problems is clean, the
vendored source passes source_problems, bf16 is ungated, int8 is refused before a
build and accepted after, and upstream's avatar-1.5 path is unchanged.

16 tests.
Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0182DhR1eFNPQyGmDrpHbedY
parent e0e1f195
......@@ -16,7 +16,7 @@
# Canonical product version for CoderAI — single source of truth. Both the API
# metadata and the admin web UI read from here.
__version__ = "0.2.53"
__version__ = "0.2.54"
__tagline__ = "Complete orchestration, distribution and escalation of remotizable advanced inference."
# Configure the CUDA caching allocator BEFORE torch is imported anywhere.
......
......@@ -95,3 +95,50 @@ def test_quantising_is_not_the_default_anywhere():
for path in (SERVICE, WORKER):
src = path.read_text(encoding="utf-8")
assert not re.search(r'use_int8["\']?\s*[:=]\s*True', src), path.name
# ── the gate that decides whether INT8 may be SERVED ────────────────────────
import sys as _sys
_sys.path.insert(0, str(ROOT / "tools"))
LC = pytest.importorskip("longcat_common")
def _ckpt(tmp_path, with_int8=False):
if with_int8:
(tmp_path / LC.INT8_SUBDIR).mkdir(parents=True)
return str(tmp_path)
def test_int8_is_refused_on_a_base_checkpoint_that_has_none(tmp_path):
"""Upstream ships INT8 only for avatar-1.5, so without built weights this is a
request for something that does not exist."""
problems = LC.variant_problems("int8", "", checkpoint_dir=_ckpt(tmp_path))
assert problems and "Build INT8 weights" in problems[0]
def test_int8_is_allowed_once_the_weights_have_been_built(tmp_path):
"""The regression this guards: the quantise button produces base_model_int8/ for
a BASE checkpoint, and the gate used to reject it anyway because the family was
not avatar-1.5 — so the weights could be built and never served."""
assert LC.variant_problems("int8", "", checkpoint_dir=_ckpt(tmp_path, True)) == []
def test_use_int8_follows_the_same_rule_as_the_variant(tmp_path):
assert LC.variant_problems("bf16", "", use_int8=True,
checkpoint_dir=_ckpt(tmp_path)) != []
assert LC.variant_problems("bf16", "", use_int8=True,
checkpoint_dir=_ckpt(tmp_path, True)) == []
def test_upstreams_avatar_int8_still_needs_no_local_build():
assert LC.variant_problems("int8", "avatar-1.5") == []
def test_bf16_is_never_gated(tmp_path):
assert LC.variant_problems("bf16", "", checkpoint_dir=_ckpt(tmp_path)) == []
def test_the_service_passes_the_checkpoint_to_the_gate():
src = SERVICE.read_text(encoding="utf-8")
assert "checkpoint_dir=checkpoint" in src, "the gate cannot see the built weights"
......@@ -108,7 +108,7 @@ def family_of(model_path: str = "", variant: str = "") -> str:
def variant_problems(variant: str, family: str = "", use_int8: bool = False,
use_distill: bool = False) -> list:
use_distill: bool = False, checkpoint_dir: str = "") -> list:
"""Reasons this combination cannot be served, or [].
Checked before loading so an unsupported flag is an error the operator can act on,
......@@ -121,10 +121,18 @@ def variant_problems(variant: str, family: str = "", use_int8: bool = False,
problems.append(
"the GGUF variants are packaged for ComfyUI's gguf loader, which coderai "
"does not implement — use bf16, fp8, or the official int8 (avatar-1.5)")
if (v == "int8" or use_int8) and family not in INT8_FAMILIES:
problems.append(
f"INT8 weights exist only for {'/'.join(INT8_FAMILIES)}; this checkpoint "
f"reads as {family or 'the base model'}")
if v == "int8" or use_int8:
# Upstream SHIPS int8 only for avatar-1.5 — but the model page can now build
# it for any checkpoint (tools/longcat_quantize.py), so what decides this is
# whether the weights are actually there, not which family wrote them.
built = bool(checkpoint_dir) and os.path.isdir(
os.path.join(os.path.expanduser(checkpoint_dir), INT8_SUBDIR))
if not built and family not in INT8_FAMILIES:
problems.append(
f"no {INT8_SUBDIR}/ in this checkpoint, and upstream ships INT8 only "
f"for {'/'.join(INT8_FAMILIES)} (this reads as "
f"{family or 'the base model'}) — use “Build INT8 weights” on the "
f"model page first")
if use_distill and family and family not in DMD_FAMILIES:
problems.append(
f"the DMD distillation exists only for {'/'.join(DMD_FAMILIES)}; "
......
......@@ -562,13 +562,18 @@ def generate(body: dict) -> dict:
raise ValueError(f"unknown task {task!r}; expected t2v, i2v, vc, "
f"{' or '.join(LC.AVATAR_TASKS)}")
# Variant and family gating BEFORE loading: INT8 and the DMD distillation exist only
# for avatar-1.5, and asking for them elsewhere would quietly load something else.
# Variant and family gating BEFORE loading, so an unsupported combination is an
# error rather than a quietly different model. INT8 is allowed wherever the
# weights exist — upstream ships them for avatar-1.5, and the model page can
# build them for anything else.
family = LC.family_of(checkpoint)
variant = str(body.get("variant") or "bf16").strip().lower()
use_int8 = bool(body.get("use_int8")) or variant == "int8"
use_distill_lora = bool(body.get("use_distill"))
problems = LC.variant_problems(variant, family, use_int8, use_distill_lora)
# The checkpoint is passed so a locally built base_model_int8/ counts as INT8
# being available, not just upstream's avatar-1.5 build.
problems = LC.variant_problems(variant, family, use_int8, use_distill_lora,
checkpoint_dir=checkpoint)
if task in LC.AVATAR_TASKS:
problems += LC.avatar_problems(checkpoint, family, use_int8, use_distill_lora)
elif family:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment