IQ.Pilot Release Commit @ bec7652
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
// clang++ -O2 repro.cc && ./a.out
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
@@ -5,12 +8,12 @@ from types import SimpleNamespace
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from cereal import log
|
||||
from iqpilot.cereal import log
|
||||
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.config import Plan
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.daemon import NeuralEngineState, _merged_plan
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.daemon as iqmodeld_daemon
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import smooth_value
|
||||
from iqpilot.selfdrive.iqmodeld.config import Plan
|
||||
from iqpilot.selfdrive.iqmodeld.daemon import NeuralEngineState, _merged_plan
|
||||
import iqpilot.selfdrive.iqmodeld.daemon as iqmodeld_daemon
|
||||
from iqpilot.selfdrive.controls.lib.drive_helpers import smooth_value
|
||||
|
||||
|
||||
def _fake_state(**overrides):
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
@@ -5,13 +8,14 @@ from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.combined_artifact import resolve_combined_split_artifact
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner as runner_helpers
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.combined_split_runner import TinygradCombinedSplitRunner
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad import combined_split_runner as combined_runner_mod
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.parser import PhaseParser
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.tests.test_iqmodeld_contracts import _phase_sample
|
||||
from iqpilot.selfdrive.iqmodeld.models.combined_artifact import resolve_combined_split_artifact
|
||||
import iqpilot.selfdrive.iqmodeld.models.runners.model_runner as runner_helpers
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad import tinygrad_runner as tinygrad_runner_mod
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.combined_split_runner import TinygradCombinedSplitRunner
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad import combined_split_runner as combined_runner_mod
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from iqpilot.selfdrive.iqmodeld.parser import PhaseParser
|
||||
from iqpilot.selfdrive.iqmodeld.tests.test_iqmodeld_contracts import _phase_sample
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -77,7 +81,7 @@ def test_resolve_combined_split_artifact_prefers_override(tmp_path: Path, monkey
|
||||
expected = tmp_path / "driving_combined_demo.pkl"
|
||||
expected.write_bytes(b"iq")
|
||||
|
||||
monkeypatch.setattr("openpilot.iqpilot.selfdrive.iqmodeld.models.combined_artifact._MODEL_ROOT", tmp_path)
|
||||
monkeypatch.setattr("iqpilot.selfdrive.iqmodeld.models.combined_artifact._MODEL_ROOT", tmp_path)
|
||||
|
||||
assert resolve_combined_split_artifact(bundle) == expected
|
||||
|
||||
@@ -89,7 +93,7 @@ def test_get_model_runner_prefers_combined_split_artifact(monkeypatch):
|
||||
], generation=11)
|
||||
|
||||
marker = object()
|
||||
monkeypatch.setattr(runner_helpers, "get_active_bundle", lambda: bundle)
|
||||
monkeypatch.setattr(runner_helpers, "_fetch_bundle", lambda: bundle)
|
||||
monkeypatch.setattr(runner_helpers, "has_combined_split_artifact", lambda _: True)
|
||||
monkeypatch.setattr(combined_runner_mod, "TinygradCombinedSplitRunner", lambda: marker)
|
||||
|
||||
@@ -103,9 +107,9 @@ def test_get_model_runner_keeps_split_bundle_on_existing_runner_without_combined
|
||||
], generation=12)
|
||||
|
||||
marker = object()
|
||||
monkeypatch.setattr(runner_helpers, "get_active_bundle", lambda: bundle)
|
||||
monkeypatch.setattr(runner_helpers, "_fetch_bundle", lambda: bundle)
|
||||
monkeypatch.setattr(runner_helpers, "has_combined_split_artifact", lambda _: False)
|
||||
monkeypatch.setattr(runner_helpers, "TinygradSplitRunner", lambda: marker)
|
||||
monkeypatch.setattr(tinygrad_runner_mod, "TinygradSplitRunner", lambda: marker)
|
||||
|
||||
assert runner_helpers.get_model_runner() is marker
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.tools.compile_supercombo import (
|
||||
from iqpilot.selfdrive.iqmodeld.tools.compile_supercombo import (
|
||||
_captured_devices,
|
||||
_captured_queue_depth,
|
||||
_validate_pose_outputs,
|
||||
)
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.supercombo_runner import _captured_queue_depth
|
||||
|
||||
|
||||
class _Captured:
|
||||
|
||||
128
iqpilot/selfdrive/iqmodeld/tests/test_fused_runner_guards.py
Normal file
128
iqpilot/selfdrive/iqmodeld/tests/test_fused_runner_guards.py
Normal file
@@ -0,0 +1,128 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pickle
|
||||
from dataclasses import dataclass
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners import model_runner as model_runner_mod
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad import fused_runner as fused_mod
|
||||
|
||||
|
||||
class _View:
|
||||
def __init__(self, shape):
|
||||
self.shape = shape
|
||||
|
||||
|
||||
class _Captured:
|
||||
def __init__(self, expected_names, expected_input_info):
|
||||
self.expected_names = expected_names
|
||||
self.expected_input_info = expected_input_info
|
||||
|
||||
|
||||
class _FakeJit:
|
||||
def __init__(self, expected_names, expected_input_info):
|
||||
self.captured = _Captured(expected_names, expected_input_info)
|
||||
|
||||
def __call__(self, **kwargs):
|
||||
raise AssertionError("policy jit should not run in this test")
|
||||
|
||||
|
||||
class _FakeTensor:
|
||||
def __init__(self, arr, device=None):
|
||||
self.shape = tuple(np.asarray(arr).shape)
|
||||
|
||||
def contiguous(self):
|
||||
return self
|
||||
|
||||
def realize(self):
|
||||
return self
|
||||
|
||||
|
||||
class _FakeDevice:
|
||||
DEFAULT = "FAKE"
|
||||
|
||||
|
||||
@dataclass
|
||||
class _Type:
|
||||
raw: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class _Artifact:
|
||||
fileName: str
|
||||
|
||||
|
||||
class _Model:
|
||||
def __init__(self, file_name):
|
||||
self.type = _Type(ModelType.vision)
|
||||
self.artifact = _Artifact(file_name)
|
||||
self.metadata = None
|
||||
|
||||
|
||||
class _Bundle:
|
||||
def __init__(self, file_name):
|
||||
self.models = [_Model(file_name)]
|
||||
self.is20hz = True
|
||||
|
||||
|
||||
POLICY_INPUTS = ["action_t", "big_img", "desire", "desire_q", "feat_q", "img", "traffic_convention"]
|
||||
POLICY_SHAPES = {
|
||||
"action_t": (1, 2), "big_img": (1, 12, 128, 256), "desire": (1, 8), "desire_q": (1, 100, 8),
|
||||
"feat_q": (1, 99, 512), "img": (1, 12, 128, 256), "traffic_convention": (1, 2),
|
||||
}
|
||||
|
||||
|
||||
def _write_fused_pkl(path, policy_inputs):
|
||||
info = [(_View(POLICY_SHAPES[n]), (), None, "NPY") for n in policy_inputs]
|
||||
role_meta = {
|
||||
"input_shapes": {"desire_pulse": (1, 100, 8), "traffic_convention": (1, 2), "features_buffer": (1, 99, 512)},
|
||||
"output_slices": {},
|
||||
}
|
||||
blob = {
|
||||
"metadata": {
|
||||
"vision": {"input_shapes": {"img": (1, 12, 128, 256), "big_img": (1, 12, 128, 256)}, "output_slices": {}},
|
||||
"on_policy": role_meta,
|
||||
"off_policy": role_meta,
|
||||
},
|
||||
"run_policy": _FakeJit(policy_inputs, info),
|
||||
"frame_skip": 4,
|
||||
(1928, 1208): _FakeJit(["frame"], [(_View((1,)), (), None, "NPY")]),
|
||||
}
|
||||
with open(path, "wb") as f:
|
||||
pickle.dump(blob, f)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fused_runner(tmp_path, monkeypatch):
|
||||
def _build(policy_inputs):
|
||||
name = "driving_fused_test.pkl"
|
||||
_write_fused_pkl(tmp_path / name, policy_inputs)
|
||||
monkeypatch.setattr(model_runner_mod, "_fetch_bundle", lambda params=None: _Bundle(name))
|
||||
monkeypatch.setattr(fused_mod, "CUSTOM_MODEL_PATH", str(tmp_path))
|
||||
monkeypatch.setattr(fused_mod, "_tinygrad_imports", lambda: (_FakeTensor, _FakeDevice))
|
||||
return fused_mod.TinygradFusedRunner()
|
||||
return _build
|
||||
|
||||
|
||||
def test_action_t_allocated_when_only_the_jit_declares_it(fused_runner):
|
||||
runner = fused_runner(POLICY_INPUTS)
|
||||
assert "action_t" not in runner._on_meta["input_shapes"]
|
||||
|
||||
runner._ensure_queues(1928, 1208)
|
||||
|
||||
assert runner._npy_buffers["action_t"].shape == POLICY_SHAPES["action_t"]
|
||||
assert runner._npy_buffers["traffic_convention"].shape == POLICY_SHAPES["traffic_convention"]
|
||||
|
||||
|
||||
def test_action_t_absent_when_the_jit_does_not_take_it(fused_runner):
|
||||
runner = fused_runner([n for n in POLICY_INPUTS if n != "action_t"])
|
||||
|
||||
runner._ensure_queues(1928, 1208)
|
||||
|
||||
assert "action_t" not in runner._npy_buffers
|
||||
@@ -1,20 +1,23 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
|
||||
import cereal.messaging as messaging
|
||||
import iqpilot.cereal.messaging as messaging
|
||||
import numpy as np
|
||||
from cereal import log
|
||||
from iqpilot.cereal import log
|
||||
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.config import Meta, ModelConstants
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.messaging import (
|
||||
from iqpilot.selfdrive.iqmodeld.config import Meta, ModelConstants
|
||||
from iqpilot.selfdrive.iqmodeld.messaging import (
|
||||
DrivePacketMemory,
|
||||
pick_curvature,
|
||||
populate_drive_messages,
|
||||
populate_odometry_message,
|
||||
)
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.split_model_constants import SplitModelConstants
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.parser import ArchiveParser, PhaseParser
|
||||
from iqpilot.selfdrive.iqmodeld.models.split_model_constants import SplitModelConstants
|
||||
from iqpilot.selfdrive.iqmodeld.parser import ArchiveParser, PhaseParser
|
||||
|
||||
|
||||
def _archive_sample(rng: np.random.Generator) -> dict[str, np.ndarray]:
|
||||
|
||||
72
iqpilot/selfdrive/iqmodeld/tests/test_lat_delay_source.py
Normal file
72
iqpilot/selfdrive/iqmodeld/tests/test_lat_delay_source.py
Normal file
@@ -0,0 +1,72 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from iqpilot.cereal import car
|
||||
from iqpilot.common.params import Params
|
||||
from iqpilot.selfdrive.iqmodeld.daemon import InferenceDaemon
|
||||
|
||||
LIVE_DELAY = 0.4387
|
||||
RACK_DELAY = 0.10
|
||||
OFFSET = 0.05
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def params(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("PARAMS_ROOT", str(tmp_path))
|
||||
p = Params()
|
||||
p.put("IQSteerDelayCache", LIVE_DELAY)
|
||||
p.put("IQSoftwareSteerDelay", OFFSET)
|
||||
p.put_bool("ModelSmoothingEnabled", False)
|
||||
p.put("ModelLatSmoothSec", 0)
|
||||
p.put("PlanplusControl", 1.0)
|
||||
p.put("CameraOffset", 0.0)
|
||||
return p
|
||||
|
||||
|
||||
def _daemon(params, steer_control_type):
|
||||
car_params = car.CarParams.new_message()
|
||||
car_params.steerControlType = steer_control_type
|
||||
car_params.steerActuatorDelay = RACK_DELAY
|
||||
return SimpleNamespace(
|
||||
_params=params,
|
||||
_car_params=car_params,
|
||||
_sub={"lateralDelay": SimpleNamespace(lateralDelay=LIVE_DELAY)},
|
||||
_runtime=SimpleNamespace(lat_delay=None, PLANPLUS_CONTROL=None, model_smoothing_max_extra_sec=None),
|
||||
_warps=SimpleNamespace(set_offset=lambda _: None),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("live_enabled, expected", [(False, RACK_DELAY + OFFSET), (True, LIVE_DELAY)])
|
||||
def test_angle_cars_honour_the_self_tuning_toggle(params, live_enabled, expected):
|
||||
params.put_bool("IQLiveSteerDelay", live_enabled)
|
||||
daemon = _daemon(params, car.CarParams.SteerControlType.angle)
|
||||
InferenceDaemon._refresh_tunables(daemon, 0)
|
||||
assert daemon._runtime.lat_delay == pytest.approx(expected)
|
||||
|
||||
|
||||
def test_angle_cars_never_plan_against_the_live_estimate_when_disabled(params):
|
||||
params.put_bool("IQLiveSteerDelay", False)
|
||||
daemon = _daemon(params, car.CarParams.SteerControlType.angle)
|
||||
InferenceDaemon._refresh_tunables(daemon, 0)
|
||||
assert daemon._runtime.lat_delay != pytest.approx(LIVE_DELAY)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("live_enabled", [True, False])
|
||||
def test_torque_cars_keep_the_live_estimate(params, live_enabled):
|
||||
params.put_bool("IQLiveSteerDelay", live_enabled)
|
||||
daemon = _daemon(params, car.CarParams.SteerControlType.torque)
|
||||
InferenceDaemon._refresh_tunables(daemon, 0)
|
||||
assert daemon._runtime.lat_delay == pytest.approx(LIVE_DELAY)
|
||||
|
||||
|
||||
def test_refresh_is_throttled_to_every_sixtieth_tick(params):
|
||||
params.put_bool("IQLiveSteerDelay", False)
|
||||
daemon = _daemon(params, car.CarParams.SteerControlType.angle)
|
||||
InferenceDaemon._refresh_tunables(daemon, 1)
|
||||
assert daemon._runtime.lat_delay is None
|
||||
InferenceDaemon._refresh_tunables(daemon, 60)
|
||||
assert daemon._runtime.lat_delay == pytest.approx(RACK_DELAY + OFFSET)
|
||||
@@ -1,150 +0,0 @@
|
||||
"""
|
||||
Copyright (c) IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.manager import IQModelManager, _DOWNLOAD_INDEX_KEY
|
||||
|
||||
|
||||
@dataclass
|
||||
class _DownloadUri:
|
||||
sha256: str = ""
|
||||
uri: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class _Artifact:
|
||||
fileName: str = ""
|
||||
downloadUri: _DownloadUri = field(default_factory=_DownloadUri)
|
||||
|
||||
|
||||
@dataclass
|
||||
class _Model:
|
||||
artifact: _Artifact = field(default_factory=_Artifact)
|
||||
metadata: _Artifact | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class _Bundle:
|
||||
index: int = 0
|
||||
ref: str = ""
|
||||
internalName: str = ""
|
||||
displayName: str = ""
|
||||
models: list = field(default_factory=list)
|
||||
|
||||
|
||||
class _FakeParams:
|
||||
def __init__(self):
|
||||
self.store = {}
|
||||
|
||||
def get(self, key):
|
||||
return self.store.get(key)
|
||||
|
||||
def put(self, key, value):
|
||||
self.store[key] = value
|
||||
|
||||
def remove(self, key):
|
||||
self.store.pop(key, None)
|
||||
|
||||
|
||||
def _bundle(index, name, sha, filename="driving_vision_test_tinygrad.pkl"):
|
||||
return _Bundle(
|
||||
index=index,
|
||||
ref=f"ref-{name}",
|
||||
internalName=name,
|
||||
displayName=f"{name} display",
|
||||
models=[_Model(artifact=_Artifact(fileName=filename, downloadUri=_DownloadUri(sha256=sha)))],
|
||||
)
|
||||
|
||||
|
||||
def _manager(active, available):
|
||||
mgr = IQModelManager.__new__(IQModelManager)
|
||||
mgr.params = _FakeParams()
|
||||
mgr.active_bundle = active
|
||||
mgr.available_models = available
|
||||
mgr._validated_active_key = None
|
||||
mgr._manifest_refresh_key = None
|
||||
return mgr
|
||||
|
||||
|
||||
def test_stale_active_bundle_queues_redownload_at_current_index():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
counterpart = _bundle(12, "WMIV12", "b" * 64)
|
||||
mgr = _manager(active, [counterpart])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 12
|
||||
assert mgr.active_bundle is active
|
||||
|
||||
|
||||
def test_matching_shas_do_not_queue():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
counterpart = _bundle(12, "WMIV12", "A" * 64)
|
||||
mgr = _manager(active, [counterpart])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
|
||||
|
||||
|
||||
def test_retired_bundle_is_left_alone():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
mgr = _manager(active, [_bundle(12, "OtherModel", "b" * 64)])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
|
||||
assert mgr.active_bundle is active
|
||||
|
||||
|
||||
def test_default_bundle_is_never_refreshed():
|
||||
active = _bundle(0, "Default", "a" * 64)
|
||||
active.ref = "default"
|
||||
mgr = _manager(active, [_bundle(0, "Default", "b" * 64)])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
|
||||
|
||||
|
||||
def test_pending_download_blocks_refresh():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
mgr = _manager(active, [_bundle(12, "WMIV12", "b" * 64)])
|
||||
mgr.params.put(_DOWNLOAD_INDEX_KEY, 3)
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 3
|
||||
|
||||
|
||||
def test_empty_manifest_hash_never_triggers():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
mgr = _manager(active, [_bundle(12, "WMIV12", "")])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
|
||||
|
||||
|
||||
def test_refresh_queued_once_per_run():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
mgr = _manager(active, [_bundle(12, "WMIV12", "b" * 64)])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 12
|
||||
|
||||
mgr.params.remove(_DOWNLOAD_INDEX_KEY)
|
||||
mgr._queue_active_manifest_refresh()
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
|
||||
|
||||
|
||||
def test_counterpart_matched_by_name_not_index():
|
||||
active = _bundle(55, "WMIV12", "a" * 64)
|
||||
imposter = _bundle(55, "OtherModel", "c" * 64)
|
||||
counterpart = _bundle(12, "WMIV12", "b" * 64)
|
||||
mgr = _manager(active, [imposter, counterpart])
|
||||
|
||||
mgr._queue_active_manifest_refresh()
|
||||
|
||||
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 12
|
||||
@@ -1,17 +1,20 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from tinygrad.tensor import Tensor
|
||||
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.helpers as bundle_helpers
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner as model_runner_mod
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner as tinygrad_runner_mod
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner import TinygradRunner
|
||||
import iqpilot.selfdrive.iqmodeld.models.helpers as bundle_helpers
|
||||
import iqpilot.selfdrive.iqmodeld.models.runners.model_runner as model_runner_mod
|
||||
import iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner as tinygrad_runner_mod
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner import TinygradRunner
|
||||
|
||||
|
||||
LOCAL_MODEL_DIR = Path(__file__).resolve().parents[1] / "default_model"
|
||||
@@ -49,6 +52,7 @@ def _seed_runner_inputs(runner: TinygradRunner) -> None:
|
||||
).realize()
|
||||
|
||||
|
||||
@pytest.mark.tici
|
||||
def test_local_tinygrad_models_execute(monkeypatch):
|
||||
bundle = _Bundle([
|
||||
_Model(ModelType.vision, "driving_vision_c210m_tinygrad.pkl", "driving_vision_c210m_metadata.pkl"),
|
||||
@@ -56,7 +60,7 @@ def test_local_tinygrad_models_execute(monkeypatch):
|
||||
])
|
||||
|
||||
monkeypatch.setattr(bundle_helpers, "get_active_bundle", lambda params=None: bundle, raising=False)
|
||||
monkeypatch.setattr(model_runner_mod, "get_active_bundle", lambda params=None: bundle, raising=False)
|
||||
monkeypatch.setattr(model_runner_mod, "_fetch_bundle", lambda params=None: bundle)
|
||||
monkeypatch.setattr(tinygrad_runner_mod, "CUSTOM_MODEL_PATH", str(LOCAL_MODEL_DIR), raising=False)
|
||||
monkeypatch.setattr(model_runner_mod, "CUSTOM_MODEL_PATH", str(LOCAL_MODEL_DIR), raising=False)
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld import metadata, messaging, parser
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.daemon import CaptureStamp, NeuralEngineState
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from iqpilot.selfdrive.iqmodeld import metadata, messaging, parser
|
||||
from iqpilot.selfdrive.iqmodeld.daemon import CaptureStamp, NeuralEngineState
|
||||
|
||||
|
||||
def test_public_module_surface():
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
@@ -5,15 +8,14 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from tinygrad.nn.onnx import OnnxRunner
|
||||
from tinygrad.tensor import Tensor
|
||||
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.helpers as bundle_helpers
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner as model_runner_mod
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner as tinygrad_runner_mod
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner import TinygradRunner
|
||||
import iqpilot.selfdrive.iqmodeld.models.helpers as bundle_helpers
|
||||
import iqpilot.selfdrive.iqmodeld.models.runners.model_runner as model_runner_mod
|
||||
import iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner as tinygrad_runner_mod
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.model_runner import ModelType
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.tinygrad_runner import TinygradRunner
|
||||
|
||||
|
||||
SHARE_ROOT = Path(os.getenv("IQPILOT_SELECTOR_SHARE", "/Volumes/New New Vault/IQModels/models/recompiled16"))
|
||||
@@ -86,6 +88,7 @@ def _run_tinygrad_bundle(bundle_dir: Path, monkeypatch):
|
||||
bundle = _bundle_for_dir(bundle_dir)
|
||||
monkeypatch.setattr(bundle_helpers, "get_active_bundle", lambda params=None: bundle, raising=False)
|
||||
monkeypatch.setattr(model_runner_mod, "get_active_bundle", lambda params=None: bundle, raising=False)
|
||||
monkeypatch.setattr(model_runner_mod, "_fetch_bundle", lambda: bundle)
|
||||
monkeypatch.setattr(tinygrad_runner_mod, "CUSTOM_MODEL_PATH", str(bundle_dir), raising=False)
|
||||
monkeypatch.setattr(model_runner_mod, "CUSTOM_MODEL_PATH", str(bundle_dir), raising=False)
|
||||
|
||||
@@ -122,8 +125,9 @@ def _run_onnx_bundle(bundle_dir: Path):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not SHARE_ROOT.is_dir(), reason="selector model share is not mounted")
|
||||
def test_three_selector_models_parse_via_share_onnx():
|
||||
if not SHARE_ROOT.is_dir():
|
||||
return
|
||||
selector_dirs = _find_selector_dirs(limit=3, require_onnx=True)
|
||||
assert len(selector_dirs) >= 3
|
||||
|
||||
@@ -133,8 +137,9 @@ def test_three_selector_models_parse_via_share_onnx():
|
||||
assert policy_raw.size > 0
|
||||
|
||||
|
||||
@pytest.mark.skipif(not SHARE_ROOT.is_dir(), reason="selector model share is not mounted")
|
||||
def test_selector_tinygrad_pkls_execute_when_host_compatible(monkeypatch):
|
||||
if not SHARE_ROOT.is_dir():
|
||||
return
|
||||
selector_dirs = _find_selector_dirs(limit=10)
|
||||
attempted = 0
|
||||
executed = 0
|
||||
@@ -151,6 +156,10 @@ def test_selector_tinygrad_pkls_execute_when_host_compatible(monkeypatch):
|
||||
if "/dev/kgsl-3d0" in str(exc):
|
||||
continue
|
||||
raise
|
||||
except TypeError as exc:
|
||||
if "DType.__init__()" in str(exc):
|
||||
continue
|
||||
raise
|
||||
|
||||
assert "pose" in vision_outputs
|
||||
assert "plan" in policy_outputs
|
||||
@@ -159,4 +168,4 @@ def test_selector_tinygrad_pkls_execute_when_host_compatible(monkeypatch):
|
||||
break
|
||||
|
||||
if executed == 0:
|
||||
pytest.skip(f"share tinygrad pkls are QCOM-only on this host; inspected {attempted} bundles")
|
||||
assert attempted > 0, "no selector bundles were inspected on the share"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
@@ -5,10 +8,10 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from cereal import custom
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models import helpers as model_helpers
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad import supercombo_runner as supercombo_runner_mod
|
||||
from openpilot.iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.supercombo_runner import (
|
||||
from iqpilot.cereal import custom
|
||||
from iqpilot.selfdrive.iqmodeld.models import helpers as model_helpers
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad import supercombo_runner as supercombo_runner_mod
|
||||
from iqpilot.selfdrive.iqmodeld.models.runners.tinygrad.supercombo_runner import (
|
||||
TinygradSupercomboRunner,
|
||||
)
|
||||
|
||||
@@ -153,6 +156,31 @@ def test_select_default_model_clears_custom_download_state(tmp_path: Path, monke
|
||||
assert not pending_restore.exists()
|
||||
|
||||
|
||||
def test_seed_default_bundle_runs_while_a_download_is_queued(monkeypatch: pytest.MonkeyPatch):
|
||||
monkeypatch.setattr(model_helpers, "ensure_default_model_files", lambda *a, **k: None)
|
||||
|
||||
params = _FakeParams()
|
||||
params.put("ModelManager_DownloadIndex", "81")
|
||||
|
||||
model_helpers.seed_default_bundle_if_unset(params)
|
||||
|
||||
active = params.get("ModelManager_ActiveBundle")
|
||||
assert active is not None and active.get("ref") == "default"
|
||||
assert params.get("ModelManager_DownloadIndex") == "81"
|
||||
|
||||
|
||||
def test_seed_default_bundle_leaves_an_existing_active_bundle_alone(monkeypatch: pytest.MonkeyPatch):
|
||||
monkeypatch.setattr(model_helpers, "ensure_default_model_files", lambda *a, **k: None)
|
||||
|
||||
params = _FakeParams({"index": 81, "ref": "pop"})
|
||||
params.put("ModelManager_DownloadIndex", "81")
|
||||
|
||||
model_helpers.seed_default_bundle_if_unset(params)
|
||||
|
||||
assert params.get("ModelManager_ActiveBundle").get("ref") == "pop"
|
||||
assert params.get("ModelManager_DownloadIndex") == "81"
|
||||
|
||||
|
||||
def test_default_model_is_not_resolved_to_manifest_pop_bundle():
|
||||
pop_bundle = type("Bundle", (), {"internalName": "Pop (Default)", "displayName": "Pop (Default)"})()
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
@@ -6,9 +9,9 @@ from types import SimpleNamespace
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.helpers as bundle_helpers
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.models.runners.model_runner as runner_helpers
|
||||
import openpilot.iqpilot.selfdrive.iqmodeld.daemon as iqmodeld_daemon
|
||||
import iqpilot.selfdrive.iqmodeld.models.helpers as bundle_helpers
|
||||
import iqpilot.selfdrive.iqmodeld.models.runners.model_runner as runner_helpers
|
||||
import iqpilot.selfdrive.iqmodeld.daemon as iqmodeld_daemon
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -9,8 +9,8 @@ import time
|
||||
|
||||
import numpy as np
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from openpilot.system.manager.process_config import managed_processes
|
||||
import iqpilot.cereal.messaging as messaging
|
||||
from iqpilot.system.manager.process_config import managed_processes
|
||||
|
||||
RUN_COUNT = int(os.getenv("N", "5"))
|
||||
WINDOW_SECONDS = int(os.getenv("TIME", "30"))
|
||||
|
||||
Reference in New Issue
Block a user