Text-to-Image
MLX
Safetensors
English
nemotron_h
apple-silicon
mac
autoregressive
mamba
Mixture of Experts
nemotron
nemotron-labs-image
q5
custom_code
Instructions to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit --local-dir Nemotron-Labs-Image-30B-A3B-MLX-5bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download code/scripts/probe_matmul_precision.py from VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/probe_matmul_precision.py
- Command line
-
hf download hf://VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/code/scripts/probe_matmul_precision.py
-
curl -L -o probe_matmul_precision.py https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/probe_matmul_precision.py
1.35 kB
| """Probe GEMM precision on this GPU: fp32 (TF32?) and bf16 accumulation, plain and quantized.""" | |
| import numpy as np, mlx.core as mx, os, json | |
| rng = np.random.default_rng(0) | |
| res = {"env_MLX_ENABLE_TF32": os.environ.get("MLX_ENABLE_TF32"), "arch": mx.device_info()["architecture"]} | |
| def bf(x): return np.array(mx.array(x).astype(mx.bfloat16).astype(mx.float32)) | |
| for (M, K, N) in [(1, 2688, 4096), (8, 2688, 4096), (300, 2688, 4096), (4096, 1024, 1024)]: | |
| a = rng.standard_normal((M, K)).astype(np.float32); b = (rng.standard_normal((K, N)) / np.sqrt(K)).astype(np.float32) | |
| ref = a.astype(np.float64) @ b.astype(np.float64) | |
| c32 = np.array(mx.matmul(mx.array(a), mx.array(b))) | |
| ab, bb = bf(a), bf(b) | |
| refb = ab.astype(np.float64) @ bb.astype(np.float64) # exact product of bf16 inputs | |
| cr = bf(refb.astype(np.float32)) # correctly rounded bf16 result | |
| c16 = np.array(mx.matmul(mx.array(a).astype(mx.bfloat16), mx.array(b).astype(mx.bfloat16)).astype(mx.float32)) | |
| res[f"{M}x{K}x{N}"] = { | |
| "fp32_rel_err": float(np.linalg.norm(c32 - ref) / np.linalg.norm(ref)), | |
| "bf16_rel_err_vs_exact_of_bf16_inputs": float(np.linalg.norm(c16 - refb) / np.linalg.norm(refb)), | |
| "bf16_frac_equal_to_correctly_rounded": float((c16 == cr).mean()), | |
| } | |
| print(json.dumps(res, indent=1)) | |