IQ.Pilot Release Commit @ 0012d8f

This commit is contained in:
IQ.Lvbs CI [bot]
2026-07-22 20:21:04 -05:00
parent 0952a162ef
commit f94087822f
6 changed files with 76 additions and 17 deletions

View File

@@ -72,7 +72,10 @@ for model_name in ['dmonitoring_model']:
# inputs (onnx + tinygrad_repo + flags + metadata script) and output hashes; if it matches, skip
# declaring the targets entirely. Any mismatch falls back to a normal on-device compile.
if arch == "larch64":
from openpilot.selfdrive.modeld.prebuilt_models import verify_prebuilt, outputs_match
from openpilot.selfdrive.modeld.prebuilt_models import packaged_prebuilt_matches, verify_prebuilt, outputs_match
if packaged_prebuilt_matches(model_name):
print(lenv.PrettyNote('SKIP', f"{model_name} — packaged prebuilt pkl"))
continue
if verify_prebuilt(model_name, flags):
print(lenv.PrettyNote('SKIP', f"{model_name} — prebuilt pkl"))
continue

View File

@@ -77,7 +77,13 @@ def outputs_match(model_name: str) -> bool:
return True
def packaged_prebuilt_matches(model_name: str) -> bool:
return not (MODELS_DIR / f'{model_name}.onnx').is_file() and outputs_match(model_name)
def verify_prebuilt(model_name: str, flags: str) -> bool:
if not (MODELS_DIR / f'{model_name}.onnx').is_file():
return False
data = _load_checks().get(model_name, {})
if data.get('signature') != compute_signature(model_name, flags):
return False

View File

@@ -0,0 +1,51 @@
import hashlib
import json
from openpilot.selfdrive.modeld import prebuilt_models
def write_outputs(models_dir, check_path):
outputs = {}
for name, contents in {
'dmonitoring_model_tinygrad.pkl': b'tinygrad',
'dmonitoring_model_metadata.pkl': b'metadata',
}.items():
(models_dir / name).write_bytes(contents)
outputs[name] = hashlib.sha256(contents).hexdigest()
check_path.write_text(json.dumps({'dmonitoring_model': {'outputs': outputs}}))
def test_packaged_prebuilt_without_onnx(tmp_path, monkeypatch):
models_dir = tmp_path / 'models'
models_dir.mkdir()
check_path = models_dir / 'prebuilt_check.json'
write_outputs(models_dir, check_path)
monkeypatch.setattr(prebuilt_models, 'MODELS_DIR', models_dir)
monkeypatch.setattr(prebuilt_models, 'CHECK_PATH', check_path)
assert prebuilt_models.packaged_prebuilt_matches('dmonitoring_model')
assert not prebuilt_models.verify_prebuilt('dmonitoring_model', 'flags')
def test_packaged_prebuilt_rejects_corrupt_output(tmp_path, monkeypatch):
models_dir = tmp_path / 'models'
models_dir.mkdir()
check_path = models_dir / 'prebuilt_check.json'
write_outputs(models_dir, check_path)
(models_dir / 'dmonitoring_model_tinygrad.pkl').write_bytes(b'corrupt')
monkeypatch.setattr(prebuilt_models, 'MODELS_DIR', models_dir)
monkeypatch.setattr(prebuilt_models, 'CHECK_PATH', check_path)
assert not prebuilt_models.packaged_prebuilt_matches('dmonitoring_model')
def test_source_checkout_is_not_packaged_prebuilt(tmp_path, monkeypatch):
models_dir = tmp_path / 'models'
models_dir.mkdir()
check_path = models_dir / 'prebuilt_check.json'
write_outputs(models_dir, check_path)
(models_dir / 'dmonitoring_model.onnx').write_bytes(b'onnx')
monkeypatch.setattr(prebuilt_models, 'MODELS_DIR', models_dir)
monkeypatch.setattr(prebuilt_models, 'CHECK_PATH', check_path)
assert not prebuilt_models.packaged_prebuilt_matches('dmonitoring_model')