Text-to-Image
MLX
MiniMax H3
Safetensors
English
apple-silicon
macos
image-to-image
image-editing
image-generation
Instructions to use devin-lai/MiniMax-H3-Image-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use devin-lai/MiniMax-H3-Image-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download devin-lai/MiniMax-H3-Image-mlx --local-dir MiniMax-H3-Image-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download tests/test_preconverted.py from devin-lai/MiniMax-H3-Image-mlx: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/devin-lai/MiniMax-H3-Image-mlx/resolve/refs%2Fpr%2F1/tests/test_preconverted.py
- Command line
-
hf download hf://devin-lai/MiniMax-H3-Image-mlx@refs/pr/1/tests/test_preconverted.py
-
curl -L -o test_preconverted.py https://huggingface.co/devin-lai/MiniMax-H3-Image-mlx/resolve/refs%2Fpr%2F1/tests/test_preconverted.py
1.87 kB
| import json | |
| import mlx.core as mx | |
| import numpy as np | |
| import pytest | |
| from h3_mlx.config import DiTConfig | |
| from h3_mlx.dit import DiTBlock | |
| from h3_mlx.weights import Linear, WeightStore | |
| def test_preconverted_quantized_linear_loads_without_online_quantization( | |
| tmp_path, monkeypatch, bits, word | |
| ): | |
| # Fixed synthetic quantized matrix: each decoded weight is 0.5. | |
| tensors = { | |
| "proj.weight": mx.full((4, 64 // (32 // bits)), word, mx.uint32), | |
| "proj.scales": mx.full((4, 1), 0.5, mx.bfloat16), | |
| "proj.biases": mx.zeros((4, 1), mx.bfloat16), | |
| "proj.bias": mx.array([0, 0.25, 0.5, 1], mx.bfloat16), | |
| } | |
| mx.save_safetensors(str(tmp_path / "core.safetensors"), tensors) | |
| (tmp_path / "quantization.json").write_text( | |
| json.dumps({"bits": bits, "group_size": 64}) | |
| ) | |
| def forbidden(*args, **kwargs): | |
| pytest.fail("Inference must never quantize weights") | |
| monkeypatch.setattr(mx, "quantize", forbidden) | |
| layer = Linear.load(WeightStore(tmp_path), "proj") | |
| x = mx.ones((3, 64), mx.bfloat16) | |
| expected = mx.array([[32, 32.25, 32.5, 33]] * 3, mx.bfloat16) | |
| np.testing.assert_array_equal( | |
| np.asarray(layer(x).view(mx.uint16)), np.asarray(expected.view(mx.uint16)) | |
| ) | |
| def test_missing_packed_block_cannot_trigger_conversion(tmp_path): | |
| class NormStore: | |
| def get(self, key): | |
| assert ( | |
| key.endswith("norm1.weight") | |
| or key.endswith("norm2.weight") | |
| or key.endswith("_norm.weight") | |
| ) | |
| return mx.ones(32, mx.bfloat16) | |
| missing = tmp_path / "missing" | |
| with pytest.raises(FileNotFoundError, match="preconverted"): | |
| DiTBlock(NormStore(), "blocks.0", DiTConfig(), packed_cache=missing) | |
| assert not missing.exists() | |