Commit a3f8e58
authored
refactor(core): split mlx_cxx_bridge.cpp by domain; bump mlxcel-core 0.2.0 (#277)
The cxx bridge implementation had grown to 6367 lines in one file. Split the
cleanly-separable specialized blocks into their own translation units, sharing
the few cross-domain helpers (to_shape/to_dtype/from_dtype/gelu_tanh_approx)
via a new mlx_cxx_internal.h. The cxx FFI free functions stay callable across
TUs through the generated header, so only those file-local helpers needed
promotion; no behavior change.
- cpp/mlx_cxx_internal.h: shared MLX/std includes + the dtype/shape helpers.
- cpp/mlx_cxx_kernels.cpp: fused single-token decode Metal kernels (Mamba2/SSM,
GatedDeltaNet, decode-MoE).
- cpp/mlx_cxx_nemotron.cpp: NemotronH full-forward decode.
- cpp/mlx_cxx_ext.cpp: native safetensors loading + Metal 4 / turbo / paged
fused-attention launchers.
- cpp/mlx_cxx_bridge.cpp: the remaining general FFI surface, 6367 -> 4616 lines.
build.rs compiles the new files (it already built multiple .cpp via
cxx_build::bridge). mlxcel-core bumped 0.1.0 -> 0.2.0.
Validated: release build clean (fmt + clippy), greedy temp-0 output unchanged
on qwen3-30b-a3b (incl. MLXCEL_FUSED_MOE, the moved kernels) and nemotron-h-30b
(the moved full-forward + SSM/MoE kernels). The remaining bridge.cpp bulk
(ops/quant/norm-rope/attention/activation) is heavily interleaved by domain;
further extraction can follow.1 parent 65abbd5 commit a3f8e58
8 files changed
Lines changed: 1818 additions & 1757 deletions
File tree
- src/lib/mlxcel-core
- cpp
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
| 135 | + | |
128 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
129 | 140 | | |
130 | 141 | | |
131 | 142 | | |
| |||
0 commit comments