Skip to content

Commit 9645d2e

Browse files
Tremayne Timmsclaude
andcommitted
style: ruff format entire codebase
35 files were never formatted with ruff. Applying consistent formatting to pass the new ruff format --check CI step. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61224ae commit 9645d2e

35 files changed

Lines changed: 890 additions & 929 deletions

src/diagnostics/clock_throttle.py

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -75,48 +75,41 @@ def _get_throttle_reasons(gpu_index: int) -> dict:
7575

7676
# Get current throttle reasons
7777
try:
78-
throttle_reasons = (
79-
pynvml.nvmlDeviceGetCurrentClocksThrottleReasons(
80-
handle
81-
)
82-
)
78+
throttle_reasons = pynvml.nvmlDeviceGetCurrentClocksThrottleReasons(handle)
8379
except (pynvml.NVMLError, AttributeError):
8480
throttle_reasons = 0
8581

8682
# Get supported throttle reasons
8783
try:
88-
supported = (
89-
pynvml.nvmlDeviceGetSupportedClocksThrottleReasons(
90-
handle
91-
)
92-
)
84+
supported = pynvml.nvmlDeviceGetSupportedClocksThrottleReasons(handle)
9385
except (pynvml.NVMLError, AttributeError):
9486
supported = 0xFFFFFFFF
9587

9688
# Get current clocks for context
9789
try:
9890
graphics_clock = pynvml.nvmlDeviceGetClockInfo(
99-
handle, 0 # NVML_CLOCK_GRAPHICS
91+
handle,
92+
0, # NVML_CLOCK_GRAPHICS
10093
)
10194
except pynvml.NVMLError:
10295
graphics_clock = 0
10396

10497
try:
105-
max_graphics = pynvml.nvmlDeviceGetMaxClockInfo(
106-
handle, 0
107-
)
98+
max_graphics = pynvml.nvmlDeviceGetMaxClockInfo(handle, 0)
10899
except pynvml.NVMLError:
109100
max_graphics = 0
110101

111102
# Parse active throttle reasons
112103
active_reasons = []
113104
for bit, name in THROTTLE_REASONS.items():
114105
if throttle_reasons & bit:
115-
active_reasons.append({
116-
"bit": hex(bit),
117-
"reason": name,
118-
"is_problem": bit in PROBLEM_THROTTLE_BITS,
119-
})
106+
active_reasons.append(
107+
{
108+
"bit": hex(bit),
109+
"reason": name,
110+
"is_problem": bit in PROBLEM_THROTTLE_BITS,
111+
}
112+
)
120113

121114
return {
122115
"throttle_bitmask": hex(throttle_reasons),
@@ -125,11 +118,7 @@ def _get_throttle_reasons(gpu_index: int) -> dict:
125118
"graphics_clock_mhz": graphics_clock,
126119
"max_graphics_clock_mhz": max_graphics,
127120
"clock_reduction_pct": (
128-
round(
129-
(1 - graphics_clock / max_graphics) * 100, 1
130-
)
131-
if max_graphics > 0
132-
else 0
121+
round((1 - graphics_clock / max_graphics) * 100, 1) if max_graphics > 0 else 0
133122
),
134123
}
135124
finally:
@@ -152,20 +141,17 @@ def _check_clock_throttling(
152141
test_name="telemetry.clock_throttle",
153142
status=TestStatus.SKIP,
154143
duration_seconds=time.time() - start,
155-
message=(
156-
f"Could not query throttle reasons: "
157-
f"{throttle_data['error']}"
158-
),
144+
message=(f"Could not query throttle reasons: {throttle_data['error']}"),
159145
gpu_uuid=gpu.uuid,
160146
details=throttle_data,
161147
)
162148

163149
active = throttle_data.get("active_reasons", [])
164150
problem_reasons = [r for r in active if r.get("is_problem")]
165151
unexpected_reasons = [
166-
r for r in active
167-
if not r.get("is_problem")
168-
and int(r["bit"], 16) not in NORMAL_THROTTLE_BITS
152+
r
153+
for r in active
154+
if not r.get("is_problem") and int(r["bit"], 16) not in NORMAL_THROTTLE_BITS
169155
]
170156

171157
details = {
@@ -182,10 +168,7 @@ def _check_clock_throttling(
182168
test_name="telemetry.clock_throttle",
183169
status=TestStatus.FAIL,
184170
duration_seconds=time.time() - start,
185-
message=(
186-
f"GPU throttled: {', '.join(reason_names)} "
187-
f"(clock reduced {reduction}%)"
188-
),
171+
message=(f"GPU throttled: {', '.join(reason_names)} (clock reduced {reduction}%)"),
189172
failure_code="DIAG-910",
190173
gpu_uuid=gpu.uuid,
191174
details=details,
@@ -197,10 +180,7 @@ def _check_clock_throttling(
197180
test_name="telemetry.clock_throttle",
198181
status=TestStatus.WARN,
199182
duration_seconds=time.time() - start,
200-
message=(
201-
f"Unexpected clock limiting active: "
202-
f"{', '.join(reason_names)}"
203-
),
183+
message=(f"Unexpected clock limiting active: {', '.join(reason_names)}"),
204184
gpu_uuid=gpu.uuid,
205185
details=details,
206186
)
@@ -220,6 +200,4 @@ def run_clock_throttle_checks(
220200
profile: dict[str, Any],
221201
) -> list[TestResult]:
222202
"""Execute clock throttle analysis on all GPUs."""
223-
return [
224-
_check_clock_throttling(gpu, profile) for gpu in gpu_infos
225-
]
203+
return [_check_clock_throttling(gpu, profile) for gpu in gpu_infos]

src/diagnostics/compute_stress.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ def _run_compute_stress(
9696
temp = _pynvml.nvmlDeviceGetTemperature(
9797
handle, _pynvml.NVML_TEMPERATURE_GPU
9898
)
99-
temp_samples.append({
100-
"time_s": round(now - stress_start, 1),
101-
"temp_c": temp,
102-
})
99+
temp_samples.append(
100+
{
101+
"time_s": round(now - stress_start, 1),
102+
"temp_c": temp,
103+
}
104+
)
103105
_pynvml.nvmlShutdown()
104106
except Exception:
105107
pass
@@ -134,7 +136,7 @@ def _run_compute_stress(
134136
status=TestStatus.FAIL,
135137
duration_seconds=time.time() - start,
136138
message=f"Compute stress failed with {len(errors)} error(s) "
137-
f"after {iteration_count} iterations",
139+
f"after {iteration_count} iterations",
138140
failure_code="DIAG-600",
139141
gpu_uuid=gpu.uuid,
140142
details=details,
@@ -146,7 +148,7 @@ def _run_compute_stress(
146148
status=TestStatus.WARN,
147149
duration_seconds=time.time() - start,
148150
message=f"Stress test ended early: {stress_duration:.1f}s "
149-
f"of {duration_seconds}s target",
151+
f"of {duration_seconds}s target",
150152
gpu_uuid=gpu.uuid,
151153
details=details,
152154
)
@@ -156,7 +158,7 @@ def _run_compute_stress(
156158
status=TestStatus.PASS,
157159
duration_seconds=time.time() - start,
158160
message=f"Compute stress OK: {iteration_count} GEMM ops, "
159-
f"{gflops:.0f} GFLOPS over {stress_duration:.1f}s",
161+
f"{gflops:.0f} GFLOPS over {stress_duration:.1f}s",
160162
gpu_uuid=gpu.uuid,
161163
details=details,
162164
)

src/diagnostics/deployment.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,13 @@ def _check_ecc_mode(gpu_infos: list[GPUInfo], profile: dict[str, Any]) -> TestRe
123123
results = []
124124
for gpu in gpu_infos:
125125
if not ecc_supported:
126-
results.append(
127-
{"index": gpu.index, "ecc_mode": gpu.ecc_mode, "status": "SKIP"}
128-
)
126+
results.append({"index": gpu.index, "ecc_mode": gpu.ecc_mode, "status": "SKIP"})
129127
elif ecc_expected is not None:
130128
expected_str = "enabled" if ecc_expected else "disabled"
131129
if gpu.ecc_mode == expected_str:
132-
results.append(
133-
{"index": gpu.index, "ecc_mode": gpu.ecc_mode, "status": "PASS"}
134-
)
130+
results.append({"index": gpu.index, "ecc_mode": gpu.ecc_mode, "status": "PASS"})
135131
else:
136-
results.append(
137-
{"index": gpu.index, "ecc_mode": gpu.ecc_mode, "status": "FAIL"}
138-
)
132+
results.append({"index": gpu.index, "ecc_mode": gpu.ecc_mode, "status": "FAIL"})
139133

140134
if not ecc_supported:
141135
return TestResult(
@@ -177,8 +171,7 @@ def _check_gpu_processes(gpu_infos: list[GPUInfo]) -> TestResult:
177171
try:
178172
procs = pynvml.nvmlDeviceGetComputeRunningProcesses(handle)
179173
heavy = [
180-
p for p in procs
181-
if (p.usedGpuMemory or 0) > COMPUTE_VRAM_THRESHOLD_MB * 1024 * 1024
174+
p for p in procs if (p.usedGpuMemory or 0) > COMPUTE_VRAM_THRESHOLD_MB * 1024 * 1024
182175
]
183176
if heavy:
184177
busy_gpus.append(

src/diagnostics/ecc_health.py

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,19 @@ def _query_ecc_counters(gpu_index: int) -> dict:
3030
vol_sbe = 0
3131
vol_dbe = 0
3232
try:
33-
vol_sbe = (
34-
pynvml.nvmlDeviceGetTotalEccErrors(
35-
handle,
36-
pynvml.NVML_SINGLE_BIT_ECC,
37-
pynvml.NVML_VOLATILE_ECC,
38-
)
33+
vol_sbe = pynvml.nvmlDeviceGetTotalEccErrors(
34+
handle,
35+
pynvml.NVML_SINGLE_BIT_ECC,
36+
pynvml.NVML_VOLATILE_ECC,
3937
)
4038
except (pynvml.NVMLError, AttributeError):
4139
vol_sbe = -1 # Not supported
4240

4341
try:
44-
vol_dbe = (
45-
pynvml.nvmlDeviceGetTotalEccErrors(
46-
handle,
47-
pynvml.NVML_DOUBLE_BIT_ECC,
48-
pynvml.NVML_VOLATILE_ECC,
49-
)
42+
vol_dbe = pynvml.nvmlDeviceGetTotalEccErrors(
43+
handle,
44+
pynvml.NVML_DOUBLE_BIT_ECC,
45+
pynvml.NVML_VOLATILE_ECC,
5046
)
5147
except (pynvml.NVMLError, AttributeError):
5248
vol_dbe = -1
@@ -55,23 +51,19 @@ def _query_ecc_counters(gpu_index: int) -> dict:
5551
agg_sbe = 0
5652
agg_dbe = 0
5753
try:
58-
agg_sbe = (
59-
pynvml.nvmlDeviceGetTotalEccErrors(
60-
handle,
61-
pynvml.NVML_SINGLE_BIT_ECC,
62-
pynvml.NVML_AGGREGATE_ECC,
63-
)
54+
agg_sbe = pynvml.nvmlDeviceGetTotalEccErrors(
55+
handle,
56+
pynvml.NVML_SINGLE_BIT_ECC,
57+
pynvml.NVML_AGGREGATE_ECC,
6458
)
6559
except (pynvml.NVMLError, AttributeError):
6660
agg_sbe = -1
6761

6862
try:
69-
agg_dbe = (
70-
pynvml.nvmlDeviceGetTotalEccErrors(
71-
handle,
72-
pynvml.NVML_DOUBLE_BIT_ECC,
73-
pynvml.NVML_AGGREGATE_ECC,
74-
)
63+
agg_dbe = pynvml.nvmlDeviceGetTotalEccErrors(
64+
handle,
65+
pynvml.NVML_DOUBLE_BIT_ECC,
66+
pynvml.NVML_AGGREGATE_ECC,
7567
)
7668
except (pynvml.NVMLError, AttributeError):
7769
agg_dbe = -1
@@ -80,23 +72,19 @@ def _query_ecc_counters(gpu_index: int) -> dict:
8072
retired_sbe = 0
8173
retired_dbe = 0
8274
try:
83-
retired_sbe = (
84-
pynvml.nvmlDeviceGetRetiredPages(
85-
handle,
86-
pynvml.NVML_PAGE_RETIREMENT_CAUSE_MULTIPLE_SINGLE_BIT_ECC_ERRORS,
87-
)
75+
retired_sbe = pynvml.nvmlDeviceGetRetiredPages(
76+
handle,
77+
pynvml.NVML_PAGE_RETIREMENT_CAUSE_MULTIPLE_SINGLE_BIT_ECC_ERRORS,
8878
)
8979
if isinstance(retired_sbe, (list, tuple)):
9080
retired_sbe = len(retired_sbe)
9181
except (pynvml.NVMLError, AttributeError):
9282
retired_sbe = -1
9383

9484
try:
95-
retired_dbe = (
96-
pynvml.nvmlDeviceGetRetiredPages(
97-
handle,
98-
pynvml.NVML_PAGE_RETIREMENT_CAUSE_DOUBLE_BIT_ECC_ERROR,
99-
)
85+
retired_dbe = pynvml.nvmlDeviceGetRetiredPages(
86+
handle,
87+
pynvml.NVML_PAGE_RETIREMENT_CAUSE_DOUBLE_BIT_ECC_ERROR,
10088
)
10189
if isinstance(retired_dbe, (list, tuple)):
10290
retired_dbe = len(retired_dbe)
@@ -106,9 +94,7 @@ def _query_ecc_counters(gpu_index: int) -> dict:
10694
# Pending retired pages
10795
pending_retirement = False
10896
try:
109-
pending = (
110-
pynvml.nvmlDeviceGetRetiredPages_v2(handle)
111-
)
97+
pending = pynvml.nvmlDeviceGetRetiredPages_v2(handle)
11298
if pending:
11399
pending_retirement = True
114100
except (pynvml.NVMLError, AttributeError):
@@ -118,9 +104,7 @@ def _query_ecc_counters(gpu_index: int) -> dict:
118104
remapped_rows = {}
119105
try:
120106
remapped = pynvml.nvmlDeviceGetRemappedRows(handle)
121-
correctable, uncorrectable, pending_remap, failure = (
122-
remapped
123-
)
107+
correctable, uncorrectable, pending_remap, failure = remapped
124108
remapped_rows = {
125109
"correctable": correctable,
126110
"uncorrectable": uncorrectable,
@@ -168,10 +152,7 @@ def _check_ecc_health(
168152
test_name="telemetry.ecc_health",
169153
status=TestStatus.SKIP,
170154
duration_seconds=time.time() - start,
171-
message=(
172-
"ECC not supported on this GPU "
173-
f"({gpu.name})"
174-
),
155+
message=(f"ECC not supported on this GPU ({gpu.name})"),
175156
gpu_uuid=gpu.uuid,
176157
details={"ecc_mode": gpu.ecc_mode},
177158
)
@@ -183,10 +164,7 @@ def _check_ecc_health(
183164
test_name="telemetry.ecc_health",
184165
status=TestStatus.SKIP,
185166
duration_seconds=time.time() - start,
186-
message=(
187-
f"ECC query failed: "
188-
f"{counters.get('error', 'unknown')}"
189-
),
167+
message=(f"ECC query failed: {counters.get('error', 'unknown')}"),
190168
gpu_uuid=gpu.uuid,
191169
details=counters,
192170
)
@@ -256,9 +234,7 @@ def _check_ecc_health(
256234
test_name="telemetry.ecc_health",
257235
status=TestStatus.WARN,
258236
duration_seconds=time.time() - start,
259-
message=(
260-
"Pages pending retirement — reboot recommended"
261-
),
237+
message=("Pages pending retirement — reboot recommended"),
262238
gpu_uuid=gpu.uuid,
263239
details=details,
264240
)
@@ -282,6 +258,4 @@ def run_ecc_health_checks(
282258
profile: dict[str, Any],
283259
) -> list[TestResult]:
284260
"""Execute ECC health analysis on all GPUs."""
285-
return [
286-
_check_ecc_health(gpu, profile) for gpu in gpu_infos
287-
]
261+
return [_check_ecc_health(gpu, profile) for gpu in gpu_infos]

0 commit comments

Comments
 (0)