Skip to content

Add exact FP16 node exclusions and bounded strict-type validation #1353

Description

@ssss141414

Feature gap

ONNX Runtime exposes exact node_block_list support for FP16 conversion, but WinML needs shared, opt-in plumbing for graph-derived node names and a bounded strict-type validation gate.

Required shared contract

  • Add optional WinMLQuantizationConfig.fp16_nodes_to_exclude: list[str] | None with stable declaration-order de-duplication and non-empty-string validation.
  • Serialize the field only for FP16 mode and include distinct non-empty lists in cache identity; omitted and null preserve existing behavior.
  • Forward the list unchanged through FP16Pass.run as ORT node_block_list.
  • Forward the same list in both normal and disable_shape_infer=True convert_to_fp16 calls.
  • Before conversion, run checker, strict shape/type inference, and checker on an isolated input model. If that succeeds, require the identical sequence on the converted model and raise RuntimeError('FP16 conversion produced incompatible FP16 types.') on failure.
  • Only AttributeError, google.protobuf.message.EncodeError, checker.ValidationError, and shape_inference.InferenceError from the input capability preflight may skip the generic converted-model strict sequence. Existing specialized safeguards remain mandatory.

Exact graph-derived boundary names

The recipe must use exactly these 74 ONNX node.name values, in this order, as fp16_nodes_to_exclude:

  • InsertedPrecisionFreeCast_/deberta/embeddings/LayerNorm/LayerNormalization_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.0/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.0/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.0/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.0/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.0/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.0/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.1/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.1/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.1/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.1/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.1/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.1/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.2/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.2/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.2/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.2/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.2/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.2/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.3/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.3/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.3/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.3/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.3/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.3/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.4/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.4/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.4/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.4/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.4/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.4/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.5/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.5/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.5/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.5/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.5/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.5/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.6/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.6/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.6/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.6/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.6/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.6/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.7/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.7/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.7/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.7/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.7/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.7/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.8/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.8/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.8/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.8/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.8/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.8/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.9/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.9/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.9/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.9/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.9/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.9/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.10/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.10/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.10/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.10/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.10/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.10/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.11/attention/self/Transpose_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.11/attention/self/Reshape_1_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.11/attention/self/Reshape_3_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.11/attention/self/Transpose_8_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.11/attention/self/Reshape_5_output_0
  • InsertedPrecisionFreeCast_/deberta/encoder/layer.11/attention/self/Reshape_13_output_0
  • InsertedPrecisionFreeCast_/pooler/Gather_output_0

InsertedPrecisionFreeCast_/deberta/embeddings/Cast_output_0 is deliberately absent because it is INT32-to-FLOAT, not FP16-to-FLOAT, and must convert to INT32-to-FLOAT16 under ordinary semantics.

Acceptance and evidence

  • Exact-name tests prove all 74 names are unique and ordered, exist once in the fresh optimized graph, remain FLOAT boundaries in FP16, and the excluded embeddings Cast converts normally.
  • Config/pass/converter tests cover absent, null, non-empty, duplicate, invalid, serialization, cache, normal/fallback forwarding, unknown-name, strict-capability, and specialized-regression behavior.
  • Fresh quality evidence producer-v3-quality-20260824T130316Z-7e682b5e is PASS: 152 focused converter tests, 426 focused config/pass tests, 1 focused recipe test, and 858 affected optimization tests passed (16 skipped, 1 xfailed), with format, lint, type, diff, and license gates complete.
  • Fresh build attempt producer-v3-artifacts-20260824T130610Z-971c84dd recorded a validation-script failure and was recovered idempotently by producer-v3-artifacts-20260824T131754Z-0d34abcb, whose model validation and artifact completion are PASS with 74 selected Casts and bounded CPU FP16 performance evidence.

Explicitly prohibited

No broad Cast op blocking, prefix/wildcard/substring matching, automatic graph heuristics, runtime synthesis or fallback exclusions, model/checkpoint conditionals, arbitrary exception catch, or suppression of specialized validation safeguards.

Planning reference: sealed planner-charter.v4.json; authorized base 3708969b731425b0c6d4b97920d1b5e6519bb013; dependency #1322. Invalid candidate 4cc9e8ee56848ffea02642294b27647e3eaeadb0 is not reusable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions