Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio MLX convert: pack 3 / 5 / 6-bit codes from Fortran-order or strided arrays (#17082)
Daniel Han750d728b91a6
diff --git a/studio/backend/core/inference/mlx_diffusion_convert.py b/studio/backend/core/inference/mlx_diffusion_convert.pyindex c73047d62a3..317938671b7 100644--- a/studio/backend/core/inference/mlx_diffusion_convert.py+++ b/studio/backend/core/inference/mlx_diffusion_convert.py@@ -139,7 +139,9 @@ def _pack(q: np.ndarray, bits: int) -> np.ndarray:# 8 elements = `bits` bytes: the low bytes of a little-endian uint64.for start in range(0, rows, _ROW_CHUNK):lanes = q[start : start + _ROW_CHUNK].reshape(-1, cols // 8, 8)- acc = lanes[..., 0].astype("<u8")+ acc = lanes[..., 0].astype(+ "<u8", order = "C"+ ) # C order: the byte view below needs a contiguous last axisfor k in range(1, 8):acc |= lanes[..., k].astype("<u8") << np.uint64(bits * k)stream[start : start + _ROW_CHUNK] = (diff --git a/studio/backend/tests/test_mlx_diffusion_convert.py b/studio/backend/tests/test_mlx_diffusion_convert.pyindex 0a0a15a17ee..36f9f01a838 100644--- a/studio/backend/tests/test_mlx_diffusion_convert.py+++ b/studio/backend/tests/test_mlx_diffusion_convert.py@@ -187,6 +187,14 @@ def test_pack_is_byte_identical_to_the_reference(bits, dtype):assert conv._pack(edge, bits).tobytes() == _pack_reference(edge, bits).tobytes()[email protected]("bits", [2, 3, 4, 5, 6, 8])+def test_pack_takes_fortran_order_and_strided_inputs(bits):+ q = _rng(bits).integers(0, 1 << bits, size = (300, 64), dtype = np.uint8)+ ref = _pack_reference(q, bits).tobytes()+ assert conv._pack(np.asfortranarray(q), bits).tobytes() == ref+ assert conv._pack(np.ascontiguousarray(q.T).T, bits).tobytes() == ref++@pytest.mark.parametrize("bits", [4, 8])def test_pack_does_not_widen_to_uint32_per_element(bits):import tracemalloc