From 90cbb094829501706b79eaab356a623328a4f23f Mon Sep 17 00:00:00 2001 From: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:03:00 -0800 Subject: [PATCH] tinygrad: sync tinygrad and recompile models (#1464) * ref * add in the fixes * Update fetcher.py * Update helpers.py * force push same commit so we can restart CI --- selfdrive/modeld/SConscript | 4 ++-- selfdrive/modeld/dmonitoringmodeld.py | 2 +- selfdrive/modeld/modeld.py | 2 +- sunnypilot/models/fetcher.py | 2 +- sunnypilot/models/helpers.py | 4 ++-- sunnypilot/models/runners/model_runner.py | 7 ++----- tinygrad_repo | 2 +- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index 6802b45e6..1a6df4bb9 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -51,8 +51,8 @@ def tg_compile(flags, model_name): for model_name in ['driving_vision', 'driving_policy', 'dmonitoring_model']: flags = { 'larch64': 'DEV=QCOM', - 'Darwin': 'DEV=CPU IMAGE=0', - }.get(arch, 'DEV=LLVM IMAGE=0') + 'Darwin': f'DEV=CPU HOME={os.path.expanduser("~")} IMAGE=0', # tinygrad calls brew which needs a $HOME in the env + }.get(arch, 'DEV=CPU CPU_LLVM=1 IMAGE=0') tg_compile(flags, model_name) # Compile BIG model if USB GPU is available diff --git a/selfdrive/modeld/dmonitoringmodeld.py b/selfdrive/modeld/dmonitoringmodeld.py index 215056e6e..5aeb035bd 100755 --- a/selfdrive/modeld/dmonitoringmodeld.py +++ b/selfdrive/modeld/dmonitoringmodeld.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import os from openpilot.system.hardware import TICI -os.environ['DEV'] = 'QCOM' if TICI else 'LLVM' +os.environ['DEV'] = 'QCOM' if TICI else 'CPU' from tinygrad.tensor import Tensor from tinygrad.dtype import dtypes import math diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 00b49afab..9ac21a18d 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import os from openpilot.system.hardware import TICI -os.environ['DEV'] = 'QCOM' if TICI else 'LLVM' +os.environ['DEV'] = 'QCOM' if TICI else 'CPU' USBGPU = "USBGPU" in os.environ if USBGPU: os.environ['DEV'] = 'AMD' diff --git a/sunnypilot/models/fetcher.py b/sunnypilot/models/fetcher.py index 8c9c4eac7..0c14315ff 100644 --- a/sunnypilot/models/fetcher.py +++ b/sunnypilot/models/fetcher.py @@ -116,7 +116,7 @@ class ModelCache: class ModelFetcher: """Handles fetching and caching of model data from remote source""" - MODEL_URL = "https://docs.sunnypilot.ai/driving_models_v8.json" + MODEL_URL = "https://raw.githubusercontent.com/sunnypilot/sunnypilot-docs/refs/heads/gh-pages/docs/driving_models_v9.json" def __init__(self, params: Params): self.params = params diff --git a/sunnypilot/models/helpers.py b/sunnypilot/models/helpers.py index 20b94fb61..51a3a2459 100644 --- a/sunnypilot/models/helpers.py +++ b/sunnypilot/models/helpers.py @@ -19,8 +19,8 @@ from openpilot.system.hardware.hw import Paths from pathlib import Path # see the README.md for more details on the model selector versioning -CURRENT_SELECTOR_VERSION = 10 -REQUIRED_MIN_SELECTOR_VERSION = 9 +CURRENT_SELECTOR_VERSION = 11 +REQUIRED_MIN_SELECTOR_VERSION = 11 USE_ONNX = os.getenv('USE_ONNX', PC) diff --git a/sunnypilot/models/runners/model_runner.py b/sunnypilot/models/runners/model_runner.py index 712466279..6902ed09b 100644 --- a/sunnypilot/models/runners/model_runner.py +++ b/sunnypilot/models/runners/model_runner.py @@ -14,13 +14,10 @@ CUSTOM_MODEL_PATH = Paths.model_root() # Set QCOM environment variable for TICI devices, potentially enabling hardware acceleration USBGPU = "USBGPU" in os.environ if USBGPU: - os.environ['AMD'] = '1' + os.environ['DEV'] = 'AMD' os.environ['AMD_IFACE'] = 'USB' -elif TICI: - os.environ['QCOM'] = '1' else: - os.environ['LLVM'] = '1' - os.environ['JIT'] = '2' # TODO: This may cause issues + os.environ['DEV'] = 'QCOM' if TICI else 'CPU' class ModelData: diff --git a/tinygrad_repo b/tinygrad_repo index d2bb1bcb9..7296c74cb 160000 --- a/tinygrad_repo +++ b/tinygrad_repo @@ -1 +1 @@ -Subproject commit d2bb1bcb976f106a41928f2d66d354ab7afd6f59 +Subproject commit 7296c74cbd2666da7dce95d7ca6dab5340653a5c