|
46 | 46 |
|
47 | 47 | # Enrich the build configs with generic attributes for framework |
48 | 48 | # order/version. Also make bundleBuild attr explicit. |
49 | | - buildConfigs = map ( |
| 49 | + buildSets = map ( |
50 | 50 | set: |
51 | 51 | let |
52 | 52 | inherit (set) buildConfig; |
53 | 53 | in |
54 | | - buildConfig |
| 54 | + set |
55 | 55 | // { |
56 | | - bundleBuild = buildConfig.bundleBuild or false; |
57 | | - frameworkOrder = if buildConfig ? cudaVersion then 0 else 1; |
58 | | - frameworkVersion = |
59 | | - buildConfig.cudaVersion or buildConfig.rocmVersion or buildConfig.xpuVersion or "0.0"; |
| 56 | + buildConfig = |
| 57 | + |
| 58 | + buildConfig // { |
| 59 | + bundleBuild = buildConfig.bundleBuild or false; |
| 60 | + frameworkOrder = if buildConfig ? cudaVersion then 0 else 1; |
| 61 | + frameworkVersion = |
| 62 | + buildConfig.cudaVersion or buildConfig.rocmVersion or buildConfig.xpuVersion or "0.0"; |
| 63 | + }; |
60 | 64 | } |
61 | 65 | ) (build.applicableBuildSets path); |
62 | 66 | configCompare = |
63 | | - a: b: |
| 67 | + setA: setB: |
| 68 | + let |
| 69 | + a = setA.buildConfig; |
| 70 | + b = setB.buildConfig; |
| 71 | + in |
64 | 72 | if a.bundleBuild != b.bundleBuild then |
65 | 73 | a.bundleBuild |
66 | 74 | else if a.frameworkOrder != b.frameworkOrder then |
|
69 | 77 | builtins.compareVersions a.torchVersion b.torchVersion > 0 |
70 | 78 | else |
71 | 79 | builtins.compareVersions a.frameworkVersion b.frameworkVersion < 0; |
72 | | - buildConfigsSorted = lib.sort configCompare buildConfigs; |
73 | | - shellTorch = |
74 | | - if buildConfigsSorted == [ ] then |
| 80 | + buildSetsSorted = lib.sort configCompare buildSets; |
| 81 | + bestBuildSet = |
| 82 | + if buildSetsSorted == [ ] then |
75 | 83 | throw "No build variant is compatible with this system" |
76 | 84 | else |
77 | | - buildName (builtins.head buildConfigsSorted); |
| 85 | + builtins.head buildSetsSorted; |
| 86 | + shellTorch = buildName bestBuildSet.buildConfig; |
78 | 87 | in |
79 | | - |
80 | 88 | { |
81 | 89 | devShells = rec { |
82 | 90 | default = devShells.${shellTorch}; |
|
100 | 108 | rev = revUnderscored; |
101 | 109 | }; |
102 | 110 | }; |
103 | | - packages = rec { |
104 | | - default = bundle; |
| 111 | + packages = |
| 112 | + let |
| 113 | + bundle = build.buildTorchExtensionBundle { |
| 114 | + inherit path doGetKernelCheck; |
| 115 | + rev = revUnderscored; |
| 116 | + }; |
| 117 | + in |
| 118 | + { |
| 119 | + inherit bundle; |
105 | 120 |
|
106 | | - build-and-copy = writeScriptBin "build-and-copy" '' |
107 | | - #!/usr/bin/env bash |
108 | | - set -euo pipefail |
| 121 | + default = bundle; |
109 | 122 |
|
110 | | - if [ ! -d build ]; then |
111 | | - mkdir build |
112 | | - fi |
| 123 | + build-and-copy = writeScriptBin "build-and-copy" '' |
| 124 | + #!/usr/bin/env bash |
| 125 | + set -euo pipefail |
113 | 126 |
|
114 | | - for build_variant in ${bundle}/*; do |
115 | | - build_variant=$(basename $build_variant) |
116 | | - if [ -e build/$build_variant ]; then |
117 | | - rm -rf build/$build_variant |
| 127 | + if [ ! -d build ]; then |
| 128 | + mkdir build |
118 | 129 | fi |
119 | 130 |
|
120 | | - cp -r ${bundle}/$build_variant build/ |
121 | | - done |
| 131 | + for build_variant in ${bundle}/*; do |
| 132 | + build_variant=$(basename $build_variant) |
| 133 | + if [ -e build/$build_variant ]; then |
| 134 | + rm -rf build/$build_variant |
| 135 | + fi |
122 | 136 |
|
123 | | - chmod -R +w build |
124 | | - ''; |
| 137 | + cp -r ${bundle}/$build_variant build/ |
| 138 | + done |
125 | 139 |
|
126 | | - bundle = build.buildTorchExtensionBundle { |
127 | | - inherit path doGetKernelCheck; |
128 | | - rev = revUnderscored; |
129 | | - }; |
130 | | - redistributable = build.buildDistTorchExtensions { |
131 | | - inherit path doGetKernelCheck; |
132 | | - bundleOnly = false; |
133 | | - rev = revUnderscored; |
| 140 | + chmod -R +w build |
| 141 | + ''; |
| 142 | + |
| 143 | + kernels = |
| 144 | + bestBuildSet.pkgs.python3.withPackages ( |
| 145 | + ps: with ps; [ |
| 146 | + kernel-abi-check |
| 147 | + kernels |
| 148 | + ] |
| 149 | + ) |
| 150 | + // { |
| 151 | + meta.mainProgram = "kernels"; |
| 152 | + }; |
| 153 | + |
| 154 | + redistributable = build.buildDistTorchExtensions { |
| 155 | + inherit path doGetKernelCheck; |
| 156 | + bundleOnly = false; |
| 157 | + rev = revUnderscored; |
| 158 | + }; |
134 | 159 | }; |
135 | | - }; |
136 | 160 | } |
0 commit comments