Separate usable steering samples from complete native history checks

This commit is contained in:
firestar5683
2026-11-19 21:33:27 -06:00
parent cf4c99e7fa
commit e5ea759719
6 changed files with 38 additions and 5 deletions
+1
View File
@@ -88,6 +88,7 @@ jobs:
--json-output ci-results/flm-offroad.json
.venv/bin/python -m pytest -q --import-mode=importlib \
openpilot/starpilot/flm/tests/test_steering_compatibility.py \
openpilot/starpilot/flm/tests/test_offroad_nonemitted_controls.py \
openpilot/starpilot/flm/tests/test_observed_maneuvers.py \
openpilot/starpilot/flm/tests/test_upstream_producer_transport.py \
openpilot/starpilot/flm/tests/test_clock_resolution_budget.py \
+1 -1
View File
@@ -203,7 +203,7 @@ def _original_input_refusal(rows):
reason = numerical.get('reason')
if not row['qualified'] and (
reason == 'original_hint_requires_exact_unclipped_native_pair'
or reason == 'same_state_controller_checks_only' and type(numerical.get('scored_frames')) is int and numerical['scored_frames'] < 50
or reason == 'same_state_controller_checks_only' and type(numerical.get('scored_frames')) is int and numerical['scored_frames'] <= 0
):
return True
return False
@@ -251,7 +251,8 @@ def check_candidate(cp, controls, values, *, score_start_ns=0, score_end_ns=2**6
maximum = max(maximum, delta)
last_ns, last_sequence = frame.control_ns, frame.frame_sequence
return {
'qualified': bool(scored >= 50 and (changed > 0 or not require_change)),
# Replication is assessed across independent windows; full native history is checked separately.
'qualified': bool(scored > 0 and (changed > 0 or not require_change)),
'reason': 'same_state_controller_checks_only',
'verified_frames': verified,
'scored_frames': scored,
@@ -343,7 +343,7 @@ class TestOffroadSurface(unittest.TestCase):
from opendbc.car.hyundai.values import CAR
from openpilot.starpilot.flm import controller_replay
from openpilot.starpilot.flm.controller_replay import SelectedControllerFactory, capture_snapshot, frame_input, final_command
from openpilot.starpilot.flm.offroad_controller_checks import check_candidate
from openpilot.starpilot.flm.offroad_controller_checks import check_candidate, check_original_native
from openpilot.starpilot.flm.torque_adapter import Objective
from openpilot.starpilot.flm.torque_observation import TorqueObservation
@@ -413,6 +413,25 @@ class TestOffroadSurface(unittest.TestCase):
self.assertEqual(len(result['commands']), len(original))
self.assertTrue(all(before == after for _, before, after in result['commands']))
self.assertFalse(check_candidate(cp, original, values(), require_change=True)['qualified'])
# A few usable commands may be numerically checked, but cannot replace native history or an actual change.
for end_tick, expected_scored in ((4, 1), (24, 17), (59, 48)):
with self.subTest(end_tick=end_tick):
sparse = check_candidate(cp, original, values(), score_end_ns=original[end_tick].control_ns, require_change=False)
self.assertTrue(sparse['qualified'], sparse)
self.assertEqual(sparse['scored_frames'], expected_scored)
self.assertEqual(sparse['changed_frames'], 0)
self.assertEqual(sparse['verified_frames'], len(original))
self.assertFalse(check_candidate(cp, original, values(), score_end_ns=original[end_tick].control_ns)['qualified'])
commands = sparse['commands']
stamps = {stamp for stamp, _, _ in commands}
native_controls = tuple(control for control in original if control.control_ns in stamps)
if len(native_controls) < 50:
with self.assertRaisesRegex(ValueError, 'Complete bounded source controller/native history required'):
check_original_native(cp, native_controls, (), commands, require_change=False)
else:
native = check_original_native(cp, native_controls, (), commands, require_change=False)
self.assertFalse(native['qualified'])
self.assertEqual(native['reason'], 'insufficient_original_native_delivery')
hinted = tuple(replace(row, limited=True) for row in original)
no_delivery = check_candidate(cp, hinted, values(), require_change=False)
self.assertFalse(no_delivery['qualified'])
@@ -146,7 +146,9 @@ def test_native_history_counts_real_emissions_and_preserves_each_hold(native_his
@pytest.mark.parametrize('reason,scored,attempts', (
('original_hint_requires_exact_unclipped_native_pair', None, 1),
('same_state_controller_checks_only', 49, 1),
('same_state_controller_checks_only', 0, 1),
('same_state_controller_checks_only', 1, len(TRAINING_FRACTIONS)),
('same_state_controller_checks_only', 49, len(TRAINING_FRACTIONS)),
('same_state_controller_checks_only', 50, len(TRAINING_FRACTIONS)),
('candidate_dependent_quality_refusal', None, len(TRAINING_FRACTIONS)),
))
@@ -161,3 +163,13 @@ def test_only_original_source_refusal_ends_redundant_strength_search(reason, sco
assert fitted is None and proof['selected_fraction'] is None
assert len(proof['attempts']) == checker.call_count == attempts
assert proof['heldout_windows_not_evaluated'] == ('d', 'e', 'f')
def test_sparse_numerical_credit_never_replaces_real_native_emissions(native_history):
cp, controls, chain, commands = native_history
retained = set(sorted({output.apply_ns for output in chain})[:24])
fewer = tuple(output for output in chain if output.apply_ns in retained)
result = check_original_native(cp, controls, fewer, commands, require_change=False)
assert not result['qualified'] and result['reason'] == 'insufficient_original_native_delivery'
unchanged = check_original_native(cp, controls, chain, commands, require_change=True)
assert not unchanged['qualified'], 'A complete unchanged history cannot earn a changed tune'
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "28fcd3ed89612c4b8cdc262e0df2381ca978c1dbe8792072df2564f9991a05e5", "schema_version": 1}
{"protected_inventory_sha256": "9b542a5eaf10d5a0a5bb94304cd3334a63ad1fcc39e225f6014be4b69c8660eb", "schema_version": 1}