deploy: ONNX toolchain — export, precision pass (fp16 sea / fp32 Q/DQ islands), graph modify - #14
Draft
vividf wants to merge 1 commit into
Draft
deploy: ONNX toolchain — export, precision pass (fp16 sea / fp32 Q/DQ islands), graph modify#14vividf wants to merge 1 commit into
vividf wants to merge 1 commit into
Conversation
This was referenced Sep 5, 2026
… islands), graph modify Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
vividf
force-pushed
the
pr4-onnx-toolchain
branch
from
September 7, 2026 05:23
6cdcf75 to
99f03b4
Compare
vividf
force-pushed
the
pr3-deployment-stage-graph
branch
from
September 7, 2026 05:23
8903af0 to
0eeeabd
Compare
This was referenced Sep 7, 2026
quant: declarative quantization (plan/placement, modelopt engine, PTQ/QAT, self-describing ckpt)
#17
Draft
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack(base
pr-stack-base=7e35d97):#11 → #12 → #13 → #14 → #15 → #16 → #17 → #18 → #19 → #20(CenterPoint 全功能點)→ #21 → #25 → #22 → #23 → #24(= 開發 branch HEAD,逐位元一致)。合併由下而上,每合一層把下一層 base retarget。這個 PR 是什麼
ONNX 工具鏈,本 stack 最需要細看的一層:export 包裝、兩條 precision pass、config 驅動的圖手術。
Precision pass:自動路由(模型端零 precision 代碼)
autocast.py)Island 規則手冊(全部是量出來的)
誰進島(
_quantized_island_names,4 條依序):① 所有 Q/DQ 節點;② scale/zero-point 的 producer(fp32 scale 位元組級保留——scale 就是量化本身);③ 每個 DQ 輸出的消費者(量化 Conv/Gemm 本體);④ 反向生長:從每個 Q 的 data 輸入只沿 float data slot 往回穿過 commuting whitelist,讓「量化 op → pointwise → 下一個 Q」整段零 cast。cast 放哪:只在島↔海與圖 IO 邊界,每條跨界 float 邊恰好一顆;整數邊(zero-point/shape/indices)永不 cast——
_ISLAND_FLOAT_INPUT_SLOTS逐 op 顯式表 + import 時 assert 與 whitelist 鎖死(擴 whitelist 忘了 slot 行 → import 直接爆)。圖 IO 保 fp32(runtime ABI)。違反的實測代價:
work_dirs/fp8_probe/nvidia_minimal_repro.py,ORT 同圖算得對,四實作對一)心智模型:島的 fp32 是「記號」不是執行精度——TRT 把島內
DQ→Conv→Relu→Q融成 int8 進出 kernel;實際執行 = 海 fp16、島 int8、邊界 cast 實測共 0.118 ms。維護契約與防呆
逐檔導覽
onnx/precision.py:island pass 全部(路由事實函式、whitelist、slot 表、成員資格、cast pass、斷鏈警告)。onnx/autocast.py:ModelOpt AutoCast 包裝 +keep_topk_in_fp16(TopK 的 fp16 保持器)。onnx/export.py:torch.onnx.export 包裝(dynamic axes/shapes、外部資料合併)。onnx/modify.py:deploy.onnx.modify_graph的圖手術執行器。test_onnx_export.py(19 個:island 位元組級精確、castless 鏈、shape-op 生長不碰 int 邊、控制流 raise、boundary rewire、FP8 拼法…)。檔案清單(點開)
Review checklist
_warn_broken_quantized_chains的一跳偵測邏輯(為什麼只查一跳)。🤖 Generated with Claude Code