mlx-jax-splitmix
БесплатноБез исполняемых скриптовНе проверенMLX on Apple Silicon with JAX-style SplitMix64 PRNG. Deterministic color generation with GPU acceleration.
от plurigrid★ 73 звезды на GitHubОб этом скилле
MLX + JAX SplitMix64 Skill
"Same seed, same colors — whether on CPU, GPU, or across machines."
1. Core Insight
JAX's PRNG design is functional and splittable — perfect for Gay.jl's deterministic coloring:
JAX: key, subkey = jax.random.split(key)
Gay: seed₂ = splitmix64(seed₁)
MLX brings this to Apple Silicon with native GPU acceleration.
2. SplitMix64 in JAX/MLX
import jax
import jax.numpy as jnp
from functools import partial
# SplitMix64 constants (same as Gay.jl)
GOLDEN = jnp.uint64(0x9E3779B97F4A7C15)
MIX1 = jnp.uint64(0xBF58476D1CE4E5B9)
MIX2 = jnp.uint64(0x94D049BB133111EB)
@jax.jit
def splitmix64(z: jnp.uint64) -> jnp.uint64:
"""Pure functional SplitMix64 - JIT compiled."""
z = z + GOLDEN
z = (z ^ (z >> 30)) * MIX1
z = (z ^ (z >> 27)) * MIX2
return z ^ (z >> 31)
@jax.jit
def seed_to_trit(seed: jnp.uint64) -> jnp.int8:
"""GF(3) trit: {-1, 0, +1}."""
return jnp.int8((seed % 3) - 1)
@jax.jit
def seed_to_hue(seed: jnp.uint64) -> jnp.float32:
"""Hue in [0, 360)."""
return jnp.float32(seed % 360)
# Vectorized version for batch processing
splitmix64_batch = jax.vmap(splitmix64)
seed_to_trit_batch = jax.vmap(seed_to_trit)
3. MLX Implementation
import mlx.core as mx
# MLX version (Apple Silicon optimized)
GOLDEN_MLX = mx.array(0x9E3779B97F4A7C15, dtype=mx.uint64)
MIX1_MLX = mx.array(0xBF58476D1CE4E5B9, dtype=mx.uint64)
MIX2_MLX = mx.array(0x94D049BB133111EB, dtype=mx.uint64)
def splitmix64_mlx(z: mx.array) -> mx.array:
"""SplitMix64 for MLX - runs on Apple GPU."""
z = z + GOLDEN_MLX
z = (z ^ (z >> 30)) * MIX1_MLX
z = (z ^ (z >> 27)) * MIX2_MLX
return z ^ (z >> 31)
def derive_chain_mlx(seed: int, length: int) -> mx.array:
"""Generate derivation chain on GPU."""
seeds = mx.zeros((length,), dtype=mx.uint64)
current = mx.array(seed, dtype=mx.uint64)
for i in range(length):
seeds[i] = current
current = splitmix64_mlx(current)
return seeds
4. JAX Key Splitting ↔ Gay.jl Derive
import jax.random as random
# JAX native key splitting
key = random.key(1069)
key1, key2, key3 = random.split(key, 3)
# Equivalent in SplitMix64 terms
seed = jnp.uint64(1069)
seed1 = splitmix64(seed ^ jnp.uint64(0)) # XOR with index
seed2 = splitmix64(seed ^ jnp.uint64(1))
seed3 = splitmix64(seed ^ jnp.uint64(2))
# Both approaches give deterministic, independent streams
5. GF(3) Conservation with JAX
@jax.jit
def check_gf3_conservation(seeds: jnp.ndarray) -> bool:
"""Check if sum of trits ≡ 0 (mod 3)."""
trits = seed_to_trit_batch(seeds)
return jnp.sum(trits) % 3 == 0
@jax.jit
def spawn_balanced_triad(base_seed: jnp.uint64) -> tuple:
"""Spawn a GF(3)-balanced triad."""
# Search for seeds that give each trit value
def find_trit(target_trit, start_offset):
def cond(state):
offset, found = state
seed = splitmix64(base_seed ^ jnp.uint64(offset))
return seed_to_trit(seed) != target_trit
def body(state):
offset, found = state
return (offset + 1, found)
final_offset, _ = jax.lax.while_loop(cond, body, (start_offset, False))
return splitmix64(base_seed ^ jnp.uint64(final_offset))
seed_minus = find_trit(-1, 0)
seed_zero = find_trit(0, 100)
seed_plus = find_trit(1, 200)
return seed_minus, seed_zero, seed_plus
6. Parallel Color Generation
import jax
from jax import pmap
# Multi-device parallel color generation
@partial(pmap, axis_name='devices')
def parallel_derive(seeds: jnp.ndarray, steps: int) -> jnp.ndarray:
"""Derive colors in parallel across devices."""
def step_fn(seed, _):
next_seed = splitmix64(seed)
return next_seed, seed_to_hue(seed)
_, hues = jax.lax.scan(step_fn, seeds, None, length=steps)
return hues
# Usage: colors on all available GPUs/TPUs
n_devices = jax.device_count()
seeds = jnp.array([1069 + i for i in range(n_devices)], dtype=jnp.uint64)
colors = parallel_derive(seeds, 100)
7. MLX + Neural Network Integration
import mlx.core as mx
import mlx.nn as nn
class ColorEmbedding(nn.Module):
"""Neural network with deterministic color seeds."""
def __init__(self, seed: int, dim: int = 64):
super().__init__()
self.seed = mx.array(seed, dtype=mx.uint64)
self.dim = dim
# Derive weight initialization seeds
w_seed = splitmix64_mlx(self.seed)
b_seed = splitmix64_mlx(w_seed)
# Initialize with deterministic random
mx.random.seed(int(w_seed.item()))
self.linear = nn.Linear(3, dim) # RGB input
def __call__(self, rgb: mx.array) -> mx.array:
"""Embed color into latent space."""
return self.linear(rgb)
def get_color_at(self, index: int) -> mx.array:
"""Get determin
Установить mlx-jax-splitmix в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл mlx-jax-splitmix?
MLX on Apple Silicon with JAX-style SplitMix64 PRNG. Deterministic color generation with GPU acceleration.
Как установить скилл mlx-jax-splitmix?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mlx-jax-splitmix запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic