Image-Text-to-Text
MLX
Safetensors
diffusion_gemma
turboquant
Mixture of Experts
diffusion
block-diffusion
conversational
Instructions to use manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32 with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32") config = load_config("manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32 with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32
Run Hermes
hermes
- OpenClaw new
How to use manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "manjunathshiva/diffusiongemma-26B-A4B-it-tq3-g32" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
| """Speed patch for PolarQuantizedSwitchLinear at canvas/batch scale. | |
| DiffusionGemma denoising pushes ~2048 (token, expert) routings per switch call | |
| (256-token canvas x top-8). polar_multi_gather_qmv re-reads the input vector | |
| from global memory once per output row, which is ~33 ms/call at that scale. | |
| This patch routes large-N batched calls to: fused Metal dequant (packed tq -> | |
| fp16, one thread per quant group, pure bandwidth) + mx.gather_mm. ~10 ms/call. | |
| Decode-scale calls (n_tokens==1 or small k) keep the existing fused kernels. | |
| Usage: from fast_switch_patch import patch_switch_fast; patch_switch_fast() | |
| """ | |
| import math | |
| import mlx.core as mx | |
| from turboquant_mlx.layers.polar_switch_linear import PolarQuantizedSwitchLinear | |
| from turboquant_mlx.core.rotation import rotate_input | |
| # Above this many (token, expert) routings, dequant+gather_mm beats the | |
| # per-row gather kernels (measured crossover is well below canvas scale). | |
| LARGE_N_THRESHOLD = 512 | |
| _kernel_cache: dict[tuple[int, int], object] = {} | |
| def _get_dequant_kernel(bits: int, group_size: int): | |
| """One thread per (expert, row, group): unpack + codebook + scale -> fp16.""" | |
| key = (bits, group_size) | |
| if key in _kernel_cache: | |
| return _kernel_cache[key] | |
| n_codes = 1 << bits | |
| elems_per_u32 = 32 // bits | |
| mask = (1 << bits) - 1 | |
| source = f""" | |
| uint gid = thread_position_in_grid.x; | |
| uint n_groups = scales_shape[2]; | |
| uint out_rows = scales_shape[1]; | |
| uint pw_cols = packed_weight_shape[2]; | |
| uint in_dims = n_groups * {group_size}u; | |
| uint total = scales_shape[0] * out_rows * n_groups; | |
| if (gid >= total) return; | |
| uint g = gid % n_groups; | |
| uint row = (gid / n_groups) % out_rows; | |
| uint e = gid / (n_groups * out_rows); | |
| float cb[{n_codes}]; | |
| for (uint i = 0; i < {n_codes}u; i++) {{ cb[i] = float(codebook[i]); }} | |
| float scale = float(scales[gid]); | |
| uint pw_base = (e * out_rows + row) * pw_cols; | |
| uint out_base = (e * out_rows + row) * in_dims + g * {group_size}u; | |
| for (uint t = 0; t < {group_size}u; t++) {{ | |
| uint col = g * {group_size}u + t; | |
| uint word = packed_weight[pw_base + col / {elems_per_u32}u]; | |
| uint code = (word >> ((col % {elems_per_u32}u) * {bits}u)) & {mask}u; | |
| out[out_base + t] = T(cb[code] * scale); | |
| }} | |
| """ | |
| _kernel_cache[key] = mx.fast.metal_kernel( | |
| name=f"polar_dequant_experts_{bits}bit_gs{group_size}", | |
| input_names=["packed_weight", "scales", "codebook"], | |
| output_names=["out"], | |
| source=source, | |
| ensure_row_contiguous=True, | |
| ) | |
| return _kernel_cache[key] | |
| def dequant_experts_fast(layer: PolarQuantizedSwitchLinear) -> mx.array: | |
| """(num_experts, output_dims, input_dims) fp16 via the fused Metal kernel.""" | |
| kernel = _get_dequant_kernel(layer.bits, layer.group_size) | |
| e, o = layer.num_experts, layer.output_dims | |
| n_groups = layer.input_dims // layer.group_size | |
| total = e * o * n_groups | |
| return kernel( | |
| inputs=[layer.weight, layer.scales, layer.codebook], | |
| template=[("T", layer.scales.dtype)], | |
| grid=(total, 1, 1), | |
| threadgroup=(256, 1, 1), | |
| output_shapes=[(e, o, layer.input_dims)], | |
| output_dtypes=[layer.scales.dtype], | |
| )[0] | |
| _orig_call = PolarQuantizedSwitchLinear.__call__ | |
| def _patched_call(self, x, indices, sorted_indices=False): | |
| n_tokens = 1 if x.ndim <= 2 else math.prod(x.shape[:-2]) | |
| k = indices.shape[-1] if indices.ndim >= 1 else 1 | |
| # Canvas/prefill scale: fused dequant + native gather_mm. | |
| if (n_tokens == k and k >= LARGE_N_THRESHOLD) or ( | |
| n_tokens != 1 and n_tokens != k | |
| ): | |
| if self._needs_rotation: | |
| x = rotate_input(x, self.signs) | |
| w_deq = dequant_experts_fast(self) | |
| y = mx.gather_mm( | |
| x, | |
| w_deq.swapaxes(-1, -2), | |
| rhs_indices=indices, | |
| sorted_indices=sorted_indices, | |
| ) | |
| if "bias" in self: | |
| y = y + mx.expand_dims(self["bias"][indices], -2) | |
| return y | |
| return _orig_call(self, x, indices, sorted_indices=sorted_indices) | |
| def patch_switch_fast(): | |
| PolarQuantizedSwitchLinear.__call__ = _patched_call | |
| print(f"[INFO] fast-switch patch active (threshold={LARGE_N_THRESHOLD} routings)") | |