Repository navigation
Add Inkling 2 model - #2061
Add Inkling 2 model#2061jundot wants to merge 7 commits into
Conversation
Text and image input, with Metal kernels for the prefill attention and the attention residuals. The published checkpoint loads as is, and tensor and pipeline parallel work.
Split the model file into config, layers, vision, checkpoint and model modules, and move the processor and the two kernels into the package. The processor now returns a dict of inputs, as load_processor expects, and the image rows use the shared splice. The model code is otherwise unchanged.
|
Updated this PR for the new models layout in #2082. I moved Inkling 2 into a package with config, layers, vision, checkpoint, model, kernels and processor modules. The processor now returns a dict of inputs, and the image rows use the shared splice. The model code is otherwise unchanged. |
The public checkpoints declare their quantization, so load_model sets up the experts and sanitize only maps the tensors. load_model also reads fp8 with 1x32 ue8m0 blocks as mxfp8, as in Inkling-2-Small-MXFP8.
|
The experts now load through load_model, since the public checkpoints declare their quantization. Sanitize only maps the tensors. load_model also reads fp8 with 1x32 ue8m0 blocks as mxfp8, which Inkling-2-Small-MXFP8 uses. |
|
@jundot While testing LORA back propagation for a local RL harness with Inkling, I reproduced a failure: ValueError: [gather_axis] Cannot calculate VJP with respect to indices. Use stop_gradient on indices to stop gradients from being computed. Adding indices = Would you like me to open a pr against the inkling2 branch? |
Co-authored-by: Brendan Boyle <1395328+brendanboyle87@users.noreply.github.com>
|
Thanks @brendanboyle87, I could reproduce it. Added the stop_gradient here with you as co-author, and skipped the custom kernels in training mode (no vjp). Mini needed one more fix, that's in #2086. |
* This is a draft because of the open PR limit. I will mark it ready for review once my other open PRs are merged.
Text and image input. The published NVFP4 checkpoint loads as is, and tensor and pipeline parallel work. DSpark is not included.
Images and kernels follow the same structure as Muse Spark Open. The image processor and the kernels are in the inkling2 package.
Two new kernels. relative_attention is the prefill attention with the relative position bias and the per-token sink, which MLX SDPA does not take. depth_attention mixes the attention residual blocks. Without them the model runs plain MLX ops.
M3 Ultra with 512 GB. Each number is the mean of two runs with 128 generated tokens.
Without the kernels the 16k prefill also takes 24 GB more memory.
Benchmark script
The kernels are off when inkling2.layers._use_kernels returns False. The prompt text is Moby-Dick from Project Gutenberg.
Model information
Supported checkpoints
Verification
mlx_lm.generate --model thinkingmachines/Inkling-2-Small -p "The secret to baking a good cake is" -m 1024