fix(perception): reject material ties and trace gpu pacing
This commit is contained in:
@@ -135,10 +135,16 @@ def test_triton_statistics_exclude_warmup_and_reject_counter_reset(pilot):
|
||||
def test_ddrnet_triton_transport_is_bounded_and_validates_output_identity(pilot):
|
||||
module = pilot("pilot_ddrnet_triton")
|
||||
mask = np.zeros((512, 512), np.uint8)
|
||||
descriptor = {"outputs": [{
|
||||
"name": "mask", "datatype": "UINT8", "shape": [1, 512, 512],
|
||||
"parameters": {"binary_data_size": mask.nbytes},
|
||||
}]}
|
||||
descriptor = {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "mask",
|
||||
"datatype": "UINT8",
|
||||
"shape": [1, 512, 512],
|
||||
"parameters": {"binary_data_size": mask.nbytes},
|
||||
}
|
||||
]
|
||||
}
|
||||
header = json.dumps(descriptor).encode()
|
||||
|
||||
class Response:
|
||||
@@ -214,6 +220,61 @@ def test_nvml_sampler_reuses_one_session_without_spawning_processes(pilot):
|
||||
assert library.nvmlDeviceGetUtilizationRates.calls == 2
|
||||
|
||||
|
||||
def test_material_vote_tie_never_allows_by_class_order(pilot):
|
||||
choose = pilot("pilot_graph").select_material
|
||||
# unknown=0, hard_surface=1, bare_soil=2, grass=3
|
||||
votes = np.array(
|
||||
[[0, 0, 0, 2], [0, 1, 0, 1], [0, 2, 0, 1], [0, 0, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2]]
|
||||
)
|
||||
np.testing.assert_array_equal(choose(votes), [3, 0, 1, 0, 0, 0])
|
||||
with pytest.raises(ValueError, match="invalid material"):
|
||||
choose(np.array([[0, -1, 0]]))
|
||||
|
||||
|
||||
def test_numeric_diagnostic_counts_transitions_and_score_ties(pilot):
|
||||
module = pilot("diagnose_ddrnet_numeric")
|
||||
reference, candidate = np.array([[3, 3], [1, 0]]), np.array([[1, 3], [0, 0]])
|
||||
assert module.compare_masks(reference, reference)["different_pixels"] == 0
|
||||
assert module.compare_masks(reference, candidate) == {
|
||||
"different_pixels": 2,
|
||||
"transitions": [
|
||||
{"reference": 1, "candidate": 0, "pixels": 1},
|
||||
{"reference": 3, "candidate": 1, "pixels": 1},
|
||||
],
|
||||
}
|
||||
logits = np.array([[[[100.0]], [[101.0]]]], dtype=np.float32)
|
||||
details = module.score_details(logits, np.ones_like(logits), np.array([[0]]), [(0, 0)])
|
||||
assert details[0]["selected"] == 0 and details[0]["logit_margin"] == 1
|
||||
assert details[0]["max_score_ties"] == [0, 1]
|
||||
|
||||
|
||||
def test_optional_nvml_device_state_distinguishes_unavailable_from_zero(pilot):
|
||||
class Function:
|
||||
def __init__(self, code, value):
|
||||
self.code, self.value = code, value
|
||||
|
||||
def __call__(self, *args):
|
||||
args[-1]._obj.value = self.value
|
||||
return self.code
|
||||
|
||||
module = pilot("pilot_telemetry")
|
||||
sampler = object.__new__(module.NvmlSampler)
|
||||
sampler.closed, sampler.handle = False, None
|
||||
sampler.library = SimpleNamespace(
|
||||
nvmlDeviceGetClockInfo=Function(0, 2685),
|
||||
nvmlDeviceGetPerformanceState=Function(0, 0),
|
||||
nvmlDeviceGetPowerUsage=Function(3, 0),
|
||||
)
|
||||
state = sampler.sample_device_state()
|
||||
assert state["sm_clock_mhz"] == 2685 and state["pstate"] == 0
|
||||
assert state["power_mw"] is None and state["device_state_errors"] == {"power_mw": 3}
|
||||
del sampler.library.nvmlDeviceGetClockInfo
|
||||
assert sampler.sample_device_state()["sm_clock_mhz"] is None
|
||||
sampler.closed = True
|
||||
with pytest.raises(RuntimeError, match="closed"):
|
||||
sampler.sample_device_state()
|
||||
|
||||
|
||||
def test_body_history_is_bounded_and_never_reads_future(pilot):
|
||||
store = pilot("pilot_graph").CurrentStore(None)
|
||||
for index in range(100):
|
||||
|
||||
Reference in New Issue
Block a user