Metal backend: exported `.pte` does not load outside a process that already has PyTorch's libomp (embedded AOTI object links `/opt/llvm-openmp/lib/libomp.dylib`)
I maintainer di solito rispondono entro 1 giorno
@metascroy ci sta già lavorando.
Dal 21/9/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- build-system, embedded-iot, machine-learning, mobile-dev
Direzione di ricerca
Start with metal_backend.cpp around line 352 and the MetalBackend.codesign_so path, then inspect run_metal_test.sh's existing library-reference rewrite. Reproduce export and loading outside executor_runner, and determine whether the accepted fix should remove unused dependencies or reject unsupported ones at export time. Done means the chosen behavior is verified for an app without PyTorch's libomp.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
A Metal .pte loads under executor_runner built by run_metal_test.sh, but fails in an application that links the ExecuTorch runtime on its own:
E executorch:metal_backend.cpp:352] Failed to load shared library: dlopen(.../<hash>_so_blob<pid>.so, 0x0005):
Library not loaded: /opt/llvm-openmp/lib/libomp.dylib
E executorch:method.cpp:132] Init failed for backend MetalBackend: 0x22
Cause
On macOS inductor's _get_openmp_args always adds -lomp. The libomp it resolves is the one bundled in the PyTorch wheel (torch/lib/libomp.dylib), whose LC_ID_DYLIB is the absolute path /opt/llvm-openmp/lib/libomp.dylib, and that path is recorded as a dependency of the AOTI object embedded in the .pte. The path exists on no end-user machine.
It goes unnoticed in-tree because run_metal_test.sh already rewrites the same reference in executor_runner to @rpath/libomp.dylib with an rpath into torch/lib. The runner therefore loads PyTorch's libomp first, and dyld then satisfies the model's dependency by install name. An app that ships its own libomp (or none) has no image with that install name loaded, so dlopen fails.
The dependency is not used: nm -u on the embedded object shows no omp / kmp symbol for a Metal-delegated MobileNet, as expected for a graph that runs on the GPU.
Possible directions
- Link the AOTI object with
-Wl,-dead_strip_dylibsfor the Metal backend, so dylibs the object does not reference are dropped and libomp stays only if a model really needs it. Inductor has no option for extra link flags today; we do it from outside by pointingtorch._inductor.config.cpp.cxxat a wrapper compiler that appends the flag on link steps. The resulting object links onlylibc++andlibSystemand loads in a process with no libomp at all. - Independently, a check next to
MetalBackend.codesign_sothat the compiled object has no dependency outside/usr/liband/Systemwould turn this from a load-time surprise on someone else's machine into an export-time error.
Happy to send a PR for the check if that direction sounds right; the link-flag part probably belongs in inductor.
- Lingua principale
- Python
- Stelle
- 5k
- Fork
- 1.2k
- Merge medio
- 2g 9h
- PR unite (30g)
- 555
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytorch/executorch
-
enhancement triaged
Difficoltà 2/5 Mezza giornata Idoneità per principianti 68/100
pytorch/executorch#21640 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement module: examples
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
pytorch/executorch#23164 · 7 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Qualcomm: 8-bit per-channel weight scales are floored at the 16-bit eps, and the HTP miscomputes near-zero channelsForse già presa @psiddh l’ha presa 1 giorno fa. Apertamodule: qnn partner: qualcomm
pytorch/executorch#23160 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[cpu kernels] native_layer_norm: layer_norm_scalar returns NaN on large-mean rows; Half/BF16 at N>=256 slow after #23153Forse già presa @JakeStevens l’ha presa 1 giorno fa. Apertamodule: kernels
pytorch/executorch#23159 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
module: vulkan
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
pytorch/executorch#23158 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pytorch/executorch
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
solana-foundation/pay-kit#341 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nasa/python_cmr#123 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
EleutherAI/lm-evaluation-harness#4243 ·
I maintainer di solito rispondono entro 1 giorno
-
area: dashboard bug perceived difficulty: 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Nitjsefnie-Harness-Commons/daedalus#1179 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
cusp-ai-oss/tojax#17 ·