mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 12:31:13 +00:00
[AZ-300] Implement PytorchFp16Runtime — C7 simple-baseline strategy
AZ-300 mandatory simple-baseline InferenceRuntime (eager FP16 PyTorch).
Implements the AZ-297 Protocol; current_runtime_label returns
"pytorch_fp16". Numerical reference every fancier C7 strategy (AZ-298
TRT, AZ-299 ORT) is measured against, and the only viable runtime for
Tier-1 workstation Docker where TRT is non-trivial to install.
Production code (new):
- components/c7_inference/pytorch_fp16_runtime.py — runtime +
PytorchEngineHandle + output-shape adapter
- components/c7_inference/architecture_registry.py — torch-free
register_architecture / default_registry / ArchitectureFactory
(Risk-1 mitigation: no L2->L3 back-edge from C7 into per-backbone
code)
- components/c7_inference/__init__.py — re-exports the registry
mechanism. Still does NOT import the concrete strategy module
(Invariant I-5)
- components/c7_inference/config.py — adds per_frame_debug_log bool
field (gates the DEBUG per-frame latency log)
Tests (new): tests/unit/c7_inference/test_pytorch_fp16_runtime.py
covers AC-1..AC-8 + NFRs. AC-1/2/6/7 + thermal/release/registry
guards run unconditionally (17 tests); AC-3/4/5/8 +
NFR-perf-deserialize + NFR-reliability-eval-mode require CUDA and
skip on Tier-1 CI / macOS dev.
Tests (modified):
- test_protocol_conformance.py — narrowed
test_ac5_build_inference_runtime_flag_on_but_module_missing
parametrisation to exclude pytorch_fp16 (now-built); TRT / ORT
still covered until AZ-298 / AZ-299 ship.
CI: .github/workflows/ci.yml lint + unit jobs now install
'-e .[dev,inference]' because mypy + pytest need torch + torchvision +
onnxruntime on the runner.
Three task-spec -> as-built deltas documented in
_docs/02_tasks/done/AZ-300_c7_pytorch_baseline.md Implementation Notes:
1. Constructor conforms to AZ-297 factory shape (config positional;
thermal_publisher + registry + clock keyword-only optionals).
AZ-302 will update the factory to thread thermal_publisher.
2. Architecture registry uses extras["model_name"] as lookup key
(avoids touching the frozen BuildConfig / EngineCacheEntry DTOs).
3. Warm-up forward deferred to AZ-300 tier-2 follow-up — the zero-arg
registry has no per-backbone input-shape metadata.
Suite: 1120 passed / 10 skipped (CUDA + Tier-2 + cmake / actionlint
environment gates). No regressions in non-c7_inference areas.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -33,10 +33,12 @@ from gps_denied_onboard.components.c7_inference import (
|
||||
OptimizationProfile,
|
||||
OutOfMemoryError,
|
||||
PrecisionMode,
|
||||
RuntimeError as C7RuntimeError,
|
||||
TelemetryUnavailableError,
|
||||
ThermalState,
|
||||
)
|
||||
from gps_denied_onboard.components.c7_inference import (
|
||||
RuntimeError as C7RuntimeError,
|
||||
)
|
||||
from gps_denied_onboard.components.c7_inference.config import KNOWN_RUNTIMES
|
||||
from gps_denied_onboard.config.schema import Config, ConfigError
|
||||
from gps_denied_onboard.runtime_root.errors import RuntimeNotAvailableError
|
||||
@@ -44,7 +46,6 @@ from gps_denied_onboard.runtime_root.inference_factory import (
|
||||
build_inference_runtime,
|
||||
)
|
||||
|
||||
|
||||
_CONTRACT_PATH = (
|
||||
Path(__file__).resolve().parents[3]
|
||||
/ "_docs/02_document/contracts/c7_inference/inference_runtime_protocol.md"
|
||||
@@ -296,10 +297,21 @@ def test_ac5_build_inference_runtime_flag_off_no_import(
|
||||
assert module_name not in sys.modules
|
||||
|
||||
|
||||
@pytest.mark.parametrize("runtime", sorted(_STRATEGY_MODULES))
|
||||
@pytest.mark.parametrize(
|
||||
"runtime",
|
||||
sorted(rt for rt in _STRATEGY_MODULES if rt != "pytorch_fp16"),
|
||||
)
|
||||
def test_ac5_build_inference_runtime_flag_on_but_module_missing(
|
||||
monkeypatch, strategy_module_cleanup, runtime
|
||||
) -> None:
|
||||
"""``BUILD_*=ON`` but the strategy module hasn't been written yet.
|
||||
|
||||
``pytorch_fp16`` is excluded because AZ-300 shipped its concrete
|
||||
module — the corresponding case is covered by
|
||||
``test_pytorch_fp16_runtime.test_ac1_protocol_conformance`` which
|
||||
constructs the real strategy. The TRT / ORT runtimes (AZ-298 /
|
||||
AZ-299) remain pending; this test still guards their factory path.
|
||||
"""
|
||||
_, _, flag = _STRATEGY_MODULES[runtime]
|
||||
monkeypatch.setenv(flag, "ON")
|
||||
config = _config_with_runtime(runtime)
|
||||
|
||||
Reference in New Issue
Block a user