Something went wrong. Try again.
lol
Something went wrong. Try again.
6.3 kB · 239 lines
Nix
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240{ lib, stdenv, pkgs, buildPythonPackage, fetchFromGitHub,
# nativeBuildInputs gitMinimal,
# build-system certifi, cmake, packaging, pyyaml, setuptools, zstd,
# dependencies # coremltools, (unpackaged) expecttest, flatbuffers, hydra-core, hypothesis, kgb, mpmath, numpy, omegaconf, pandas, parameterized, pytorch-tokenizers, ruamel-yaml, scikit-learn, sympy, tabulate, torch, torchao, typing-extensions,
# tests pytest-json-report, pytest-rerunfailures, pytestCheckHook, torchaudio, torchtune, transformers, writableTmpDirAsHomeHook, yaspin,}:buildPythonPackage (finalAttrs: { pname = "executorch"; version = "1.2.0"; pyproject = true;
src = fetchFromGitHub { owner = "pytorch"; repo = "executorch"; tag = "v${finalAttrs.version}";
# The ExecuTorch repo must be cloned into a directory named exactly `executorch`. # See https://github.com/pytorch/executorch/issues/6475 for progress on a fix for this restriction. name = "executorch";
fetchSubmodules = true; hash = "sha256-Rkw6+keOygQaf6iOCpGoW9JgXiCimgx8gsxLEH3bxME="; };
postPatch = # Hardcode the default flatc binary path to the nixpkgs flatc '' substituteInPlace exir/_serialize/_flatbuffer.py \ --replace-fail \ 'flatc_path = "flatc"' \ 'flatc_path = "${lib.getExe pkgs.flatbuffers}"' '' # Relax build-system dependencies + '' substituteInPlace pyproject.toml \ --replace-fail '"pip>=23",' "" \ --replace-fail "cmake>=3.24,<4.0.0" "cmake" '' # CMake 4 dropped support of versions lower than 3.5, versions lower than 3.10 are deprecated. # https://github.com/NixOS/nixpkgs/issues/445447 + '' substituteInPlace backends/xnnpack/third-party/pthreadpool/CMakeLists.txt \ --replace-fail \ "CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR)" \ "CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)" '' # Fix build with GCC>=15 + '' substituteInPlace third-party/flatcc/include/flatcc/portable/grisu3_print.h \ --replace-fail \ 'static char hexdigits[16] = "0123456789ABCDEF";' \ 'static char hexdigits[17] = "0123456789ABCDEF";'
sed -i "1i #include <cstdint>" backends/apple/coreml/runtime/inmemoryfs/memory_buffer.hpp sed -i "1i #include <cstdint>" extension/llm/tokenizers/third-party/sentencepiece/src/sentencepiece_processor.h '';
env = { BUILD_VERSION = finalAttrs.version;
# Can't use cmakeFlags since we do not control invocation of cmake. # But the build script is sensitive to this env variable. # Fixes: # Some binaries contain forbidden references to /build/. Check the error above! CMAKE_ARGS = lib.concatStringsSep " " [ (lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) ]; };
build-system = [ certifi cmake packaging pyyaml setuptools zstd ]; dontUseCmakeConfigure = true;
nativeBuildInputs = [ gitMinimal ];
pythonRemoveDeps = [ # unpackaged "coremltools"
# Test dependencies that should not be listed in runtime dependencies "pytest" "pytest-json-report" "pytest-rerunfailures" "pytest-xdist" ]; pythonRelaxDeps = [ "scikit-learn" "torchao" ]; dependencies = [ # coremltools (unpackaged) expecttest flatbuffers hydra-core hypothesis kgb mpmath numpy omegaconf packaging pandas parameterized pytorch-tokenizers pyyaml ruamel-yaml scikit-learn sympy tabulate torch torchao typing-extensions ];
pythonImportsCheck = [ "executorch" ];
nativeCheckInputs = [ pytest-json-report pytest-rerunfailures pytestCheckHook torchaudio torchtune transformers writableTmpDirAsHomeHook yaspin ];
disabledTestPaths = [ # Require unpackaged coremltools "backends/apple/coreml/*" "export/tests/test_target_recipes.py"
# Try to download models from HuggingFace hub "extension/llm/tokenizers/test/test_hf_tokenizer.py" ];
disabledTests = [ # RuntimeError: Failed to execute method forward, error: 0x20 # [method.cpp:70] Backend BackendWithCompilerDemo is not registered "test_compatibility_in_runtime" "test_compatibility_in_runtime_edge_program_manager" "test_emit_lowered_backend_module_end_to_end" "test_multi_method_end_to_end"
# AssertionError (Numerical comparison fails) "test_sdpa_with_cache_seq_len_13" "test_sdpa_with_custom_quantized_seq_len_130_gqa" "test_within_transformer"
# Try to download models from the internet "test_all_models_with_recipes" "test_dl3_export_to_executorch" "test_efficient_sam_export_to_executorch" "test_ic3_export_to_executorch" "test_mobilenet_v3" "test_mobilenet_v3_xnnpack" "test_mv2_export_to_executorch" "test_mv3_export_to_executorch" "test_resnet18_export_to_executorch" "test_resnet50_export_to_executorch" "test_vit_export_to_executorch"
# RuntimeError: Failed to compile /build/tmplb6i266d/data.json to /build/tmplb6i266d/data.pte "test_flatbuffer_paths_match" ] ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64) [ # RuntimeError: Error in dlopen: # /tmp/AP8CBk/vision_encoder/data/aotinductor/model/chm6ca425mbz7jdmmwcbnyrm6x6tedrfmaoyr4vee625vxhjibbt.wrapper.so: # cannot enable executable stack as shared object requires: Invalid argument "TestImageTransform" "test_flamingo_vision_encoder" "test_llama3_2_text_decoder_aoti" "test_tile_positional_embedding_aoti" ];
meta = { description = "On-device AI across mobile, embedded and edge for PyTorch"; homepage = "https://github.com/pytorch/executorch"; changelog = "https://github.com/pytorch/executorch/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ GaetanLepage ]; badPlatforms = [ # Many tests segfault. Supporting this platform will need additional work "aarch64-linux" # Compilation errors on Darwin lib.systems.inspect.patterns.isDarwin ]; };})