frugally-deep: revert bump&backport CMake 4 compat, rocmPackages.miopen: add regression test (#444645)

authored by Emily and committed by GitHub c057301e e8f62c1f

+140 -4
+24 -4
pkgs/by-name/fr/frugally-deep/package.nix
··· 1 1 { 2 2 lib, 3 3 stdenv, 4 + fetchpatch, 4 5 fetchFromGitHub, 5 6 gitUpdater, 6 7 cmake, 7 8 functionalplus, 8 9 eigen, 9 10 nlohmann_json, 10 - doctest, 11 11 python3Packages, 12 12 buildTests ? false, # Needs tensorflow 13 + # for tests 14 + doctest, 15 + rocmPackages, 13 16 }: 14 17 15 18 stdenv.mkDerivation (finalAttrs: { 16 19 pname = "frugally-deep"; 17 - version = "0.18.2-unstable-2025-06-16"; 20 + # be careful bumping this, frugally-deep may change its model metadata format 21 + # in ways that only fail at runtime. MIOpen is currently the only package 22 + # relying on this, run passthru.tests.miopen-can-load-models to check 23 + version = "0.15.24-p0"; 18 24 19 25 src = fetchFromGitHub { 20 26 owner = "Dobiasd"; 21 27 repo = "frugally-deep"; 22 - rev = "30a4ce4c932ca810a5a77c4ab943a520bb1048fe"; 23 - hash = "sha256-tcwCRSHhN61ZFDFVQ/GItvgSSjeLSbFDoNMqwswtvto="; 28 + rev = "v${finalAttrs.version}"; 29 + hash = "sha256-yg2SMsYOOSOgsdwIH1bU3iPM45z6c7WeIrgOddt3um4="; 24 30 }; 25 31 32 + patches = [ 33 + (fetchpatch { 34 + # Backport CMake 4 compat so we can stay on 0.15 for now 35 + name = "update-minimum-cmake4-huntergate.patch"; 36 + url = "https://github.com/Dobiasd/frugally-deep/commit/30a4ce4c932ca810a5a77c4ab943a520bb1048fe.patch"; 37 + hash = "sha256-J5z+jQis8N2mzWu2Qm7J0fPkrplpjgDCOAJT7binz04="; 38 + }) 39 + ]; 40 + 26 41 nativeBuildInputs = [ 27 42 cmake 28 43 ] ··· 43 58 ]; 44 59 45 60 cmakeFlags = lib.optionals buildTests [ "-DFDEEP_BUILD_UNITTEST=ON" ]; 61 + passthru.tests.miopen-can-load-models = 62 + rocmPackages.miopen.passthru.tests.can-load-models.override 63 + { 64 + frugally-deep = finalAttrs.finalPackage; 65 + }; 46 66 passthru.updateScript = gitUpdater; 47 67 48 68 meta = with lib; {
+12
pkgs/development/rocm-modules/6/miopen/default.nix
··· 1 1 { 2 2 lib, 3 3 stdenv, 4 + callPackage, 4 5 fetchFromGitHub, 5 6 fetchpatch, 6 7 rocmUpdateScript, ··· 297 298 298 299 requiredSystemFeatures = [ "big-parallel" ]; 299 300 301 + passthru.tests = { 302 + # Ensure all .tn.model files can be loaded by whatever version of frugally-deep we have 303 + # This is otherwise hard to verify as MIOpen will only use these models on specific, 304 + # expensive Instinct GPUs 305 + # If MIOpen stops embedding .tn.model files the test will also fail, and can be deleted, 306 + # likely along with the frugally-deep dependency 307 + can-load-models = callPackage ./test-frugally-deep-model-loading.nix { 308 + inherit (finalAttrs) src version; 309 + inherit frugally-deep nlohmann_json; 310 + }; 311 + }; 300 312 passthru.updateScript = rocmUpdateScript { 301 313 name = finalAttrs.pname; 302 314 inherit (finalAttrs.src) owner;
+55
pkgs/development/rocm-modules/6/miopen/test-frugally-deep-model-loading.cpp
··· 1 + #include <fdeep/fdeep.hpp> 2 + #include <iostream> 3 + #include <filesystem> 4 + #include <vector> 5 + #include <string> 6 + 7 + int main() { 8 + std::vector<std::string> model_files; 9 + std::string src_dir = std::getenv("SRC_DIR") ? std::getenv("SRC_DIR") : "."; 10 + 11 + // collect *tn.model files except _metadata 12 + try { 13 + for (const auto& entry : std::filesystem::recursive_directory_iterator(src_dir)) { 14 + if (entry.is_regular_file()) { 15 + std::string path = entry.path().string(); 16 + if (path.find("tn.model") != std::string::npos && path.find("_metadata.") == std::string::npos) { 17 + model_files.push_back(path); 18 + } 19 + } 20 + } 21 + } catch (const std::exception& e) { 22 + std::cerr << "Error scanning directory: " << e.what() << std::endl; 23 + return 1; 24 + } 25 + 26 + if (model_files.empty()) { 27 + std::cout << "No *.tn.model files found in " << src_dir << std::endl; 28 + return 1; 29 + } 30 + 31 + std::cout << "Found " << model_files.size() << " model files to test" << std::endl; 32 + 33 + int failed_count = 0; 34 + for (const auto& model_file : model_files) { 35 + std::cout << "Loading: " << model_file << " ... "; 36 + std::cout.flush(); 37 + 38 + try { 39 + const auto model = fdeep::load_model(model_file); 40 + std::cout << "OK" << std::endl; 41 + } catch (const std::exception& e) { 42 + std::cout << "FAILED: " << e.what() << std::endl; 43 + failed_count++; 44 + } 45 + } 46 + 47 + if (failed_count > 0) { 48 + std::cerr << "\n" << failed_count << " out of " << model_files.size() 49 + << " models failed to load" << std::endl; 50 + return 1; 51 + } 52 + 53 + std::cout << "\nAll " << model_files.size() << " models loaded successfully!" << std::endl; 54 + return 0; 55 + }
+49
pkgs/development/rocm-modules/6/miopen/test-frugally-deep-model-loading.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + eigen, 5 + frugally-deep, 6 + functionalplus, 7 + nlohmann_json, 8 + src, 9 + version, 10 + }: 11 + 12 + stdenv.mkDerivation { 13 + pname = "miopen-frugally-deep-model-test"; 14 + inherit version src; 15 + 16 + dontConfigure = true; 17 + dontInstall = true; 18 + doCheck = true; 19 + 20 + buildPhase = '' 21 + runHook preBuild 22 + 23 + $CXX -std=c++20 \ 24 + -I${lib.getDev eigen}/include/eigen3 \ 25 + -I${lib.getDev functionalplus}/include \ 26 + -I${lib.getDev frugally-deep}/include \ 27 + -I${lib.getDev nlohmann_json}/include \ 28 + ${./test-frugally-deep-model-loading.cpp} \ 29 + -o test_models 30 + 31 + runHook postBuild 32 + ''; 33 + 34 + checkPhase = '' 35 + runHook preCheck 36 + 37 + echo "Running model loading tests..." 38 + SRC_DIR="${src}" ./test_models 39 + mkdir -p $out 40 + 41 + runHook postCheck 42 + ''; 43 + 44 + meta = { 45 + description = "Test that frugally-deep can load MIOpen model files"; 46 + maintainers = with lib.teams; [ rocm ]; 47 + platforms = lib.platforms.linux; 48 + }; 49 + }