Skip to content

runtime executor test model export failure on Mac #10257

Open
@larryliu0820

Description

@larryliu0820

🐛 Describe the bug

I'm on commit: 17cbef5

bash ./install_executorch.sh

cmake -DCMAKE_INSTALL_PREFIX=cmake-out -DCMAKE_BUILD_TYPE=Debug -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON  -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON -DPYTHON_EXECUTABLE=python -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON -DEXECUTORCH_BUILD_TESTS=ON -Bcmake-out .

cmake --build cmake-out -j9 --target install --config Debug

This will fail on Mac, so need the following patch:

diff --git a/runtime/executor/test/CMakeLists.txt b/runtime/executor/test/CMakeLists.txt
index 3003a5d2c..0b454f6a2 100644
--- a/runtime/executor/test/CMakeLists.txt
+++ b/runtime/executor/test/CMakeLists.txt
@@ -28,14 +28,14 @@ add_custom_command(
          "${CMAKE_CURRENT_BINARY_DIR}/ModuleMultipleEntry.pte"
          "${CMAKE_CURRENT_BINARY_DIR}/ModuleSimpleTrain.pte"
   COMMAND
-    python3 -m test.models.export_program --modules
+    ${PYTHON_EXECUTABLE} -m test.models.export_program --modules
     "ModuleAdd,ModuleAddHalf,ModuleDynamicCatUnallocatedIO,ModuleIndex,ModuleLinear,ModuleMultipleEntry,ModuleSimpleTrain"
-    --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
+    --outdir "${CMAKE_CURRENT_BINARY_DIR}"
   COMMAND
-    python3 -m test.models.export_program --modules "ModuleLinear"
-    --external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
+    ${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleLinear"
+    --external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}"
   COMMAND
-    python3 -m test.models.export_delegated_program --modules "ModuleAddMul"
+    ${PYTHON_EXECUTABLE} -m test.models.export_delegated_program --modules "ModuleAddMul"
     --backend_id "StubBackend" --outdir "${CMAKE_CURRENT_BINARY_DIR}" || true
   WORKING_DIRECTORY ${EXECUTORCH_ROOT}
 )

Then I got the following error:

...

error:
  /private/var/folders/4n/g6_02f5x1mvdw88n7dtw15l80000gn/T/tmpx3xs7jk_/data.json:1: 2325: error: unexpected force_align value '1024', alignment must be a power of two integer ranging from the type's natural alignment 1 to 1024

Traceback (most recent call last):
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/_serialize/_flatbuffer.py", line 290, in _program_json_to_flatbuffer
    _flatc_compile(temp_dir, schema_info.root_path, json_path)
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/_serialize/_flatbuffer.py", line 213, in _flatc_compile
    _run_flatc(
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/_serialize/_flatbuffer.py", line 199, in _run_flatc
    subprocess.run([flatc_path] + list(args), check=True)
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['flatc', '--binary', '-o', '/var/folders/4n/g6_02f5x1mvdw88n7dtw15l80000gn/T/tmpx3xs7jk_', '/var/folders/4n/g6_02f5x1mvdw88n7dtw15l80000gn/T/tmpx3xs7jk_/program.fbs', '/var/folders/4n/g6_02f5x1mvdw88n7dtw15l80000gn/T/tmpx3xs7jk_/data.json']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/larryliu/executorch/test/models/export_delegated_program.py", line 244, in <module>
    main()
  File "/Users/larryliu/executorch/test/models/export_delegated_program.py", line 233, in main
    export_module_to_program(
  File "/Users/larryliu/executorch/test/models/export_delegated_program.py", line 171, in export_module_to_program
    ).to_executorch(config=et_config)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/program/_program.py", line 107, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/program/_program.py", line 1558, in to_executorch
    return ExecutorchProgramManager(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/program/_program.py", line 1621, in __init__
    self._pte_data, self._tensor_data = serialize_for_executorch(
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/_serialize/_serialize.py", line 50, in serialize_for_executorch
    pte: Cord = _serialize_pte_binary(
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/_serialize/_program.py", line 488, in serialize_pte_binary
    result: _FlatbufferResult = _program_json_to_flatbuffer(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/executorch/exir/_serialize/_flatbuffer.py", line 313, in _program_json_to_flatbuffer
    raise RuntimeError(
RuntimeError: Failed to compile /var/folders/4n/g6_02f5x1mvdw88n7dtw15l80000gn/T/tmpx3xs7jk_/data.json to /var/folders/4n/g6_02f5x1mvdw88n7dtw15l80000gn/T/tmpx3xs7jk_/data.pte. Set ET_EXIR_SAVE_FLATC_INPUTS_ON_FAILURE=1 to save input files on failure.
[ 14%] Built target generated_pte_files
make: *** [all] Error 2

Versions

Collecting environment information...
PyTorch version: 2.8.0.dev20250325
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 15.3.2 (arm64)
GCC version: Could not collect
Clang version: 16.0.0 (clang-1600.0.26.6)
CMake version: version 3.31.6
Libc version: N/A

Python version: 3.11.11 (main, Dec 11 2024, 10:25:04) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-15.3.2-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M4 Max

Versions of relevant libraries:
[pip3] executorch==0.7.0a0+09d28bb
[pip3] numpy==2.2.4
[pip3] pytorch_tokenizers==0.1.0
[pip3] torch==2.8.0.dev20250325
[pip3] torchao==0.11.0+git9516764a
[pip3] torchaudio==2.6.0.dev20250325
[pip3] torchsr==1.0.4
[pip3] torchvision==0.22.0.dev20250325
[conda] executorch                0.7.0a0+09d28bb          pypi_0    pypi
[conda] numpy                     2.2.4                    pypi_0    pypi
[conda] pytorch-tokenizers        0.1.0                    pypi_0    pypi
[conda] torch                     2.8.0.dev20250325          pypi_0    pypi
[conda] torchao                   0.11.0+git9516764a          pypi_0    pypi
[conda] torchaudio                2.6.0.dev20250325          pypi_0    pypi
[conda] torchsr                   1.0.4                    pypi_0    pypi
[conda] torchvision               0.22.0.dev20250325          pypi_0    pypi

cc @jathu

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: build/installIssues related to the cmake and buck2 builds, and to installing ExecuTorch

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions