Files
OBLITERATUS/tests/conditional/test_model_download_runtime.py
Joseph MaglyandClaude Opus 5.5 d0f14f77d9 fix(ci): restore the hosted model and operator-UI conditional gates
Scheduled Conditional tests have failed since late August on two hosted
gates, which also blocks release certification:

- model-download-runtime: the operator-only Qwen3.8-27B BF16 regression
  lived in the gate file and always skips on hosted runners; the gate
  runner rejects any skip. Move it to tests/conditional/test_qwen38_runtime.py,
  outside every hosted gate.
- operator-ui: `uv sync --all-extras` now pulls the qwen-hybrid extra,
  whose causal-conv1d sdist builds only against a CUDA toolkit. Exclude
  qwen-hybrid there and in the tag-only supply-chain job, which runs the
  same sync and would fail the next release.

Policy tests pin both invariants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 11:39:27 -04:00

75 lines
2.5 KiB
Python

"""Pinned, networked tiny-model load plus cache-only replay."""
from __future__ import annotations
import uuid
import pytest
import torch
from obliteratus.architecture_profiles import ArchitectureClass, detect_architecture
from obliteratus.models.loader import _select_model_class, load_model
from transformers import AutoConfig, AutoModelForImageTextToText
pytestmark = [pytest.mark.network, pytest.mark.download]
MODEL = "hf-internal-testing/tiny-random-gpt2"
REVISION = "71034c5d8bde858ff824298bdedc65515b97d2b9"
MISTRAL4_MODEL = "mistralai/Mistral-Small-4-119B-2603"
MISTRAL4_REVISION = "a11f36bebf709121056b1dbcc943d1c6afbe494d"
def test_pinned_tiny_model_download_inference_and_offline_cache(monkeypatch):
handle = load_model(
MODEL,
revision=REVISION,
device="cpu",
dtype="float32",
trust_remote_code=False,
skip_snapshot=True,
)
encoded = handle.tokenizer("conditional gate", return_tensors="pt")
with torch.no_grad():
output = handle.model(**encoded)
assert output.logits.shape[:2] == encoded["input_ids"].shape
assert next(handle.model.parameters()).device.type == "cpu"
handle.cleanup()
monkeypatch.setenv("HF_HUB_OFFLINE", "1")
monkeypatch.setenv("TRANSFORMERS_OFFLINE", "1")
cached = load_model(
MODEL,
revision=REVISION,
device="cpu",
local_files_only=True,
trust_remote_code=False,
skip_snapshot=True,
)
assert cached.model_name == MODEL
cached.cleanup()
missing = f"obliteratus/offline-missing-{uuid.uuid4().hex}"
with pytest.raises(OSError):
load_model(missing, revision=REVISION, device="cpu", local_files_only=True)
def test_pinned_mistral4_config_resolves_composite_contract_without_remote_code():
config = AutoConfig.from_pretrained(
MISTRAL4_MODEL,
revision=MISTRAL4_REVISION,
trust_remote_code=False,
)
assert config.model_type == "mistral3"
assert config.architectures == ["Mistral3ForConditionalGeneration"]
assert config.text_config.model_type == "mistral4"
assert config.text_config.n_routed_experts == 128
assert config.text_config.num_experts_per_tok == 4
assert _select_model_class("causal_lm", config) is AutoModelForImageTextToText
profile = detect_architecture(MISTRAL4_MODEL, config=config)
assert profile.model_type == "mistral4"
assert profile.arch_class is ArchitectureClass.LARGE_MOE
assert (profile.num_experts, profile.num_active_experts) == (128, 4)