MFLUX is a native MLX implementation of generative image models that runs locally on Mac computers. It is for generating images with supported models through command-line tools or a Python API. The catalogue skills and instruction support workflows built around these image-generation models.
Borrowing it
Nothing to install: this file belongs to mflux-community/mflux. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/mflux-community/mflux/main/.cursor/skills/mflux-model-porting/SKILL.mdgit clone --depth 1 https://github.com/mflux-community/mfluxWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/mflux-community/mflux/mflux-model-porting)<a href="https://agentmods.dev/skills/mflux-community/mflux/mflux-model-porting"><img src="https://agentmods.dev/badge/skills/mflux-community/mflux/mflux-model-porting/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/mflux-community/mflux/mflux-model-porting"><img src="https://agentmods.dev/badge/skills/mflux-community/mflux/mflux-model-porting.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00028 | $0.03633 |
| Opus 5 | $0.00014 | $0.01817 |
| Sonnet 5 | $0.00006 | $0.00727 |
| Haiku 4.5 | $0.00003 | $0.00363 |
Grade A, and why
mflux-model-porting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 192 lines — stays where its author put it; the contents beside it link to each section on GitHub.
mflux model porting
Goal
Provide a repeatable, MLX-focused workflow for porting ML models (typically from diffusers repo located near mflux repo in the system) into mflux with correctness first, then refactor to mflux style.
Principles
- Match the reference implementation first; prove correctness before cleanup.
- Lock correctness with deterministic tests before refactoring.
- During the initial port, avoid premature performance work (e.g.,
mx.compile, kernel fusion tweaks, scheduler micro-optimizations); add optimizations only after correctness is locked. - Refactor toward shared components and clean APIs once tests are green.
- PyTorch and MLX RNGs are different; for strict parity checks, export the exact initial noise/latents from the reference and load them in MLX instead of relying on matching integer seeds.
Workflow (checklist)
- Scope and parity
- Define target parity (outputs, speed, memory) and acceptable tolerances.
- Identify reference files, configs, and checkpoints to mirror.
- Draft a Cursor plan for the port and review it before starting implementation.
- Port fast to reference
- Add the model package skeleton and a variant class + initializer.
- Follow standard mflux initializer/weight-loading style; review recent ports like
z_image_turboandflux2_kleinfor structure and naming. - Wire weight definitions/mappings early so loading is exercised (implement quantization in the initializer, but skip it during early runs).
- Keep the first implementation simple and explicit; defer
mx.compileand other speed-focused changes until deterministic parity is passing. - When defining explicit weight mappings, inspect actual tensor values from the model in the Hugging Face cache to confirm names and shapes.
- Add a minimal hardcoded runner for quick iteration (two tiny scripts: one in the reference repo, one in mflux), seeded with diffusers-style defaults (e.g., 1024×1024, default prompt).
- Add lightweight shape checks close to the code paths.
- Use
mx.save/mx.loadat critical points; it is OK to add these to the reference (without changing logic) to export latents.
- Port order (work backwards from image)
- Typical image generation flow:
prompt → text_encoder → transformer_loop → VAE → image. - For porting, invert the order so you can validate pixel space early.
- Start with VAE decode/encode to validate output images quickly:
- Export packed latents from the reference just before VAE decode.
- Load latents inline and decode to an image for visual inspection.
- Run an encode→decode roundtrip to sanity check reconstruction; a good-looking image reconstruction increases confidence in the implementation.
- Expect small numeric diffs in tensor values; when it is not clear from the numbers alone, always generate images and rely on human visual inspection to judge whether the match is acceptable.
- Then port the transformer loop and its schedulers with intermediate latent checks.
- If the reference uses a novel scheduler, port it; otherwise, reuse the existing mflux scheduler.
- Finish with the text encoder and tokenizer details.
- After each major component is validated (e.g., VAE, transformer, text encoder), commit with a clear milestone message like "VAE done" to preserve progress.
- Once the full port is working, remove any loaded tensors or debug artifacts so no traces remain.
- Typical image generation flow:
- Deterministic validation
- Create a deterministic MLX test (image or tensor) that locks the output.
- Run tests via
MFLUX_PRESERVE_TEST_OUTPUT=1 uv run <test command>. - If MLX OOMs on sensible inputs (e.g., 1024×1024), assume a likely porting mistake and re-check shapes or memory-heavy ops.
- Post-test refactor (explicit step)
- Review commits after the first deterministic test to capture refactoring preferences.
- Consolidate shared components into common modules.
- Remove debug paths and one-off schedulers once validated.
- Move configuration defaults into standard config/scheduler paths.
- Simplify and decompose large files into focused modules once behavior is locked.
- Prefer shared scheduler implementations when they already exist in mflux.
- Ensure CLIs register callbacks via
CallbackManager.register_callbacks(...)so shared features like--stepwise-image-output-dirwork; pass alatent_creatorthat supportsunpack_latents(...). - Keep running the deterministic image test during refactors to avoid regressions.
- Align the variant class with recent ports (
flux2_klein,z_image):prompt_cache, merged_predict, RoPE setup inside predict path,_decode_latentshelper, no verbose comments/docstrings (see repoRULE.md). - Strip dead scaffolding (e.g. unused gradient-checkpointing flags) once training/inference paths are stable.
- Pre-merge polish (after core port works)
- diffusers sanity check: run matched mflux + diffusers generations; use
mflux-debugginglatent injection if outputs disagree but you need to validate transformer/VAE. - Golden tests: pick prompt/seed/settings that are stable on target CI hardware; update reference PNGs only after explicit approval (see
mflux-testing). - img2img: verify latent packing/normalization on the img2img path matches txt2img and training (especially when reusing a shared VAE from another model family).
pack_latentsmust accept the 5D(B, C, 1, H, W)tensor that tiled VAE encode (vae_encode_tiled) returns — squeeze the singleton temporal axis first, asflux2/fibo/z_imagelatent creators do; a 4D-only unpack (or a bare passthroughpack_latents) breaks tiled img2img. This is reachable via--low-ram:MemorySaversetstiling_config = TilingConfig()(vae_encode_tiled=True), so always test img2img with--low-ram, not just the default path (which is safe only becauseVAEUtil.encodesqueezes 5D→4D when tiling is off). - Cross-model touch points: list every file outside
models/<your_model>/; justify shared changes (memory_savertiling guard, shared VAEtiling_config, trainingrunnerwiring). Drop unrelated edits (e.g. personal.gitignoreentries). - README: follow an existing model README structure (e.g. Flux2): hero image, turbo + base examples, feature section (img2img), disk-size warning, Notes, Training. Measure on-disk sizes with
duon HF cache and/ormflux-save+du -shfor quantized sizes. - Training: example JSON under
models/common/training/_example/, un-ignore in.gitignore, fast unit tests for training-adapter preview defaults. - Re-run
just lint,just test-fast, then slow golden tests before merge.
- diffusers sanity check: run matched mflux + diffusers generations; use
- Finalize
- Re-run tests and basic perf checks after polish.
- Add CLI/pipeline defaults and completions later, once core output is stable.
- Ensure the model is wired into the standard surfaces:
ModelConfigentry + aliases- Thin model CLI entrypoint that uses shared parser/config/callback patterns
- README following the structure and tone of existing model READMEs
- Python API example that matches the CLI/defaults
- Document any new mapping rules, shape constraints, or tolerances.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 10d ago First seen · 192 lines · 28 tokens per session scan A 9c4076e56d30
mflux-model-porting is a skill published in the GitHub repository mflux-community/mflux (2,316 stars, last pushed 7d ago), licensed MIT. It adds 28 tokens to every session and 3,633 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
dataset-discovery
Multi-source ML dataset discovery.
diffusers-ascend-pipeline
A guide for running image and video generation pipelines on Huawei Ascend NPUs with the Diffusers library. Diffusers is a software library for using generative models, and the guide covers model pipelines, memory settings, LoRA adapters, and multi-card inference.
diffusers-ascend-weight-prep
A model-weight preparation tool for Diffusers, a library for running image and other generative models, on Huawei Ascend NPU hardware. It downloads weights from Hugging Face or ModelScope and can create placeholder weights from configuration files for business testing.
quantizing-models-bitsandbytes
Quantizes LLMs to 8-bit or 4-bit for 50-75% memory reduction with minimal accuracy loss. Use when GPU memory is limited, need to fit larger models, or want faster inference. Supports INT8, NF4, FP4 formats, QLoRA training, and 8-bit optimizers. Works with HuggingFace Transformers.
gguf-quantization
GGUF format and llama.cpp quantization for efficient CPU/GPU inference. Use when deploying models on consumer hardware, Apple Silicon, or when needing flexible quantization from 2-8 bit without GPU requirements.
llama-cpp
Runs LLM inference on CPU, Apple Silicon, and consumer GPUs without NVIDIA hardware. Use for edge deployment, M1/M2/M3 Macs, AMD/Intel GPUs, or when CUDA is unavailable. Supports GGUF quantization (1.5-8 bit) for reduced memory and 4-10× speedup vs PyTorch on CPU.