Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"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,
250002
]
},
{
"name": "attention_mask",
"dtype": "int32",
"shape": [
1,
512
],
"value_range": [
0,
2
]
}
],
"output_tensors": [
{
"name": "last_hidden_state"
}
],
"compatibility": {
"transformers_attention": "eager"
}
},
"optim": {
"clamp_constant_values": true
},
"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,
"task": "sentence-similarity",
"model_id": "dell-research-harvard/lt-wikidata-comp-multi",
"model_type": "xlm-roberta",
"fp16_keep_io_types": true,
"fp16_op_block_list": null
},
"compile": null,
"loader": {
"task": "sentence-similarity",
"model_class": "AutoModel",
"model_type": "xlm-roberta"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"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,
250002
]
},
{
"name": "attention_mask",
"dtype": "int32",
"shape": [
1,
512
],
"value_range": [
0,
2
]
}
],
"output_tensors": [
{
"name": "last_hidden_state"
}
],
"compatibility": {
"transformers_attention": "eager"
}
},
"optim": {
"clamp_constant_values": true
},
"quant": null,
"compile": null,
"loader": {
"task": "sentence-similarity",
"model_class": "AutoModel",
"model_type": "xlm-roberta"
}
}
54 changes: 29 additions & 25 deletions src/winml/modelkit/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,7 @@ def _build_hf_pipeline(

max_iters: int = extra_kwargs.pop("hack_max_optim_iterations", 3)
allow_unsupported_nodes: bool = extra_kwargs.pop("allow_unsupported_nodes", False)
skip_optimize = extra_kwargs.pop("skip_optimize", False) or config.skip_optimize
model_label = model_id or "random-init"

# ── Validate + setup ─────────────────────────────────────────
Expand Down Expand Up @@ -2142,18 +2143,19 @@ def _name(base: str) -> str:
stage_timings.append(("Export", _export_elapsed))

# ── Optimize stage ───────────────────────────────────────────
current_path, _ = _run_optimize_stage(
config=config,
model_path=current_path,
optimized_path=optimized_path,
ep=ep,
device=device,
max_iters=max_iters,
stage_timings=stage_timings,
show_io_first=False,
analyze_output_path=analyze_result_path,
allow_unsupported_nodes=allow_unsupported_nodes,
)
if not skip_optimize:
current_path, _ = _run_optimize_stage(
config=config,
model_path=current_path,
optimized_path=optimized_path,
ep=ep,
device=device,
max_iters=max_iters,
stage_timings=stage_timings,
show_io_first=False,
analyze_output_path=analyze_result_path,
allow_unsupported_nodes=allow_unsupported_nodes,
)

# Persist config after autoconf
config_path.write_text(json.dumps(config.to_dict(), indent=2))
Expand Down Expand Up @@ -2209,6 +2211,7 @@ def _build_onnx_pipeline(

max_iters: int = extra_kwargs.pop("hack_max_optim_iterations", 3)
allow_unsupported_nodes: bool = extra_kwargs.pop("allow_unsupported_nodes", False)
skip_optimize = extra_kwargs.pop("skip_optimize", False)

# ── Validate + setup ─────────────────────────────────────────
if not onnx_path.exists():
Expand Down Expand Up @@ -2251,21 +2254,22 @@ def _build_onnx_pipeline(
# config before any stage reads it, otherwise the optimize stage will still
# run on integer ops and the quantize stage may try to re-quantize.
ensure_pre_quantized_stamped(config, current_path)
skip_optimize = skip_optimize or config.skip_optimize

# ── Optimize stage (first stage for ONNX — show I/O here) ────
current_path, _ = _run_optimize_stage(
config=config,
model_path=current_path,
optimized_path=optimized_path,
ep=ep,
device=device,
max_iters=max_iters,
stage_timings=stage_timings,
show_io_first=True,
analyze_output_path=analyze_result_path,
allow_unsupported_nodes=allow_unsupported_nodes,
skip_optimize=config.skip_optimize,
)
if not skip_optimize:
current_path, _ = _run_optimize_stage(
config=config,
model_path=current_path,
optimized_path=optimized_path,
ep=ep,
device=device,
max_iters=max_iters,
stage_timings=stage_timings,
show_io_first=True,
analyze_output_path=analyze_result_path,
allow_unsupported_nodes=allow_unsupported_nodes,
)

config_path.write_text(json.dumps(config.to_dict(), indent=2))

Expand Down
Loading
Loading