From 9e36bf48124189a5807554b48b31614ad15b878f Mon Sep 17 00:00:00 2001 From: Yong Yue Date: Thu, 16 Jul 2026 12:00:07 +0800 Subject: [PATCH] Add text-classification fp32/fp16 recipes for cross-encoder/ms-marco-MiniLM-L4-v2 Recipe-only contribution. Adds fp32 and fp16 recipe configs for cross-encoder/ms-marco-MiniLM-L4-v2 (BertForSequenceClassification, 4 layers) on two verified EP/device combinations: cpu/cpu and dml/gpu. Goal ladder (verified on local hardware): - L0 (build): PASS on all 4 configs - L1 (perf): - cpu/cpu fp32: 82.69 samples/s - cpu/cpu fp16: 85.10 samples/s - dml/gpu fp32: 81.25 samples/s - dml/gpu fp16: 31.42 samples/s --- .../cpu/text-classification_fp16_config.json | 65 +++++++++++++++++++ .../cpu/text-classification_fp32_config.json | 46 +++++++++++++ .../gpu/text-classification_fp16_config.json | 65 +++++++++++++++++++ .../gpu/text-classification_fp32_config.json | 46 +++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp16_config.json create mode 100644 examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp32_config.json create mode 100644 examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp16_config.json create mode 100644 examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp32_config.json diff --git a/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp16_config.json b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp16_config.json new file mode 100644 index 000000000..ca353cc30 --- /dev/null +++ b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp16_config.json @@ -0,0 +1,65 @@ +{ + "export": { + "opset_version": 17, + "batch_size": 1, + "export_params": true, + "do_constant_folding": true, + "verbose": false, + "dynamo": false, + "enable_hierarchy_tags": true, + "clean_onnx": false, + "hierarchy_tag_format": "full", + "input_tensors": [ + { + "name": "input_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 30522] + }, + { + "name": "attention_mask", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + }, + { + "name": "token_type_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + } + ], + "output_tensors": [ + { + "name": "logits" + } + ] + }, + "optim": {}, + "quant": { + "mode": "fp16", + "samples": 10, + "calibration_method": "minmax", + "weight_type": "uint8", + "activation_type": "uint8", + "per_channel": false, + "symmetric": false, + "weight_symmetric": null, + "activation_symmetric": null, + "save_calibration": false, + "distribution": "uniform", + "seed": null, + "calibration_load_path": null, + "calibration_save_path": null, + "op_types_to_quantize": null, + "nodes_to_exclude": null, + "fp16_keep_io_types": true, + "fp16_op_block_list": null + }, + "compile": null, + "loader": { + "task": "text-classification", + "model_class": "AutoModelForSequenceClassification", + "model_type": "bert" + } +} diff --git a/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp32_config.json b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp32_config.json new file mode 100644 index 000000000..eb9f77384 --- /dev/null +++ b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/cpu/cpu/text-classification_fp32_config.json @@ -0,0 +1,46 @@ +{ + "export": { + "opset_version": 17, + "batch_size": 1, + "export_params": true, + "do_constant_folding": true, + "verbose": false, + "dynamo": false, + "enable_hierarchy_tags": true, + "clean_onnx": false, + "hierarchy_tag_format": "full", + "input_tensors": [ + { + "name": "input_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 30522] + }, + { + "name": "attention_mask", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + }, + { + "name": "token_type_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + } + ], + "output_tensors": [ + { + "name": "logits" + } + ] + }, + "optim": {}, + "quant": null, + "compile": null, + "loader": { + "task": "text-classification", + "model_class": "AutoModelForSequenceClassification", + "model_type": "bert" + } +} diff --git a/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp16_config.json b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp16_config.json new file mode 100644 index 000000000..ca353cc30 --- /dev/null +++ b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp16_config.json @@ -0,0 +1,65 @@ +{ + "export": { + "opset_version": 17, + "batch_size": 1, + "export_params": true, + "do_constant_folding": true, + "verbose": false, + "dynamo": false, + "enable_hierarchy_tags": true, + "clean_onnx": false, + "hierarchy_tag_format": "full", + "input_tensors": [ + { + "name": "input_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 30522] + }, + { + "name": "attention_mask", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + }, + { + "name": "token_type_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + } + ], + "output_tensors": [ + { + "name": "logits" + } + ] + }, + "optim": {}, + "quant": { + "mode": "fp16", + "samples": 10, + "calibration_method": "minmax", + "weight_type": "uint8", + "activation_type": "uint8", + "per_channel": false, + "symmetric": false, + "weight_symmetric": null, + "activation_symmetric": null, + "save_calibration": false, + "distribution": "uniform", + "seed": null, + "calibration_load_path": null, + "calibration_save_path": null, + "op_types_to_quantize": null, + "nodes_to_exclude": null, + "fp16_keep_io_types": true, + "fp16_op_block_list": null + }, + "compile": null, + "loader": { + "task": "text-classification", + "model_class": "AutoModelForSequenceClassification", + "model_type": "bert" + } +} diff --git a/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp32_config.json b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp32_config.json new file mode 100644 index 000000000..eb9f77384 --- /dev/null +++ b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/dml/gpu/text-classification_fp32_config.json @@ -0,0 +1,46 @@ +{ + "export": { + "opset_version": 17, + "batch_size": 1, + "export_params": true, + "do_constant_folding": true, + "verbose": false, + "dynamo": false, + "enable_hierarchy_tags": true, + "clean_onnx": false, + "hierarchy_tag_format": "full", + "input_tensors": [ + { + "name": "input_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 30522] + }, + { + "name": "attention_mask", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + }, + { + "name": "token_type_ids", + "dtype": "int32", + "shape": [1, 512], + "value_range": [0, 2] + } + ], + "output_tensors": [ + { + "name": "logits" + } + ] + }, + "optim": {}, + "quant": null, + "compile": null, + "loader": { + "task": "text-classification", + "model_class": "AutoModelForSequenceClassification", + "model_type": "bert" + } +}