Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions nix-builder/lib/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ let
expectedTorchVersion = "2.13.0";
kernelBuildSetTorchVersions = lib.unique (map (buildSet: buildSet.torch.version) kernelBuildSets);

# `filterBundle` tests.
reluBoundsOutputs = genKernelFlakeOutputs {
inherit self;
path = ../tests/kernels/relu-torch-bounds;
};
inherit (reluBoundsOutputs.lib.${stdenv.hostPlatform.system}) filterBundle;
fullBundleDrv = reluBoundsOutputs.packages.${stdenv.hostPlatform.system}.bundle.drvPath;
expectedTorchMajorMinor = lib.versions.majorMinor expectedTorchVersion;

badRegistrationCheck = testers.testBuildFailure' {
drv =
(genKernelFlakeOutputs {
Expand Down Expand Up @@ -187,6 +196,28 @@ assert lib.assertMsg
''
Torch minver/maxver filtering does not work: expected only build sets with Torch ${expectedTorchVersion}, got: ${lib.concatStringsSep ", " kernelBuildSetTorchVersions}
'';
assert lib.assertMsg ((filterBundle (_: true)).drvPath == fullBundleDrv) ''
filterBundle does not work: a filter that accepts everything should give the full bundle.
'';
assert lib.assertMsg ((filterBundle (_: false)).drvPath != fullBundleDrv) ''
filterBundle does not work: a filter that rejects everything should not give the full bundle.
'';
assert lib.assertMsg
(
(filterBundle (buildConfig: buildConfig.torchVersion == expectedTorchMajorMinor)).drvPath
== fullBundleDrv
)
''
filterBundle does not work: filtering on Torch ${expectedTorchMajorMinor} should give the full bundle for relu-torch-bounds.
'';
assert lib.assertMsg
(
(filterBundle (buildConfig: buildConfig.torchVersion != expectedTorchMajorMinor)).drvPath
!= fullBundleDrv
)
''
filterBundle does not work: filtering out Torch ${expectedTorchMajorMinor} should not give the full bundle for relu-torch-bounds.
'';
assert lib.assertMsg (torchVersionUtilsTestFailures == [ ]) ''
torch-version-utils tests failed: ${builtins.toJSON torchVersionUtilsTestFailures}
'';
Expand Down
6 changes: 6 additions & 0 deletions nix-builder/lib/flake-outputs/gen-flake-outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ in
test = testShells.${bestVariant};
inherit testShells;
};

# Filter build sets using a function useBuildSet :: buildConfig -> bool
# that gets the build set configuration.
lib.filterBundle =
useBuildSet: mkBundle (lib.filter (buildSet: useBuildSet buildSet.buildConfig) applicableBuildSets);

packages =
let
bundle = mkBundle applicableBuildSets;
Expand Down
Loading