x5-qat-adaptation
Skill1 starsChanged 3 months agoApache-2.0View on GitHub
将浮点 PyTorch 模型适配为 X5 Plugin QAT 模型;当需要设置 March.BAYES_E、量化边界、可量化算子、prepare 和 fake-quant 状态入口时使用。只处理 horizon_plugin_pytorch,不处理 HAT 或 J5 March.BAYES。
In this repository59 other files it gives its agents.
- bsp-bootloader-buildSkill
- bsp-deb-buildSkill
- bsp-env-setupSkill
- bsp-image-buildSkill
- bsp-kernel-buildSkill
- bsp-rootfs-customSkill
- bsp-source-syncSkill
- bsp-s-seriesSkill
- hmct-workflowSkill
- horizon-routerSkill
- ucpSkill
- x5-accuracy-diagnosticsSkill
- x5-board-monitorSkill
- x5-bpu-python-apiSkill
- x5-calibration-data-prepareSkill
- x5-consistency-diagnosticsSkill
- x5-environment-installSkill
- x5-environment-probeSkill
- x5-environment-setupSkill
- x5-model-diagnosticsSkill
- x5-model-preflightSkill
- x5-performance-diagnosticsSkill
- x5-ptq-compileSkill
- x5-ptq-config-authoringSkill
- x5-ptq-deploySkill
- x5-qat-compileSkill
- x5-qat-deploySkill
- x5-qat-trainingSkill
- x5-routerSkill
- x5-runtime-cpp-inferSkill
- x5-runtime-deploySkill
- x5-runtime-perf-evalSkill
- rdk-accessoriesSkill
- rdk-board-delegateSkill
- rdk-board-knowledgeSkill
- rdk-camera-setupSkill
- rdk-command-manualSkill
- rdk-diagnosticSkill
- rdk-docs-referenceSkill
- rdk-ecosystemSkill
- rdk-embodied-lerobotSkill
- rdk-gpio-40pinSkill
- rdk-hardwareSkill
- rdk-headless-modeSkill
- rdk-llm-deploymentSkill
- rdk-log-forensicsSkill
- rdk-memory-auditSkill
- rdk-model-benchmarkSkill
- rdk-model-deploySkill
- rdk-model-zooSkill
- rdk-multimediaSkill
- rdk-network-remoteSkill
- rdk-peripheral-cookbookSkill
- rdk-source-mapSkill
- rdk-system-configSkill
- rdk-system-maintainSkill
- rdk-tros-setupSkill
- rdk-vision-pipelineSkill
- d-robotics-pack-installerSkill
The file
Files
X5 QAT 模型适配
目标与边界
让模型能进入 Plugin calibration/QAT/convert,同时尽量保持浮点语义。优先使用文档推荐的 FX 路径;只有现有模型确实依赖 eager 时才采用 eager 合同。
输入合同
- 模型源码、构建函数、浮点 checkpoint 和 example inputs。
- Plugin/PyTorch 版本、目标输入色彩/布局和部署边界。
- 浮点参考输出与最小单元测试。
前置检查
- 在模型构建/prepare 前执行
set_march(March.BAYES_E)。 - 通用 quick start 的
March.BAYES是 J5 示例,不能照抄。 - 识别函数式算子、动态控制流、共享 QuantStub、原地操作和无法 trace 的路径。
- 不导入
hat,不使用 HAT config 或 Trainer。
执行步骤
- 在真实部署输入边界插入独立
QuantStub,在最终浮点输出边界插入DeQuantStub。 - 对不支持的函数式算子按 Plugin 手册改为可量化 module;不要为通过 prepare 任意改变数学语义。
- 配置 qconfig,并用真实 example inputs 执行 prepare。
- 定义 calibration/QAT/validation 的
set_fake_quantize状态入口。 - 重新加载浮点权重并对比适配前后浮点输出。
- 运行静态合同检查:
python .drobotics/platforms/x5/scripts/check_qat_target.py \
--source <adapted.py> --stage adaptation --report <adaptation-check.json>产物与完成标准
- 适配源码、模型结构差异、example inputs 和浮点一致性报告。
adaptation-check.json证明March.BAYES_E、set_march和 prepare 存在,无 HAT/J5/PTQ 混用。- 适配模型可完成一次 calibration forward,且无未解释的 shape/dtype 变化。
风险与确认
修改模型源码为中风险;默认新建分支/文件,不覆盖用户原始模型。结构性改动需展示 diff。
失败与交接
一次只修一类不支持模式。两次仍无法 prepare 时保存最小复现,交接 x5-model-diagnostics,不要切换到 HAT。
按需参考
_sources/plugin/source/user_guide/float_model_requirements.md.txt_sources/plugin/source/terminology/terminology.md.txt
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

