mflux: Skill for Cursor

.cursor/skills/mflux-model-porting/SKILL.md

mflux-model-porting is a skill for Cursor from mflux-community/mflux. It costs 28 tokens per session (3,633 once invoked), scanned A, original, MIT.

A workflow for porting machine-learning models into mflux using MLX, Apple's framework for machine learning on Apple silicon. It prioritizes matching the reference model and proving correctness before optimization.

In plain words
What is it for?
Use it to define output, speed, and memory targets; port a model from a reference implementation; validate results; and then refactor or optimize the MLX version.
Why use it?
It reduces the risk of producing a faster implementation that gives incorrect results by requiring parity checks and deterministic tests first.

Skill for Cursor

Written for Cursor: installed under .cursor/.

This is mflux-community/mflux's own configuration. It tells Cursor how to work on mflux itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mflux configures →

About the project

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.

mflux-community/mflux · 2,316 stars · on GitHub

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/mflux-community/mflux/main/.cursor/skills/mflux-model-porting/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/mflux-community/mflux

Made for: Cursor.

Wrote 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.

agentmods badge for mflux-model-porting

README.md
[![agentmods](https://agentmods.dev/badge/skills/mflux-community/mflux/mflux-model-porting/github.svg)](https://agentmods.dev/skills/mflux-community/mflux/mflux-model-porting)
Your own site
<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.

agentmods 80×15 button for mflux-model-porting

Your own site · 80×15
<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>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,633 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 10d ago against content hash 9c4076e56d30, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

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.

.cursor/skills/mflux-model-porting/SKILL.md · 192 lines

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)

  1. 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.
  2. 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_turbo and flux2_klein for 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.compile and 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.load at critical points; it is OK to add these to the reference (without changing logic) to export latents.
  3. 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.
  4. 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.
  5. 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-dir work; pass a latent_creator that supports unpack_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_latents helper, no verbose comments/docstrings (see repo RULE.md).
    • Strip dead scaffolding (e.g. unused gradient-checkpointing flags) once training/inference paths are stable.
  6. Pre-merge polish (after core port works)
    • diffusers sanity check: run matched mflux + diffusers generations; use mflux-debugging latent 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_latents must accept the 5D (B, C, 1, H, W) tensor that tiled VAE encode (vae_encode_tiled) returns — squeeze the singleton temporal axis first, as flux2/fibo/z_image latent creators do; a 4D-only unpack (or a bare passthrough pack_latents) breaks tiled img2img. This is reachable via --low-ram: MemorySaver sets tiling_config = TilingConfig() (vae_encode_tiled=True), so always test img2img with --low-ram, not just the default path (which is safe only because VAEUtil.encode squeezes 5D→4D when tiling is off).
    • Cross-model touch points: list every file outside models/<your_model>/; justify shared changes (memory_saver tiling guard, shared VAE tiling_config, training runner wiring). Drop unrelated edits (e.g. personal .gitignore entries).
    • 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 du on HF cache and/or mflux-save + du -sh for 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.
  7. 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:
      • ModelConfig entry + 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.

Read the full file on GitHub · 192 lines

Changes

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.

  1. 10d ago First seen · 192 lines · 28 tokens per session scan A 9c4076e56d30

Subscribe to this mod's changes

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.

Related

Other skills, from other repositories

dataset-discovery

Multi-source ML dataset discovery.

LigphiDonk/Oh-my--paper · 10 tokens

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.

ascend-ai-coding/awesome-ascend-skills · 134 tokens

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.

ascend-ai-coding/awesome-ascend-skills · 76 tokens

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.

davila7/claude-code-templates · 83 tokens

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.

davila7/claude-code-templates · 48 tokens

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.

davila7/claude-code-templates · 76 tokens