Fix FP16 conversion for initializer-backed graph outputs - #1280
Fix FP16 conversion for initializer-backed graph outputs#1280Qiong Wu (qiowu) (DingmaomaoBJTU) wants to merge 10 commits into
Conversation
xieofxie
left a comment
There was a problem hiding this comment.
One correctness issue remains in duplicate-initializer validation for subgraphs beneath blocked operators.
xieofxie
left a comment
There was a problem hiding this comment.
Two correctness gaps remain around nested initializer outputs and lexical consumer scope.
xieofxie
left a comment
There was a problem hiding this comment.
Two conversion regressions remain for overridable initializer outputs and sparse FLOAT initializers.
xieofxie
left a comment
There was a problem hiding this comment.
One correctness issue remains in keep-I/O handling for nested graph input shadowing.
xieofxie
left a comment
There was a problem hiding this comment.
One correctness issue remains in nested keep-I/O collision detection.
xieofxie
left a comment
There was a problem hiding this comment.
All previously identified correctness issues have been addressed. The latest changes look good to merge.
Summary
keep_io_types=TrueRoot cause
ORT's FP16 converter assumes every graph output has a node producer. For an output supplied directly by an initializer:
keep_io_types=Truecreates an orphangraph_output_castNinput, and WinML topological sorting fails withGraph is not a DAGkeep_io_types=Falsechanges the graph-output declaration to FLOAT16 but leaves the backing initializer FLOAT, causing strict type inference / ORT session creation to failThe fix captures only provably safe top-level initializer outputs. It removes the exact orphan Cast for preserved FP32 I/O, or converts the resident initializer data for pure FP16. Ambiguous mixed-precision semantics fail closed.
Validation
pytest tests/unit/optim/test_fp16.py -q— 27 passedruff check src/winml/modelkit/quant/fp16.py tests/unit/optim/test_fp16.pymypy -p winml.modelkit— 429 source files cleanwinml quantize --precision fp16reproduction on keen_hominy now succeeds; the generated model creates an ORT session with all 7 outputs, while the initializer-backedlandmarks_2doutput remains FP32 under the default keep-I/O policyScope
This intentionally does not guess semantics for initializer outputs that are shared with graph consumers, captured by nested graphs, exposed as overridable graph inputs, or backed by unloaded external data. Those cases return an explicit error before conversion rather than publishing an invalid model.