Metal Backend Support#40
Open
atticus-lv wants to merge 3 commits into
Open
Conversation
Add device-aware backend selection so Kimodo runs on Apple Silicon (MPS) in addition to CUDA/CPU. Ported from tdw46's kimodo-metal-mps-support fork (MPS portions of commit d0c7736 only; the Beyond Motion / f2llm encoder swap and unrelated docs/benchmark edits are intentionally excluded). - device_utils: resolve_torch_device (auto -> cuda > mps > cpu, with graceful fallback) and preferred_text_encoder_dtype (float16 on MPS, bfloat16 otherwise, override-able via TEXT_ENCODER_DTYPE) - kimodo_model: coerce stray fp64 buffers/params to fp32 on MPS (MPS cannot materialize float64) and align text features to the denoiser dtype - skeleton/base: MPS-safe .to() that keeps fp64 -> fp32 - llm2vec: resolve device via device_utils; skip the CUDA multiprocessing branch for non-CUDA devices - load_model: device-aware text-encoder dtype while preserving the existing text_encoder_fp32 override precedence (default encoder left as llm2vec) - generate.py: add --device (auto/cpu/cuda/cuda:0/mps); demo app auto-resolves - model: export AutoEmbeddingEncoder
The motion_correction C++ extension assumed an x86 + GCC toolchain and could not build on Apple Silicon (or under clang generally): - CMakeLists passed x86-only -msse4.1/-mavx, which clang rejects on arm64 - Compiler.h never defined FORCE_INLINE for clang (only MSVC/GCC) - the Vector/SIMD math core is SSE-intrinsic only, with no NEON path Guard the SIMD compile flags by target architecture, add the clang branch for FORCE_INLINE, and have setup.py auto-skip the (optional) native extension on non-x86 targets, where kimodo falls back to the pure-Python postprocessing path. Set FORCE_MOTION_CORRECTION_BUILD=1 to override.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref #3 , this pr also modify the python part for device check
A blender addon repo for testing
2026-06-17.17-27-25.mp4