Skip to content

Commit 342e595

Browse files
authored
Merge branch 'main' into cross-rbase-v1
2 parents e612c8d + 91cc9b6 commit 342e595

File tree

4 files changed

+95
-75
lines changed

4 files changed

+95
-75
lines changed

conda-lock.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,39 +2104,39 @@ package:
21042104
- category: main
21052105
dependencies: {}
21062106
hash:
2107-
md5: 949519bf61c21c9db15f19f67a08a5b9
2108-
sha256: 54cbf4a99778316e05a7c646a92681e2694ee104fa637b5f435d4e6a1da818f6
2107+
md5: 0f514fa2a02eacfd60124aee7ad85b92
2108+
sha256: 13b8c2da5e1397e8d7c1c20b423cbe56e8952f832679b0aab896e2def3769a35
21092109
manager: conda
21102110
name: conda-forge-pinning
21112111
optional: false
21122112
platform: linux-64
21132113
url:
2114-
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.23.21.47.32-hd8ed1ab_0.conda
2115-
version: 2025.03.23.21.47.32
2114+
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.25.12.23.56-hd8ed1ab_0.conda
2115+
version: 2025.03.25.12.23.56
21162116
- category: main
21172117
dependencies: {}
21182118
hash:
2119-
md5: 949519bf61c21c9db15f19f67a08a5b9
2120-
sha256: 54cbf4a99778316e05a7c646a92681e2694ee104fa637b5f435d4e6a1da818f6
2119+
md5: 0f514fa2a02eacfd60124aee7ad85b92
2120+
sha256: 13b8c2da5e1397e8d7c1c20b423cbe56e8952f832679b0aab896e2def3769a35
21212121
manager: conda
21222122
name: conda-forge-pinning
21232123
optional: false
21242124
platform: osx-64
21252125
url:
2126-
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.23.21.47.32-hd8ed1ab_0.conda
2127-
version: 2025.03.23.21.47.32
2126+
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.25.12.23.56-hd8ed1ab_0.conda
2127+
version: 2025.03.25.12.23.56
21282128
- category: main
21292129
dependencies: {}
21302130
hash:
2131-
md5: 949519bf61c21c9db15f19f67a08a5b9
2132-
sha256: 54cbf4a99778316e05a7c646a92681e2694ee104fa637b5f435d4e6a1da818f6
2131+
md5: 0f514fa2a02eacfd60124aee7ad85b92
2132+
sha256: 13b8c2da5e1397e8d7c1c20b423cbe56e8952f832679b0aab896e2def3769a35
21332133
manager: conda
21342134
name: conda-forge-pinning
21352135
optional: false
21362136
platform: osx-arm64
21372137
url:
2138-
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.23.21.47.32-hd8ed1ab_0.conda
2139-
version: 2025.03.23.21.47.32
2138+
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.25.12.23.56-hd8ed1ab_0.conda
2139+
version: 2025.03.25.12.23.56
21402140
- category: main
21412141
dependencies:
21422142
click: '>=8'

conda_forge_tick/migrators/recipe_v1.py

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,43 @@
1212
logger = logging.getLogger(__name__)
1313

1414

15-
def combine_conditions(node):
15+
def is_same_condition(a: Any, b: Any) -> bool:
16+
return (
17+
isinstance(a, dict)
18+
and isinstance(b, dict)
19+
and "if" in a
20+
and "if" in b
21+
and a["if"] == b["if"]
22+
)
23+
24+
25+
def fold_branch(source: Any, dest: Any, branch: str) -> None:
26+
if branch not in source:
27+
return
28+
source_l = source[branch]
29+
if isinstance(source_l, str):
30+
source_l = [source_l]
31+
32+
if branch not in dest:
33+
dest[branch] = []
34+
elif isinstance(dest[branch], str):
35+
dest[branch] = [dest[branch]]
36+
dest[branch].extend(source_l)
37+
38+
39+
def combine_conditions(node: Any):
1640
"""Breadth first recursive call to combine list conditions"""
1741

1842
# recursion is breadth first because we go through each element here
1943
# before calling `combine_conditions` on any element in the node
2044
if isinstance(node, list):
21-
# 1. loop through list elements, gather the if conditions
22-
23-
# condition ("if:") -> [(then, else), (then, else)...]
24-
conditions = {}
25-
26-
for i in node:
27-
if isinstance(i, dict) and "if" in i:
28-
conditions.setdefault(i["if"], []).append((i["then"], i.get("else")))
29-
30-
# 2. if elements share a compatible if condition
31-
# combine their if...then...else statements
32-
to_drop = []
33-
for i in range(len(node)):
34-
if isinstance(node[i], dict) and "if" in node[i]:
35-
condition = node[i]["if"]
36-
if condition not in conditions:
37-
# already combined it, so drop the repeat instance
38-
to_drop.append(i)
39-
continue
40-
if len(conditions[condition]) > 1:
41-
new_then = []
42-
new_else = []
43-
for sub_then, sub_else in conditions[node[i]["if"]]:
44-
if isinstance(sub_then, list):
45-
new_then.extend(sub_then)
46-
else:
47-
assert sub_then is not None
48-
new_then.append(sub_then)
49-
if isinstance(sub_else, list):
50-
new_else.extend(sub_else)
51-
elif sub_else is not None:
52-
new_else.append(sub_else)
53-
node[i]["then"] = new_then
54-
if new_else:
55-
# TODO: preserve inline "else" instead of converting it to a list?
56-
node[i]["else"] = new_else
57-
else:
58-
assert "else" not in node[i]
59-
# remove it from the dict, so we don't output it again
60-
del conditions[condition]
61-
62-
# drop the repeated conditions
63-
for i in reversed(to_drop):
64-
del node[i]
45+
# iterate in reverse order, so we can remove elements on the fly
46+
# start at index 1, since we can only fold to the previous node
47+
for i in reversed(range(1, len(node))):
48+
if is_same_condition(node[i], node[i - 1]):
49+
fold_branch(node[i], node[i - 1], "then")
50+
fold_branch(node[i], node[i - 1], "else")
51+
del node[i]
6552

6653
# then we descend down the tree
6754
if isinstance(node, dict):

tests/test_v1_yaml/version_pytorch.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ outputs:
318318
- torch
319319
- torch._C
320320
- files:
321+
recipe:
322+
- cmake_test/
321323
source:
322324
- test
323325
- tools
@@ -369,6 +371,15 @@ outputs:
369371
then: test ! -f $SP_DIR/functorch/__pycache__/__init__.cpython-313.pyc
370372
- if: match(python, "!=3.13") and win
371373
then: if exist %SP_DIR%\functorch\__pycache__\__init__.cpython-313.pyc exit 1
374+
- cd cmake_test
375+
- if: unix
376+
then: cmake -GNinja -DCMAKE_CXX_STANDARD=17 -DWITH_TORCH_PYTHON=ON $CMAKE_ARGS .
377+
- if: win
378+
then: cmake -GNinja -DCMAKE_CXX_STANDARD=17 -DWITH_TORCH_PYTHON=ON %CMAKE_ARGS% .
379+
- if: unix
380+
then: cmake --build .
381+
- if: win
382+
then: cmake --build . --config Release
372383

373384
about:
374385
license: BSD-3-Clause

tests/test_v1_yaml/version_pytorch_correct.yaml

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ outputs:
5555
then:
5656
- intel-openmp ${{ mkl }}
5757
- libuv
58-
- sccache
5958
- cmake
6059
- ninja
6160
# Keep libprotobuf here so that a compatibile version
@@ -64,18 +63,27 @@ outputs:
6463
- protobuf
6564
- if: linux
6665
then: make
66+
- if: win
67+
then: sccache
6768
- if: unix
6869
then:
6970
- grep
7071
- rsync
7172
host:
7273
# GPU requirements
74+
- if: "cuda_compiler_version != \"None\""
75+
then: cudnn
76+
- if: "cuda_compiler_version != \"None\" and linux"
77+
then: nccl
7378
- if: "cuda_compiler_version != \"None\""
7479
then:
75-
- cudnn
7680
- magma
7781
- cuda-version ${{ cuda_compiler_version }}
7882
- nvtx-c
83+
- if: "linux and cuda_compiler_version != \"None\""
84+
then: cuda-driver-dev
85+
- if: "cuda_compiler_version != \"None\""
86+
then:
7987
- cuda-cudart-dev
8088
- cuda-cupti-dev
8189
- cuda-nvrtc-dev
@@ -85,16 +93,14 @@ outputs:
8593
- cusparselt
8694
- libcublas-dev
8795
- libcudss-dev
96+
- if: "linux and cuda_compiler_version != \"None\""
97+
then: libcufile-dev
98+
- if: "cuda_compiler_version != \"None\""
99+
then:
88100
- libcufft-dev
89101
- libcurand-dev
90102
- libcusolver-dev
91103
- libcusparse-dev
92-
- if: "cuda_compiler_version != \"None\" and linux"
93-
then: nccl
94-
- if: "linux and cuda_compiler_version != \"None\""
95-
then:
96-
- cuda-driver-dev
97-
- libcufile-dev
98104
- if: megabuild
99105
else:
100106
- python
@@ -181,12 +187,19 @@ outputs:
181187
host:
182188
- ${{ pin_subpackage('libtorch', exact=True) }}
183189
# GPU requirements
190+
- if: "cuda_compiler_version != \"None\""
191+
then: cudnn
192+
- if: "cuda_compiler_version != \"None\" and linux"
193+
then: nccl
184194
- if: "cuda_compiler_version != \"None\""
185195
then:
186-
- cudnn
187196
- cuda-version ${{ cuda_compiler_version }}
188197
- nvtx-c
189198
- magma
199+
- if: "linux and cuda_compiler_version != \"None\""
200+
then: cuda-driver-dev
201+
- if: "cuda_compiler_version != \"None\""
202+
then:
190203
- cuda-cudart-dev
191204
- cuda-cupti-dev
192205
- cuda-nvrtc-dev
@@ -196,16 +209,14 @@ outputs:
196209
- cusparselt
197210
- libcublas-dev
198211
- libcudss-dev
212+
- if: "linux and cuda_compiler_version != \"None\""
213+
then: libcufile-dev
214+
- if: "cuda_compiler_version != \"None\""
215+
then:
199216
- libcufft-dev
200217
- libcurand-dev
201218
- libcusolver-dev
202219
- libcusparse-dev
203-
- if: "cuda_compiler_version != \"None\" and linux"
204-
then: nccl
205-
- if: "linux and cuda_compiler_version != \"None\""
206-
then:
207-
- cuda-driver-dev
208-
- libcufile-dev
209220
- python
210221
- numpy
211222
- pip
@@ -252,12 +263,12 @@ outputs:
252263
then: nomkl
253264
# GPU requirements without run_exports
254265
- if: "cuda_compiler_version != \"None\""
255-
then:
256-
- ${{ pin_compatible('cudnn') }}
257-
- __cuda
266+
then: ${{ pin_compatible('cudnn') }}
258267
- if: "cuda_compiler_version != \"None\" and not win"
259268
then: triton =${{ triton }}
260269
# avoid that people without GPUs needlessly download ~0.5-1GB
270+
- if: "cuda_compiler_version != \"None\""
271+
then: __cuda
261272
- python
262273
# other requirements, see https://github.com/pytorch/pytorch/blame/main/requirements.txt
263274
- filelock
@@ -285,6 +296,8 @@ outputs:
285296
- torch
286297
- torch._C
287298
- files:
299+
recipe:
300+
- cmake_test/
288301
source:
289302
- test
290303
- tools
@@ -333,6 +346,15 @@ outputs:
333346
then: test ! -f $SP_DIR/functorch/__pycache__/__init__.cpython-313.pyc
334347
- if: match(python, "!=3.13") and win
335348
then: if exist %SP_DIR%\functorch\__pycache__\__init__.cpython-313.pyc exit 1
349+
- cd cmake_test
350+
- if: unix
351+
then: cmake -GNinja -DCMAKE_CXX_STANDARD=17 -DWITH_TORCH_PYTHON=ON $CMAKE_ARGS .
352+
- if: win
353+
then: cmake -GNinja -DCMAKE_CXX_STANDARD=17 -DWITH_TORCH_PYTHON=ON %CMAKE_ARGS% .
354+
- if: unix
355+
then: cmake --build .
356+
- if: win
357+
then: cmake --build . --config Release
336358

337359
about:
338360
license: BSD-3-Clause

0 commit comments

Comments
 (0)