diff --git a/flake.nix b/flake.nix index 1d1f4e66..081180f2 100644 --- a/flake.nix +++ b/flake.nix @@ -118,7 +118,7 @@ }; inherit (nixpkgs) lib; - buildVersion = import ./lib/build-version.nix; + buildName = (import ./lib/build-variants.nix { inherit lib; }).buildName; buildSets = defaultBuildSetsPerSystem.${system}; @@ -152,11 +152,12 @@ ++ allOutputs python3Packages.kernels ++ lib.optionals stdenv.hostPlatform.isLinux (allOutputs stdenvGlibc_2_27) ); - buildSetLinkFarm = buildSet: pkgs.linkFarm (buildVersion buildSet) (buildSetOutputs buildSet); + buildSetLinkFarm = + buildSet: pkgs.linkFarm (buildName buildSet.buildConfig) (buildSetOutputs buildSet); in pkgs.linkFarm "packages-for-cache" ( map (buildSet: { - name = buildVersion buildSet; + name = buildName (buildSet.buildConfig); path = buildSetLinkFarm buildSet; }) buildSets ); @@ -182,7 +183,7 @@ # This package set is exposed so that we can prebuild the Torch versions. torch = builtins.listToAttrs ( map (buildSet: { - name = buildVersion buildSet; + name = buildName (buildSet.buildConfig); value = buildSet.torch; }) buildSets ); diff --git a/lib/build-version.nix b/lib/build-version.nix deleted file mode 100644 index 527649c7..00000000 --- a/lib/build-version.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - buildConfig, - extension, - pkgs, - torch, - bundleBuild, -}: -let - inherit (pkgs) lib; - inherit (import ./version-utils.nix { inherit lib; }) flattenVersion abiString; - abi = torch: abiString torch.passthru.cxx11Abi; - targetPlatform = pkgs.stdenv.targetPlatform.system; - cudaVersion = torch: "cu${flattenVersion torch.cudaPackages.cudaMajorMinorVersion}"; - rocmVersion = - torch: "rocm${flattenVersion (lib.versions.majorMinor torch.rocmPackages.rocm.version)}"; - torchVersion = torch: flattenVersion torch.version; - xpuVersion = - torch: - "xpu${flattenVersion (lib.versions.majorMinor torch.xpuPackages.intel-oneapi-dpcpp-cpp.version)}"; - gpuVersion = - torch: - if torch.cudaSupport then - cudaVersion torch - else if (torch ? rocmPackages) && (torch.rocmSupport or false) then - rocmVersion torch - else if (torch ? xpuPackages) && (torch.xpuSupport or false) then - xpuVersion torch - else - null; -in -if pkgs.stdenv.hostPlatform.isDarwin then - "torch${torchVersion torch}-metal-${targetPlatform}" -else if gpuVersion torch != null then - "torch${torchVersion torch}-${abi torch}-${gpuVersion torch}-${targetPlatform}" -else - throw "No supported GPU framework (CUDA, ROCm, XPU, Metal) detected for build-version.nix" diff --git a/lib/build.nix b/lib/build.nix index 3f50f4ca..ce8edc73 100644 --- a/lib/build.nix +++ b/lib/build.nix @@ -12,7 +12,7 @@ let abi = torch: if torch.passthru.cxx11Abi then "cxx11" else "cxx98"; - torchBuildVersion = import ./build-version.nix; + buildName = (import ./build-variants.nix { inherit lib; }).buildName; supportedCudaCapabilities = builtins.fromJSON ( builtins.readFile ../build2cmake/src/cuda_supported_archs.json ); @@ -171,7 +171,7 @@ rec { extensionForTorch = { path, rev }: buildSet: { - name = torchBuildVersion buildSet; + name = buildName buildSet.buildConfig; value = mkTorchExtension buildSet { inherit path rev doGetKernelCheck; stripRPath = true; @@ -235,7 +235,7 @@ rec { mkShell = pkgs.mkShell.override { inherit (buildSet.extension) stdenv; }; in { - name = torchBuildVersion buildSet; + name = buildName buildSet.buildConfig; value = mkShell { nativeBuildInputs = with pkgs; pythonNativeCheckInputs python3.pkgs; @@ -275,7 +275,7 @@ rec { mkShell = pkgs.mkShell.override { inherit (buildSet.extension) stdenv; }; in { - name = torchBuildVersion buildSet; + name = buildName buildSet.buildConfig; value = mkShell { nativeBuildInputs = with pkgs;