@@ -0,0 +1,58 @@ |
| 1 | +"""End-to-end: train on tiny model, then `dlm prompt` against the adapter. |
| 2 | + |
| 3 | +Sprint 10 DoD: `dlm prompt` one-shot works on a freshly trained tiny-model |
| 4 | +adapter. Also exercises the cross-hardware `InferencePlan` path when run |
| 5 | +on a CPU-only runner after a QLoRA adapter was CI-produced on a CUDA |
| 6 | +job (the regression test that F05 calls out). |
| 7 | + |
| 8 | +Marked `@pytest.mark.slow`. Skipped when the SmolLM2-135M fixture isn't |
| 9 | +offline-resolvable (same gate as Sprint 09's integration stubs). |
| 10 | +""" |
| 11 | + |
| 12 | +from __future__ import annotations |
| 13 | + |
| 14 | +import pytest |
| 15 | + |
| 16 | +pytestmark = pytest.mark.slow |
| 17 | + |
| 18 | + |
| 19 | +@pytest.mark.slow |
| 20 | +def test_train_then_prompt_one_cycle() -> None: |
| 21 | + """20-step train + prompt generates non-empty coherent output. |
| 22 | + |
| 23 | + Shape: |
| 24 | + 1. Synthetic `.dlm` via `tests.fixtures.dlm_factory`. |
| 25 | + 2. `trainer.run(..., max_steps=20)` on SmolLM2-135M. |
| 26 | + 3. Resolve `InferencePlan` against current host's caps. |
| 27 | + 4. `load_for_inference` → `generate(prompt="What is X?")`. |
| 28 | + 5. Assert non-empty string response. |
| 29 | + |
| 30 | + Deferred body: implementation is CI-dependent. The scaffold is |
| 31 | + checked in so `pytest -m slow` has a concrete test to collect. |
| 32 | + """ |
| 33 | + try: |
| 34 | + from tests.fixtures.tiny_model import tiny_model_path |
| 35 | + |
| 36 | + tiny_model_path() |
| 37 | + except Exception as exc: # pragma: no cover |
| 38 | + pytest.skip(f"tiny-model fixture unavailable: {exc}") |
| 39 | + |
| 40 | + pytest.xfail("train+prompt integration scaffolded; body deferred to first CI slow run") |
| 41 | + |
| 42 | + |
| 43 | +@pytest.mark.slow |
| 44 | +def test_qlora_crossplatform_dequantize() -> None: |
| 45 | + """Audit F05: a QLoRA-trained adapter loads on a non-CUDA host via dequantize. |
| 46 | + |
| 47 | + Shape: |
| 48 | + 1. CI matrix has a CUDA job that trains QLoRA and uploads the |
| 49 | + adapter as an artifact. |
| 50 | + 2. This test runs on a CPU-only matrix row; downloads the |
| 51 | + artifact, resolves `InferencePlan`, asserts |
| 52 | + `plan.dequantize_on_load is True`, loads, generates, |
| 53 | + asserts non-empty coherent output. |
| 54 | + |
| 55 | + Until the CUDA-producing job exists, the test is xfailed so it |
| 56 | + shows up in `pytest -m slow` as "expected failure pending CI". |
| 57 | + """ |
| 58 | + pytest.xfail("needs CI artifact-sharing between CUDA and CPU jobs; F05 regression") |