FFFFFFFFFF                                                               [100%]
=================================== FAILURES ===================================
_ test_the_ladder_normalizes_a_placement_and_never_returns_an_unknown_kv_type __

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_the_ladder_normalizes_a_p0')

    def test_the_ladder_normalizes_a_placement_and_never_returns_an_unknown_kv_type(
            tmp_path: pathlib.Path) -> None:
        """`harness.Placement` carries what a benchmark can know: the layer count. Nothing else."""
        facts = fit.ModelFacts.read(model_file(tmp_path), want_sha256=False)
    
>       steps = fit.degrade_ladder(harness.Placement(LAYERS), facts)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_bench_placement.py:68: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

plan = Placement(n_gpu_layers=4)
model = ModelFacts(path='/tmp/pytest-of-root/pytest-11153/test_the_ladder_normalizes_a_p0/model.gguf', sha256='', arch='spark2_5', n_layer=4, n_kv_head=4, key_len=256, value_len=256, n_ctx_train=32768, weights_bytes=2432, file_size=4494)

    def degrade_ladder(plan: FitPlan, model: ModelFacts) -> tuple[FitPlan, ...]:
        """The documented degradation ladder: fewer layers -> smaller kv_type -> CPU-only.
    
        Ordered by decreasing device footprint, ending at a plan that asks the device for nothing, so
        the last rung is always available. Each step carries `W_FIT_DOWNGRADE` (the plan was reduced)
        and, when the KV type moved, `W_KV_TYPE_DOWNGRADE`. A caller walks it until a load succeeds.
        """
        steps: list[FitPlan] = []
        rungs = list(KV_DOWNGRADE_ORDER[KV_DOWNGRADE_ORDER.index(plan.kv_type):]) \
>           if plan.kv_type in KV_DOWNGRADE_ORDER else list(KV_DOWNGRADE_ORDER)
               ^^^^^^^^^^^^
E       AttributeError: 'Placement' object has no attribute 'kv_type'

src/ggufone/runtime/fit.py:489: AttributeError
________ test_a_real_plan_keeps_its_identity_through_the_normalization _________

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_a_real_plan_keeps_its_ide0')

    def test_a_real_plan_keeps_its_identity_through_the_normalization(tmp_path: pathlib.Path) -> None:
        """A caller that already speaks `FitPlan` must not be copied, rewritten or degraded."""
        model = fit.ModelFacts.read(model_file(tmp_path), want_sha256=False)
        plan = fit.estimate_plan(model, roomy_gpu_host(), n_ctx=4096)
        assert plan.n_gpu_layers == LAYERS
>       assert fit.coerce_plan(plan) is plan
               ^^^^^^^^^^^^^^^
E       AttributeError: module 'ggufone.runtime.fit' has no attribute 'coerce_plan'

tests/test_bench_placement.py:89: AttributeError
_______ test_a_negative_placement_means_all_layers_and_still_walks_down ________

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_a_negative_placement_mean0')

    def test_a_negative_placement_means_all_layers_and_still_walks_down(
            tmp_path: pathlib.Path) -> None:
        """`--gpu-layers -1` is the bench default on a GPU box: offload everything, reduce from there.
    
        Reading it as "0 or fewer layers, nothing to reduce" (the parent tree did) makes the ladder
        empty on the one host class this card is about.
        """
        n_layer = 8
        model_path = model_file(tmp_path, n_layer=n_layer)
        facts = fit.ModelFacts.read(model_path, want_sha256=False)
        all_layers = dataclasses.replace(
            fit.estimate_plan(facts, roomy_gpu_host(), n_ctx=4096), n_gpu_layers=-1)
    
        steps = fit.degrade_ladder(all_layers, facts)
    
>       assert [(step.n_gpu_layers, step.kv_type) for step in steps] == [
            (n_layer // 2, "f16"), (0, "f16"), (0, "q8_0"), (0, "q4_0")]
E       AssertionError: assert [(0, 'q8_0'), (0, 'q4_0')] == [(4, 'f16'), ..., (0, 'q4_0')]
E         
E         At index 0 diff: (0, 'q8_0') != (4, 'f16')
E         Right contains 2 more items, first extra item: (0, 'q8_0')
E         Use -v to get more diff

tests/test_bench_placement.py:108: AssertionError
_________ test_the_bench_load_seam_walks_the_ladder_instead_of_raising _________

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_the_bench_load_seam_walks0')

    def test_the_bench_load_seam_walks_the_ladder_instead_of_raising(tmp_path: pathlib.Path) -> None:
        """RED on the parent commit: the first `model.load()` of a bench run raised `AttributeError`.
    
        `harness.LiveModel.load()` is the only call the suites make to reach the loader, so this is
        the bench path itself — with a backend that fails while anything is offloaded, exactly like
        the operator's busy desktop.
        """
        backend = FakeBackend(n_layer=LAYERS)                     # fails while n_gpu_layers > 0
        model_path = model_file(tmp_path)
    
        with fake_runtime(tmp_path, backend):
            model = harness.LiveModel(bench_spec(model_path, backend))
            try:
>               load_ms = float(model.load())
                                ^^^^^^^^^^^^

tests/test_bench_placement.py:128: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/ggufone/bench/harness.py:379: in load
    self.handle = session_module.open_model(self.spec.path, runtime_dir=self.spec.runtime_dir,
src/ggufone/engine/session.py:250: in open_model
    walk = [step for step in fit.degrade_ladder(fit_plan, facts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

plan = Placement(n_gpu_layers=4)
model = ModelFacts(path='/tmp/pytest-of-root/pytest-11153/test_the_bench_load_seam_walks0/model.gguf', sha256='', arch='spark2_5', n_layer=4, n_kv_head=4, key_len=256, value_len=256, n_ctx_train=32768, weights_bytes=2432, file_size=4494)

    def degrade_ladder(plan: FitPlan, model: ModelFacts) -> tuple[FitPlan, ...]:
        """The documented degradation ladder: fewer layers -> smaller kv_type -> CPU-only.
    
        Ordered by decreasing device footprint, ending at a plan that asks the device for nothing, so
        the last rung is always available. Each step carries `W_FIT_DOWNGRADE` (the plan was reduced)
        and, when the KV type moved, `W_KV_TYPE_DOWNGRADE`. A caller walks it until a load succeeds.
        """
        steps: list[FitPlan] = []
        rungs = list(KV_DOWNGRADE_ORDER[KV_DOWNGRADE_ORDER.index(plan.kv_type):]) \
>           if plan.kv_type in KV_DOWNGRADE_ORDER else list(KV_DOWNGRADE_ORDER)
               ^^^^^^^^^^^^
E       AttributeError: 'Placement' object has no attribute 'kv_type'

src/ggufone/runtime/fit.py:489: AttributeError
___ test_a_bench_placement_the_device_holds_loads_with_the_requested_layers ____

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_a_bench_placement_the_dev0')

    def test_a_bench_placement_the_device_holds_loads_with_the_requested_layers(
            tmp_path: pathlib.Path) -> None:
        """The happy half of the same seam: no degradation, and the placement says what it did."""
        backend = FakeBackend(n_layer=LAYERS, fail=lambda ngl, call: False)
        model_path = model_file(tmp_path)
    
        with fake_runtime(tmp_path, backend):
            model = harness.LiveModel(bench_spec(model_path, backend))
            try:
>               model.load()

tests/test_bench_placement.py:162: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/ggufone/bench/harness.py:379: in load
    self.handle = session_module.open_model(self.spec.path, runtime_dir=self.spec.runtime_dir,
src/ggufone/engine/session.py:250: in open_model
    walk = [step for step in fit.degrade_ladder(fit_plan, facts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

plan = Placement(n_gpu_layers=4)
model = ModelFacts(path='/tmp/pytest-of-root/pytest-11153/test_a_bench_placement_the_dev0/model.gguf', sha256='', arch='spark2_5', n_layer=4, n_kv_head=4, key_len=256, value_len=256, n_ctx_train=32768, weights_bytes=2432, file_size=4494)

    def degrade_ladder(plan: FitPlan, model: ModelFacts) -> tuple[FitPlan, ...]:
        """The documented degradation ladder: fewer layers -> smaller kv_type -> CPU-only.
    
        Ordered by decreasing device footprint, ending at a plan that asks the device for nothing, so
        the last rung is always available. Each step carries `W_FIT_DOWNGRADE` (the plan was reduced)
        and, when the KV type moved, `W_KV_TYPE_DOWNGRADE`. A caller walks it until a load succeeds.
        """
        steps: list[FitPlan] = []
        rungs = list(KV_DOWNGRADE_ORDER[KV_DOWNGRADE_ORDER.index(plan.kv_type):]) \
>           if plan.kv_type in KV_DOWNGRADE_ORDER else list(KV_DOWNGRADE_ORDER)
               ^^^^^^^^^^^^
E       AttributeError: 'Placement' object has no attribute 'kv_type'

src/ggufone/runtime/fit.py:489: AttributeError
_____ test_the_row_carries_the_request_and_the_usage_for_a_model_free_seam _____

    def test_the_row_carries_the_request_and_the_usage_for_a_model_free_seam() -> None:
        """The model-free seam never saw a loader: the report says so instead of inventing a usage."""
        spec = harness.ModelSpec(path="/tmp/none.gguf", backend="cpu", n_gpu_layers=8)
    
        class Seamless:
            pass
    
>       assert harness.placement_of(Seamless(), spec) == {"requested": "n_gpu_layers=8", "used": None}
               ^^^^^^^^^^^^^^^^^^^^
E       AttributeError: module 'ggufone.bench.harness' has no attribute 'placement_of'

tests/test_bench_placement.py:183: AttributeError
__________ test_the_rendered_table_prints_the_placement_the_row_used ___________

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_the_rendered_table_prints0')

    def test_the_rendered_table_prints_the_placement_the_row_used(tmp_path: pathlib.Path) -> None:
        """The published table must name both the request and what the loader did with it."""
    
        def rendered(backend: FakeBackend) -> str:
            model_path = model_file(tmp_path)
            with fake_runtime(tmp_path, backend):
                model = harness.LiveModel(bench_spec(model_path, backend))
                try:
                    model.load()
                    report = {"suite": "latency", "generated_at": "2026-01-01T00:00:00Z",
                              "host": {}, "config": {}, "commands": {},
                              "model": {"name": "model.gguf"},
                              "placement": harness.placement_of(model, model.spec)}
                    return harness.render_report(report)
                finally:
                    model.close()
    
>       fits = rendered(FakeBackend(n_layer=LAYERS, fail=lambda ngl, call: False))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_bench_placement.py:203: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_bench_placement.py:194: in rendered
    model.load()
src/ggufone/bench/harness.py:379: in load
    self.handle = session_module.open_model(self.spec.path, runtime_dir=self.spec.runtime_dir,
src/ggufone/engine/session.py:250: in open_model
    walk = [step for step in fit.degrade_ladder(fit_plan, facts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

plan = Placement(n_gpu_layers=4)
model = ModelFacts(path='/tmp/pytest-of-root/pytest-11153/test_the_rendered_table_prints0/model.gguf', sha256='', arch='spark2_5', n_layer=4, n_kv_head=4, key_len=256, value_len=256, n_ctx_train=32768, weights_bytes=2432, file_size=4494)

    def degrade_ladder(plan: FitPlan, model: ModelFacts) -> tuple[FitPlan, ...]:
        """The documented degradation ladder: fewer layers -> smaller kv_type -> CPU-only.
    
        Ordered by decreasing device footprint, ending at a plan that asks the device for nothing, so
        the last rung is always available. Each step carries `W_FIT_DOWNGRADE` (the plan was reduced)
        and, when the KV type moved, `W_KV_TYPE_DOWNGRADE`. A caller walks it until a load succeeds.
        """
        steps: list[FitPlan] = []
        rungs = list(KV_DOWNGRADE_ORDER[KV_DOWNGRADE_ORDER.index(plan.kv_type):]) \
>           if plan.kv_type in KV_DOWNGRADE_ORDER else list(KV_DOWNGRADE_ORDER)
               ^^^^^^^^^^^^
E       AttributeError: 'Placement' object has no attribute 'kv_type'

src/ggufone/runtime/fit.py:489: AttributeError
___________ test_a_negative_placement_says_it_asked_for_every_layer ____________

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_a_negative_placement_says0')

    def test_a_negative_placement_says_it_asked_for_every_layer(tmp_path: pathlib.Path) -> None:
        """`-1` is "every layer", not "nothing offloaded": the note the operator reads must say so."""
        backend = FakeBackend(n_layer=LAYERS, fail=lambda ngl, call: False)
        model_path = model_file(tmp_path)
    
        with fake_runtime(tmp_path, backend):
            model = harness.LiveModel(bench_spec(model_path, backend, layers=-1))
            try:
>               model.load()

tests/test_bench_placement.py:221: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/ggufone/bench/harness.py:379: in load
    self.handle = session_module.open_model(self.spec.path, runtime_dir=self.spec.runtime_dir,
src/ggufone/engine/session.py:250: in open_model
    walk = [step for step in fit.degrade_ladder(fit_plan, facts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

plan = Placement(n_gpu_layers=-1)
model = ModelFacts(path='/tmp/pytest-of-root/pytest-11153/test_a_negative_placement_says0/model.gguf', sha256='', arch='spark2_5', n_layer=4, n_kv_head=4, key_len=256, value_len=256, n_ctx_train=32768, weights_bytes=2432, file_size=4494)

    def degrade_ladder(plan: FitPlan, model: ModelFacts) -> tuple[FitPlan, ...]:
        """The documented degradation ladder: fewer layers -> smaller kv_type -> CPU-only.
    
        Ordered by decreasing device footprint, ending at a plan that asks the device for nothing, so
        the last rung is always available. Each step carries `W_FIT_DOWNGRADE` (the plan was reduced)
        and, when the KV type moved, `W_KV_TYPE_DOWNGRADE`. A caller walks it until a load succeeds.
        """
        steps: list[FitPlan] = []
        rungs = list(KV_DOWNGRADE_ORDER[KV_DOWNGRADE_ORDER.index(plan.kv_type):]) \
>           if plan.kv_type in KV_DOWNGRADE_ORDER else list(KV_DOWNGRADE_ORDER)
               ^^^^^^^^^^^^
E       AttributeError: 'Placement' object has no attribute 'kv_type'

src/ggufone/runtime/fit.py:489: AttributeError
___________ test_a_placement_that_fits_nowhere_is_a_typed_oom_error ____________

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_a_placement_that_fits_now0')

    def test_a_placement_that_fits_nowhere_is_a_typed_oom_error(tmp_path: pathlib.Path) -> None:
        """Every rung fails: `E_BACKEND_OOM` (exit 3) — never an `AttributeError` in `E_INTERNAL`."""
        backend = FakeBackend(n_layer=LAYERS, fail=lambda ngl, call: True)
        model_path = model_file(tmp_path)
    
        with fake_runtime(tmp_path, backend), pytest.raises(BackendOomError) as excinfo:
>           session_module.open_model(model_path, runtime_dir=backend.directory,
                                      fit_plan=harness.Placement(LAYERS), free_probe=lambda: 1112 * MIB)

tests/test_bench_placement.py:237: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/ggufone/engine/session.py:250: in open_model
    walk = [step for step in fit.degrade_ladder(fit_plan, facts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

plan = Placement(n_gpu_layers=4)
model = ModelFacts(path='/tmp/pytest-of-root/pytest-11153/test_a_placement_that_fits_now0/model.gguf', sha256='', arch='spark2_5', n_layer=4, n_kv_head=4, key_len=256, value_len=256, n_ctx_train=32768, weights_bytes=2432, file_size=4494)

    def degrade_ladder(plan: FitPlan, model: ModelFacts) -> tuple[FitPlan, ...]:
        """The documented degradation ladder: fewer layers -> smaller kv_type -> CPU-only.
    
        Ordered by decreasing device footprint, ending at a plan that asks the device for nothing, so
        the last rung is always available. Each step carries `W_FIT_DOWNGRADE` (the plan was reduced)
        and, when the KV type moved, `W_KV_TYPE_DOWNGRADE`. A caller walks it until a load succeeds.
        """
        steps: list[FitPlan] = []
        rungs = list(KV_DOWNGRADE_ORDER[KV_DOWNGRADE_ORDER.index(plan.kv_type):]) \
>           if plan.kv_type in KV_DOWNGRADE_ORDER else list(KV_DOWNGRADE_ORDER)
               ^^^^^^^^^^^^
E       AttributeError: 'Placement' object has no attribute 'kv_type'

src/ggufone/runtime/fit.py:489: AttributeError
_____ test_the_bench_cli_reports_the_typed_reason_never_an_attribute_error _____

tmp_path = PosixPath('/tmp/pytest-of-root/pytest-11153/test_the_bench_cli_reports_the0')
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f586064ef10>
capsys = <_pytest.capture.CaptureFixture object at 0x7f586064fb10>

    def test_the_bench_cli_reports_the_typed_reason_never_an_attribute_error(
            tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch,
            capsys: pytest.CaptureFixture[str]) -> None:
        """The surface the operator runs: a bench row that cannot load names the typed code."""
        backend = FakeBackend(n_layer=LAYERS, fail=lambda ngl, call: True)
        model_path = model_file(tmp_path)
    
        with fake_runtime(tmp_path, backend):
            # the bench discovers bundles itself: point it at the fake one for this run
            monkeypatch.setattr(harness, "backend_runtimes",
                                lambda **kwargs: {"cpu": backend.directory})
            code = cli.main(["bench", "--suite", "throughput", "--model", str(model_path),
                             "--gpu-layers", str(LAYERS), "--runs", "1", "--json"])
        report: dict[str, Any] = json.loads(capsys.readouterr().out)
        row = report["backends"][0]
        assert code == 1                                   # nothing was measured: a reported row
        assert row["measured"] is False
>       assert "E_BACKEND_OOM" in row["reason"]
E       assert 'E_BACKEND_OOM' in "AttributeError: 'Placement' object has no attribute 'kv_type'"

tests/test_bench_placement.py:260: AssertionError
=========================== short test summary info ============================
FAILED tests/test_bench_placement.py::test_the_ladder_normalizes_a_placement_and_never_returns_an_unknown_kv_type
FAILED tests/test_bench_placement.py::test_a_real_plan_keeps_its_identity_through_the_normalization
FAILED tests/test_bench_placement.py::test_a_negative_placement_means_all_layers_and_still_walks_down
FAILED tests/test_bench_placement.py::test_the_bench_load_seam_walks_the_ladder_instead_of_raising
FAILED tests/test_bench_placement.py::test_a_bench_placement_the_device_holds_loads_with_the_requested_layers
FAILED tests/test_bench_placement.py::test_the_row_carries_the_request_and_the_usage_for_a_model_free_seam
FAILED tests/test_bench_placement.py::test_the_rendered_table_prints_the_placement_the_row_used
FAILED tests/test_bench_placement.py::test_a_negative_placement_says_it_asked_for_every_layer
FAILED tests/test_bench_placement.py::test_a_placement_that_fits_nowhere_is_a_typed_oom_error
FAILED tests/test_bench_placement.py::test_the_bench_cli_reports_the_typed_reason_never_an_attribute_error
10 failed in 1.15s
