computefence 0.3.4__tar.gz → 0.3.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {computefence-0.3.4 → computefence-0.3.4.1}/PKG-INFO +1 -1
  2. computefence-0.3.4.1/computefence/__init__.py +1 -0
  3. computefence-0.3.4.1/computefence/checks/environment.py +313 -0
  4. {computefence-0.3.4 → computefence-0.3.4.1}/computefence.egg-info/PKG-INFO +1 -1
  5. computefence-0.3.4/computefence/__init__.py +0 -1
  6. computefence-0.3.4/computefence/checks/environment.py +0 -147
  7. {computefence-0.3.4 → computefence-0.3.4.1}/LICENSE +0 -0
  8. {computefence-0.3.4 → computefence-0.3.4.1}/README.md +0 -0
  9. {computefence-0.3.4 → computefence-0.3.4.1}/computefence/checks/__init__.py +0 -0
  10. {computefence-0.3.4 → computefence-0.3.4.1}/computefence/checks/dataset.py +0 -0
  11. {computefence-0.3.4 → computefence-0.3.4.1}/computefence/checks/storage.py +0 -0
  12. {computefence-0.3.4 → computefence-0.3.4.1}/computefence/cli.py +0 -0
  13. {computefence-0.3.4 → computefence-0.3.4.1}/computefence/drift.py +0 -0
  14. {computefence-0.3.4 → computefence-0.3.4.1}/computefence/telemetry.py +0 -0
  15. {computefence-0.3.4 → computefence-0.3.4.1}/computefence.egg-info/SOURCES.txt +0 -0
  16. {computefence-0.3.4 → computefence-0.3.4.1}/computefence.egg-info/dependency_links.txt +0 -0
  17. {computefence-0.3.4 → computefence-0.3.4.1}/computefence.egg-info/entry_points.txt +0 -0
  18. {computefence-0.3.4 → computefence-0.3.4.1}/computefence.egg-info/requires.txt +0 -0
  19. {computefence-0.3.4 → computefence-0.3.4.1}/computefence.egg-info/top_level.txt +0 -0
  20. {computefence-0.3.4 → computefence-0.3.4.1}/pyproject.toml +0 -0
  21. {computefence-0.3.4 → computefence-0.3.4.1}/setup.cfg +0 -0
  22. {computefence-0.3.4 → computefence-0.3.4.1}/tests/test_arch_compat.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computefence
3
- Version: 0.3.4
3
+ Version: 0.3.4.1
4
4
  Summary: Don't lose another RunPod checkpoint to ephemeral disk before your job bills.
5
5
  License-Expression: MIT
6
6
  Keywords: runpod,vast.ai,gpu training,hf_home,cuda,preflight,machine learning,mlops,checkpoint
@@ -0,0 +1 @@
1
+ __version__ = "0.3.4.1"
@@ -0,0 +1,313 @@
1
+ import os
2
+ import platform
3
+ import sys
4
+ from pathlib import Path
5
+
6
+
7
+ def describe_interpreter():
8
+ return {
9
+ "version": platform.python_version(),
10
+ "executable": sys.executable,
11
+ "prefix": sys.prefix,
12
+ "virtual_env": os.environ.get("VIRTUAL_ENV"),
13
+ }
14
+
15
+
16
+ def in_active_virtualenv(interpreter):
17
+ virtual_env = interpreter["virtual_env"]
18
+ if not virtual_env:
19
+ return None
20
+ try:
21
+ return Path(interpreter["prefix"]).resolve() == Path(virtual_env).resolve()
22
+ except OSError:
23
+ return interpreter["prefix"] == virtual_env
24
+
25
+
26
+ def detect_torch():
27
+ result = {
28
+ "available": False,
29
+ "version": None,
30
+ "location": None,
31
+ "cuda_available": False,
32
+ "device_count": 0,
33
+ "device_name": None,
34
+ "device_names": [],
35
+ "error": None,
36
+ }
37
+
38
+ try:
39
+ import torch
40
+ except ImportError:
41
+ return result
42
+ except Exception as exc:
43
+ result["error"] = exc
44
+ return result
45
+
46
+ result["available"] = True
47
+ result["version"] = getattr(torch, "__version__", "unknown")
48
+ result["location"] = getattr(torch, "__file__", None)
49
+
50
+ try:
51
+ result["cuda_available"] = torch.cuda.is_available()
52
+ except Exception as exc:
53
+ result["error"] = exc
54
+ return result
55
+
56
+ if result["cuda_available"]:
57
+ result["device_count"] = torch.cuda.device_count()
58
+ result["device_names"] = [
59
+ torch.cuda.get_device_name(i) for i in range(result["device_count"])
60
+ ]
61
+ if result["device_names"]:
62
+ result["device_name"] = result["device_names"][0]
63
+
64
+ return result
65
+
66
+
67
+ def check_gpu_arch_compat(torch_info):
68
+ """Check that each visible GPU's compute capability is supported by this PyTorch build."""
69
+ results = []
70
+ try:
71
+ import torch
72
+ if not torch_info["cuda_available"]:
73
+ return results
74
+
75
+ try:
76
+ arch_list = torch.cuda.get_arch_list()
77
+ except Exception:
78
+ return results
79
+
80
+ if not arch_list:
81
+ return results
82
+
83
+ # Parse arch_list into a set of (major, minor) tuples for membership checks.
84
+ # sm_90a and similar suffixed entries are skipped — they represent PTX variants,
85
+ # not distinct compute capabilities.
86
+ supported_caps = set()
87
+ for arch in arch_list:
88
+ if arch.startswith("sm_") and len(arch) > 3:
89
+ digits = arch[3:]
90
+ if len(digits) >= 2 and digits.isdigit():
91
+ try:
92
+ major = int(digits[:-1])
93
+ minor = int(digits[-1])
94
+ supported_caps.add((major, minor))
95
+ except ValueError:
96
+ pass
97
+
98
+ if not supported_caps:
99
+ return results
100
+
101
+ # Build the human-readable list from the original strings (not the parsed set)
102
+ # so the error message matches exactly what PyTorch reports.
103
+ supported_str = ", ".join(
104
+ arch for arch in arch_list if arch.startswith("sm_")
105
+ )
106
+
107
+ for i in range(torch_info["device_count"]):
108
+ name = torch_info["device_names"][i] if i < len(torch_info["device_names"]) else f"GPU {i}"
109
+ try:
110
+ cap = torch.cuda.get_device_capability(i)
111
+ except Exception:
112
+ continue
113
+
114
+ # Membership check: the GPU is compatible if and only if its exact
115
+ # compute capability appears in get_arch_list(). No ceiling comparison —
116
+ # the old ceiling logic incorrectly blocked Ada (sm_89) on cu124 builds
117
+ # whose list ends at sm_90.
118
+ compatible = cap in supported_caps
119
+
120
+ if not compatible:
121
+ results.append({
122
+ "id": f"gpu_arch_compat_{i}",
123
+ "status": "fail",
124
+ "message": (
125
+ f"{name} has compute capability sm_{cap[0]}{cap[1]}, "
126
+ f"which is not supported by this PyTorch build "
127
+ f"(supported by this build: {supported_str})"
128
+ ),
129
+ "fix": (
130
+ f"Install a PyTorch build that supports sm_{cap[0]}{cap[1]}: "
131
+ f"see https://pytorch.org/get-started/locally/"
132
+ ),
133
+ })
134
+ else:
135
+ results.append({
136
+ "id": f"gpu_arch_compat_{i}",
137
+ "status": "pass",
138
+ "message": (
139
+ f"{name} compute capability sm_{cap[0]}{cap[1]} "
140
+ f"is supported by this PyTorch build"
141
+ ),
142
+ })
143
+
144
+ except Exception:
145
+ pass
146
+
147
+ return results
148
+
149
+
150
+ def check_environment():
151
+ results = []
152
+
153
+ interpreter = describe_interpreter()
154
+ torch_info = detect_torch()
155
+
156
+ results.append({
157
+ "id": "python_version",
158
+ "status": "pass",
159
+ "message": f"Python {interpreter['version']} ({interpreter['executable']})"
160
+ })
161
+
162
+ if in_active_virtualenv(interpreter) is False:
163
+ results.append({
164
+ "id": "virtualenv_mismatch",
165
+ "status": "warn",
166
+ "message": (
167
+ f"computefence is not running inside the active virtual environment "
168
+ f"({interpreter['virtual_env']}) — package checks below reflect "
169
+ f"{interpreter['prefix']}, not your venv"
170
+ ),
171
+ "fix": "Install computefence into the active venv: pip install computefence"
172
+ })
173
+
174
+ if not torch_info["available"]:
175
+ if torch_info["error"] is not None:
176
+ results.append({
177
+ "id": "torch_import",
178
+ "status": "fail",
179
+ "message": f"PyTorch is installed but failed to import: {torch_info['error']}",
180
+ "fix": "Check your PyTorch build matches the installed CUDA driver"
181
+ })
182
+ else:
183
+ results.append({
184
+ "id": "torch_missing",
185
+ "status": "warn",
186
+ "message": f"PyTorch not found in {interpreter['executable']} — skipping GPU checks",
187
+ "fix": "pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"
188
+ })
189
+ return results
190
+
191
+ if torch_info["cuda_available"]:
192
+ results.append({
193
+ "id": "torch_cuda",
194
+ "status": "pass",
195
+ "message": (
196
+ f"PyTorch {torch_info['version']} detected "
197
+ f"(CUDA available — architecture checked below)"
198
+ )
199
+ })
200
+ else:
201
+ results.append({
202
+ "id": "torch_cuda",
203
+ "status": "pass",
204
+ "message": f"PyTorch {torch_info['version']} detected"
205
+ })
206
+
207
+ if torch_info["error"] is not None:
208
+ results.append({
209
+ "id": "cuda_query",
210
+ "status": "fail",
211
+ "message": f"Could not query CUDA: {torch_info['error']}",
212
+ "fix": "Check your CUDA installation and PyTorch version match"
213
+ })
214
+ return results
215
+
216
+ if not torch_info["cuda_available"]:
217
+ results.append({
218
+ "id": "cuda_visibility",
219
+ "status": "fail",
220
+ "message": "CUDA not available — PyTorch cannot see any GPUs",
221
+ "fix": "Check your CUDA installation and PyTorch version match"
222
+ })
223
+ else:
224
+ results.extend(check_gpu_arch_compat(torch_info))
225
+
226
+ results.extend(check_accelerate(torch_info=torch_info))
227
+
228
+ return results
229
+
230
+
231
+ def check_accelerate(config_path=None, torch_info=None):
232
+ results = []
233
+
234
+ if torch_info is None:
235
+ torch_info = detect_torch()
236
+
237
+ if not torch_info["available"]:
238
+ return results
239
+
240
+ if config_path:
241
+ config_file = Path(config_path)
242
+ else:
243
+ candidates = [
244
+ Path.home() / ".cache" / "huggingface" / "accelerate" / "default_config.yaml",
245
+ Path.home() / ".config" / "huggingface" / "accelerate" / "default_config.yaml",
246
+ ]
247
+ hf_home = os.environ.get("HF_HOME")
248
+ if hf_home:
249
+ candidates.insert(0, Path(hf_home) / "accelerate" / "default_config.yaml")
250
+
251
+ config_file = None
252
+ for candidate in candidates:
253
+ if candidate.exists():
254
+ config_file = candidate
255
+ break
256
+
257
+ if config_file is None or not Path(config_file).exists():
258
+ results.append({
259
+ "id": "accelerate_config",
260
+ "status": "warn",
261
+ "message": "No Accelerate config found — skipping GPU count check",
262
+ "fix": "Run 'accelerate config' to create a configuration file"
263
+ })
264
+ return results
265
+
266
+ try:
267
+ import yaml
268
+ with open(config_file) as f:
269
+ config = yaml.safe_load(f)
270
+
271
+ num_processes = config.get("num_processes", None)
272
+
273
+ if num_processes is None:
274
+ results.append({
275
+ "id": "accelerate_num_processes",
276
+ "status": "warn",
277
+ "message": "Could not read num_processes from Accelerate config",
278
+ "fix": "Check your Accelerate config file is valid"
279
+ })
280
+ return results
281
+
282
+ visible_gpus = torch_info["device_count"]
283
+
284
+ if num_processes > visible_gpus:
285
+ results.append({
286
+ "id": "accelerate_gpu_count",
287
+ "status": "fail",
288
+ "message": f"Accelerate config requests {num_processes} processes but only {visible_gpus} GPU(s) are visible",
289
+ "fix": "Run accelerate config to update your GPU count then re-run doctor"
290
+ })
291
+ else:
292
+ results.append({
293
+ "id": "accelerate_gpu_count",
294
+ "status": "pass",
295
+ "message": f"Accelerate config requests {num_processes} process(es) — {visible_gpus} GPU(s) available"
296
+ })
297
+
298
+ except ImportError:
299
+ results.append({
300
+ "id": "accelerate_pyyaml",
301
+ "status": "warn",
302
+ "message": "PyYAML not installed — cannot parse Accelerate config",
303
+ "fix": "pip install pyyaml"
304
+ })
305
+ except Exception as e:
306
+ results.append({
307
+ "id": "accelerate_parse",
308
+ "status": "warn",
309
+ "message": f"Could not parse Accelerate config: {e}",
310
+ "fix": "Check your Accelerate config file is valid YAML"
311
+ })
312
+
313
+ return results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computefence
3
- Version: 0.3.4
3
+ Version: 0.3.4.1
4
4
  Summary: Don't lose another RunPod checkpoint to ephemeral disk before your job bills.
5
5
  License-Expression: MIT
6
6
  Keywords: runpod,vast.ai,gpu training,hf_home,cuda,preflight,machine learning,mlops,checkpoint
@@ -1 +0,0 @@
1
- __version__ = "0.3.4"
@@ -1,147 +0,0 @@
1
- import os
2
- import platform
3
- import sys
4
- from pathlib import Path
5
-
6
-
7
- def describe_interpreter():
8
- return {
9
- "version": platform.python_version(),
10
- "executable": sys.executable,
11
- "prefix": sys.prefix,
12
- "virtual_env": os.environ.get("VIRTUAL_ENV"),
13
- }
14
-
15
-
16
- def in_active_virtualenv(interpreter):
17
- virtual_env = interpreter["virtual_env"]
18
- if not virtual_env:
19
- return None
20
- try:
21
- return Path(interpreter["prefix"]).resolve() == Path(virtual_env).resolve()
22
- except OSError:
23
- return interpreter["prefix"] == virtual_env
24
-
25
-
26
- def detect_torch():
27
- result = {
28
- "available": False,
29
- "version": None,
30
- "location": None,
31
- "cuda_available": False,
32
- "device_count": 0,
33
- "device_name": None,
34
- "device_names": [],
35
- "error": None,
36
- }
37
-
38
- try:
39
- import torch
40
- except ImportError:
41
- return result
42
- except Exception as exc:
43
- result["error"] = exc
44
- return result
45
-
46
- result["available"] = True
47
- result["version"] = getattr(torch, "__version__", "unknown")
48
- result["location"] = getattr(torch, "__file__", None)
49
-
50
- try:
51
- result["cuda_available"] = torch.cuda.is_available()
52
- except Exception as exc:
53
- result["error"] = exc
54
- return result
55
-
56
- if result["cuda_available"]:
57
- result["device_count"] = torch.cuda.device_count()
58
- result["device_names"] = [
59
- torch.cuda.get_device_name(i) for i in range(result["device_count"])
60
- ]
61
- if result["device_names"]:
62
- result["device_name"] = result["device_names"][0]
63
-
64
- return result
65
-
66
-
67
- def check_gpu_arch_compat(torch_info):
68
- """Check that each visible GPU's compute capability is supported by this PyTorch build."""
69
- results = []
70
- try:
71
- import torch
72
- if not torch_info["cuda_available"]:
73
- return results
74
-
75
- try:
76
- arch_list = torch.cuda.get_arch_list()
77
- except Exception:
78
- return results
79
-
80
- if not arch_list:
81
- return results
82
-
83
- # Parse arch_list into a set of (major, minor) tuples for membership checks.
84
- # sm_90a and similar suffixed entries are skipped — they represent PTX variants,
85
- # not distinct compute capabilities.
86
- supported_caps = set()
87
- for arch in arch_list:
88
- if arch.startswith("sm_") and len(arch) > 3:
89
- digits = arch[3:]
90
- if len(digits) >= 2 and digits.isdigit():
91
- try:
92
- major = int(digits[:-1])
93
- minor = int(digits[-1])
94
- supported_caps.add((major, minor))
95
- except ValueError:
96
- pass
97
-
98
- if not supported_caps:
99
- return results
100
-
101
- # Build the human-readable list from the original strings (not the parsed set)
102
- # so the error message matches exactly what PyTorch reports.
103
- supported_str = ", ".join(
104
- arch for arch in arch_list if arch.startswith("sm_")
105
- )
106
-
107
- for i in range(torch_info["device_count"]):
108
- name = torch_info["device_names"][i] if i < len(torch_info["device_names"]) else f"GPU {i}"
109
- try:
110
- cap = torch.cuda.get_device_capability(i)
111
- except Exception:
112
- continue
113
-
114
- # Membership check: the GPU is compatible if and only if its exact
115
- # compute capability appears in get_arch_list(). No ceiling comparison —
116
- # the old ceiling logic incorrectly blocked Ada (sm_89) on cu124 builds
117
- # whose list ends at sm_90.
118
- compatible = cap in supported_caps
119
-
120
- if not compatible:
121
- results.append({
122
- "id": f"gpu_arch_compat_{i}",
123
- "status": "fail",
124
- "message": (
125
- f"{name} has compute capability sm_{cap[0]}{cap[1]}, "
126
- f"which is not supported by this PyTorch build "
127
- f"(supported by this build: {supported_str})"
128
- ),
129
- "fix": (
130
- f"Install a PyTorch build that supports sm_{cap[0]}{cap[1]}: "
131
- f"see https://pytorch.org/get-started/locally/"
132
- ),
133
- })
134
- else:
135
- results.append({
136
- "id": f"gpu_arch_compat_{i}",
137
- "status": "pass",
138
- "message": (
139
- f"{name} compute capability sm_{cap[0]}{cap[1]} "
140
- f"is supported by this PyTorch build"
141
- ),
142
- })
143
-
144
- except Exception:
145
- pass
146
-
147
- return results
File without changes
File without changes
File without changes