model-authoring

Guidance for writing PyTorch models that run on Apple devices through Core AI, Apple’s system for compiling and executing machine-learning models. It covers device execution, efficient inference, scalable computation, and correctness testing.

In plain words
What is it for?
Use it when writing, debugging, or reviewing PyTorch models intended for on-device Apple execution, including language, vision, audio, and diffusion models.
Why use it?
Models that work in ordinary PyTorch may compile or behave differently on device hardware. These rules help developers account for Apple Neural Engine and GPU behavior when authoring or debugging models.

Skill for Claude CodeCodex

Part of the coreai-skills plugin — 3 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/apple/coreai-models/model-authoring
Any agent
npx skills add apple/coreai-models --skill model-authoring
Clone the repo
git clone --depth 1 https://github.com/apple/coreai-models

Made for: Claude Code, Codex.

Or install coreai-skills, the plugin that ships this one along with the rest of its 3 skills.

Per session 95 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,084 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00095 $0.02084
Opus 5 $0.00048 $0.01042
Sonnet 5 $0.00019 $0.00417
Haiku 4.5 $0.00010 $0.00208

Measured 3d ago against content hash 0786578f0fd3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

model-authoring 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 3d 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.

skills/skills/model-authoring/SKILL.md · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Model Authoring

This skill contains the hard-won empirical knowledge for making PyTorch models compile and run correctly on Apple hardware via Core AI. The rules here are stable across Core AI releases — they reflect hardware behavior, not API shapes.

Reference material

Use these resources on-demand — do not read all files upfront. Consult the relevant reference when the user's task requires specific patterns for a target platform, or when debugging.

Resource When to consult
neural_engine_rules.md Neural Engine patterns: BC1S layout, Conv2d projections, per-head attention, KV cache readonly pattern, stride/dilation/pooling rules, causal mask, RoPE, chunked prefill
gpu_rules.md GPU patterns: fused QKV, native SDPA, KV cache stateful pattern, MoE (GatherMM/SwitchLinear), memory-efficient loading, RMSNorm variants
common_issues.md Debugging: PSNR issues, compilation errors, runtime problems, stale flags
coreai-models repo Complete working reference implementations for LLMs, vision, audio, diffusion. Explore primitives/ and models/ directories.

coreai-models: working reference implementations

For complex models (LLMs, MoE, multimodal, diffusion), explore the coreai-models repo before writing primitives from scratch. It has complete authoring primitives for both GPU and Neural Engine, including advanced patterns like iOS embedding quantization, MoE routing, and memory-efficient weight loading for large models. If the user has a local clone, explore it directly. If not, suggest cloning it.

Online docs: coreai-torch composite ops | externalization | composite ops API

Read the full file on GitHub · 154 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3d ago First seen · 154 lines · 95 tokens per session scan A 0786578f0fd3

Subscribe to this mod's changes

model-authoring is a skill published in the GitHub repository apple/coreai-models (2,037 stars, last pushed yesterday), licensed BSD-3-Clause. It adds 95 tokens to every session and 2,084 once invoked, about $0.0005 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

ai-model-wechat

Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, 企业微信小程序, wx.cloud apps). Features generateText and streamText with callbacks (onText, onEvent, onFinish). Models via wx.cloud.extend.AI.createModel with groups hunyuan-exp (小程序成长计划), cloudbase (main managed), or custom-. Model IDs…

TencentCloudBase/CloudBase-AI-Toolkit · 254 tokens

firebase-ai

Use when setting up firebaseai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors.

evanca/flutter-ai-rules · 30 tokens

litert-compiled-model-migration

Rapidly migrate an Android application from legacy TensorFlow Lite (TFLite) to modern LiteRT CompiledModel API v2.1.6 in Open Source GitHub repositories. Supports True Async Execution (runAsync), Zero-Copy I/O Buffers, NPU JIT compilation, and automated 2-stage verification self-testing.

google-ai-edge/litert-samples · 76 tokens

foundation-models

On-device LLM integration using Apple's Foundation Models framework. Use when implementing AI text generation, structured output, or tool calling.

rshankras/claude-code-apple-skills · 29 tokens

core-ml

Core ML, Create ML, Vision framework, Natural Language framework, on-device ML integration. Use when user wants image classification, text analysis, object detection, sound classification, model optimization, or custom model integration. Covers Core ML vs Foundation Models decision.

rshankras/claude-code-apple-skills · 54 tokens

maui-essentials-ai

Adopt Microsoft.Maui.Essentials.AI for local/on-device MAUI AI. USE FOR: Apple Intelligence AppleIntelligenceChatClient as IChatClient, iOS/macOS/Mac Catalyst 26+ checks, fallback UI, NLEmbeddingGenerator semantic search, local UseFunctionInvocation tools, privacy/offline UX. DO NOT USE FOR: source-generated tools…

dotnet/maui-labs · 108 tokens