|
9 | 9 | 3. Rewrites the wheel local-version label from ``+cu130`` to ``+cu132`` |
10 | 10 | (METADATA ``Version:`` field, ``.dist-info`` directory name, and the |
11 | 11 | wheel filename). The RECORD file is regenerated by auditwheel. |
12 | | - 4. Uploads each repackaged wheel to: |
| 12 | + 4. Removes the ``_check_cuda_version()`` runtime guard from |
| 13 | + ``torchaudio/_extension/__init__.py`` inside the wheel. torchaudio is |
| 14 | + now built against the PyTorch stable C++ ABI, so the strict CUDA |
| 15 | + version match is no longer required and would otherwise fail when a |
| 16 | + cu132-tagged torchaudio wheel runs alongside a torch built for a |
| 17 | + different CUDA minor version. The function definition in ``utils.py`` |
| 18 | + is preserved so external callers (e.g. the pytorch/builder smoke |
| 19 | + test) keep working. |
| 20 | + 5. Uploads each repackaged wheel to: |
13 | 21 | - AWS S3: s3://pytorch/whl/test/cu132/ |
14 | 22 | - Cloudflare R2: s3://pytorch-downloads/whl/test/cu132/ |
15 | 23 | Each upload sets ``x-amz-meta-checksum-sha256`` on the object so the |
|
56 | 64 | R2_BUCKET_NAME_DEFAULT = "pytorch-downloads" |
57 | 65 | R2_PREFIX = "whl/test/{cuda}" |
58 | 66 |
|
| 67 | +EXTENSION_INIT_PATH = "torchaudio/_extension/__init__.py" |
| 68 | +CHECK_CUDA_CALL_RE = re.compile(r"^[ \t]*_check_cuda_version\(\)[ \t]*\n", re.MULTILINE) |
| 69 | + |
59 | 70 |
|
60 | 71 | def discover_wheels(package: str, version: str, cuda: str) -> List[str]: |
61 | 72 | """Return list of wheel filenames for ``package`` at ``version`` on the |
@@ -177,6 +188,37 @@ def repackage_wheel( |
177 | 188 | os.path.join(ctx.path, new_dist_info_dir), |
178 | 189 | ) |
179 | 190 |
|
| 191 | + # torchaudio is now built against the PyTorch stable C++ ABI, |
| 192 | + # so the runtime _check_cuda_version() guard in |
| 193 | + # torchaudio/_extension/__init__.py is no longer needed and |
| 194 | + # would otherwise fail on cross-CUDA-version installs (e.g. a |
| 195 | + # torchaudio cu132 wheel running against torch built for a |
| 196 | + # different CUDA minor). Strip the call here; the function |
| 197 | + # definition in utils.py is left intact for callers like the |
| 198 | + # builder smoke test. |
| 199 | + init_file = os.path.join(ctx.path, EXTENSION_INIT_PATH) |
| 200 | + if not os.path.exists(init_file): |
| 201 | + raise RuntimeError(f"{EXTENSION_INIT_PATH} not found in {wheel_path}") |
| 202 | + with open(init_file, "r", encoding="utf-8") as f: |
| 203 | + init_src = f.read() |
| 204 | + patched_src, count = CHECK_CUDA_CALL_RE.subn("", init_src) |
| 205 | + if count == 0: |
| 206 | + raise RuntimeError( |
| 207 | + f"No _check_cuda_version() call found in " |
| 208 | + f"{EXTENSION_INIT_PATH} of {wheel_path.name}" |
| 209 | + ) |
| 210 | + if count > 1: |
| 211 | + print( |
| 212 | + f"- WARNING: removed {count} _check_cuda_version() " |
| 213 | + f"calls from {wheel_path.name} (expected 1)" |
| 214 | + ) |
| 215 | + with open(init_file, "w", encoding="utf-8") as f: |
| 216 | + f.write(patched_src) |
| 217 | + print( |
| 218 | + f"+ Removed _check_cuda_version() call from " |
| 219 | + f"{EXTENSION_INIT_PATH} ({wheel_path.name})" |
| 220 | + ) |
| 221 | + |
180 | 222 | new_filename = wheel_path.name.replace(old_label, new_label) |
181 | 223 | out_path = output_dir / new_filename |
182 | 224 | if not tmp_whl.exists(): |
|
0 commit comments