export

A workflow stage for exporting a machine-learning model into a deployable format and checking that it still matches the original.

In plain words
What is it for?
Building static-shape ONNX files, validating them with ONNX Runtime, preparing language-model builds and tokenizers, and generating calibration data.
Why use it?
It creates the required model metadata and validation evidence while handling regular models, language models, and combined models differently.

Skill for Claude CodeCodex

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/axera-tech/magnetar/export
Any agent
npx skills add AXERA-TECH/Magnetar --skill export
Clone the repo
git clone --depth 1 https://github.com/AXERA-TECH/Magnetar

Made for: Claude Code, Codex.

Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 735 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.00035 $0.00735
Opus 5 $0.00017 $0.00367
Sonnet 5 $0.00007 $0.00147
Haiku 4.5 $0.00003 $0.00073

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

Security

Grade A, and why

export 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 2d 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.

.codex/skills/magnetar/hidden/export/SKILL.md · 46 lines

What it actually says

EXPORT

执行

MobileNet 可直接调用 sample = magnetar.stages.export.run_mobilenet(task_dir)。 其他模型需 Agent 自行实现:导出静态 ONNX → onnx.checker 验证 → ONNX Runtime 与原模型对分(cosine ≥ 0.99)→ 生成 model_meta.json 和校准数据。 校准数据尽量用真实业务数据run_generic(calibration_data=…)scripts/export_onnx.py --calib-dir); 随机/扰动数据仅兜底,需在 export_report.md 标注来源。

LLM 分支(model_route=llm,自回归/类 LLM 模型)

不导出 ONNX,改为:

  1. 验证 HuggingFace 权重可推理:跑通一次 source 生成(greedy),保存参考输出到 export/llm_reference.txt 或 npy;
  2. 生成可复现 export/llm_build.sh:完整 pulsar2 llm_build2 命令 (--input_path origin/<model> --output_path compile/llm_out --chip <chip> --max_context <LLM_MAX_CONTEXT> --prefill_len ... --weight_type s8|s4 --hidden_state_type bf16,Pulsar2 ≥ 6.0);
  3. 确认 tokenizer:origin 中已有 tokenizer.txt/*_tokenizer.txt 直接用; 没有则按 ax-llm 文档从 HF tokenizer 转换(third_party/tokenizer.axera 工具), 无法生成时 STOP 说明;
  4. 记录模型参数(model_type、num_hidden_layers、hidden_size、vocab_size、 tokenizer_type)到 export_report.md。

hybrid 组合模型(AR-TTS 等):LLM/AR 子模型按本分支准备,非 LLM 子模型 (vocoder/encoder 等)继续走本文件上方的通用 ONNX 导出,拆分开的产物分别记录。

验证

  • export/model.onnx 为静态 shape,onnxruntime 可加载
  • export/model_meta.json 含完整 input/output name/shape/dtype/layout
  • Torch/ONNX cosine ≥ 0.99
  • export/calib_data/input.tar.gz 存在(≥3 组样本)
  • export/export_report.md 标注校准来源(real 业务数据 / perturbed 兜底)
  • LLM 分支:export/llm_build.sh 存在且命令完整可复制;参考输出已保存; tokenizer 已确认

STOP

  • ONNX 对分失败(cosine < 0.99)
  • 模型含动态 shape 且静态化失败
  • 仅有随机/扰动校准数据且用户未确认(校准集应尽量用真实业务数据,随机数据可能在真实业务上崩)
  • LLM 分支:tokenizer 无法生成;llm_build2 不支持该架构且用户未确认回退方向
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. 2d ago First seen · 46 lines · 35 tokens per session scan A a429ff6f5251

Subscribe to this mod's changes

export is a skill published in the GitHub repository AXERA-TECH/Magnetar (22 stars, last pushed 19d ago), licensed MIT. It adds 35 tokens to every session and 735 once invoked, about $0.0002 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.