Skip to content

Commit e1c54e2

Browse files
authored
Expose exporter options in command line (#289)
* expose exporter options * mypy * spell * fix
1 parent 143deef commit e1c54e2

File tree

3 files changed

+176
-38
lines changed

3 files changed

+176
-38
lines changed

CHANGELOGS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Change Logs
44
0.8.1
55
+++++
66

7+
* :pr:`289`: adds command line options ``--exppo`` to give the exporter additional options
78
* :pr:`287`: adds input ``'inputs_prompt'`` to test a LLM, meant to be used during validation
89
* :pr:`288`: add .contiguous in torch.cond branch (attention patch for sdpa implementation)
910
* :pr:`286`: adds variable to track random nodes in models

onnx_diagnostic/_command_lines_parser.py

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def get_parser_config() -> ArgumentParser:
265265
"--mop",
266266
metavar="KEY=VALUE",
267267
nargs="*",
268-
help="Additional model options, use to change some parameters of the model, "
268+
help="Additional model options, used to change some parameters of the model, "
269269
"example:\n --mop attn_implementation=sdpa or --mop attn_implementation=eager",
270270
action=_ParseDict,
271271
)
@@ -442,11 +442,17 @@ def get_parser_validate(name: str = "validate") -> ArgumentParser:
442442
default=True,
443443
action=_BoolOrParseDictPatch,
444444
nargs="*",
445-
help="Applies patches before exporting, it can be a boolean "
446-
"to enable to disable the patches or be more finetuned. It is possible to "
447-
"disable patch for torch by adding "
448-
'--patch "patch_sympy=False" --patch "patch_torch=False", '
449-
"default is True.",
445+
help=textwrap.dedent(
446+
"""
447+
Applies patches before exporting, it can be a boolean
448+
to enable to disable the patches or be more finetuned
449+
(default is True). It is possible to disable patch for torch
450+
by adding:
451+
--patch "patch_sympy=False" --patch "patch_torch=False"
452+
""".strip(
453+
"\n"
454+
)
455+
),
450456
)
451457
parser.add_argument(
452458
"--rewrite",
@@ -476,10 +482,16 @@ def get_parser_validate(name: str = "validate") -> ArgumentParser:
476482
"--inputs2",
477483
default=1,
478484
type=int,
479-
help="Validates or exports the model on a second set of inputs\n"
480-
"to check the exported model supports dynamism. The values is used "
481-
"as an increment to the first set of inputs. A high value may trick "
482-
"a different behavior in the model and missed by the exporter.",
485+
help=textwrap.dedent(
486+
"""
487+
Validates or exports the model on a second set of inputs
488+
to check the exported model supports dynamism. The values is used
489+
as an increment to the first set of inputs. A high value may trick
490+
a different behavior in the model and missed by the exporter.
491+
""".strip(
492+
"\n"
493+
)
494+
),
483495
)
484496
parser.add_argument(
485497
"--runtime",
@@ -512,9 +524,15 @@ def get_parser_validate(name: str = "validate") -> ArgumentParser:
512524
parser.add_argument(
513525
"--ortfusiontype",
514526
required=False,
515-
help="Applies onnxruntime fusion, this parameter should contain the\n"
516-
"model type or multiple values separated by `|`. `ALL` can be used\n"
517-
"to run them all.",
527+
help=textwrap.dedent(
528+
"""
529+
Applies onnxruntime fusion, this parameter should contain the
530+
model type or multiple values separated by `|`. `ALL` can be used
531+
to run them all.
532+
""".strip(
533+
"\n"
534+
)
535+
),
518536
)
519537
parser.add_argument("-v", "--verbose", default=0, type=int, help="verbosity")
520538
parser.add_argument("--dtype", help="Changes dtype if necessary.")
@@ -523,18 +541,32 @@ def get_parser_validate(name: str = "validate") -> ArgumentParser:
523541
"--iop",
524542
metavar="KEY=VALUE",
525543
nargs="*",
526-
help="Additional input options, use to change the default"
527-
"inputs use to export, example:\n --iop cls_cache=SlidingWindowCache"
528-
"\n --iop cls_cache=StaticCache",
544+
help=textwrap.dedent(
545+
"""
546+
Additional input options, used to change the default
547+
inputs use to export. Examples:
548+
--iop cls_cache=SlidingWindowCache
549+
--iop cls_cache=StaticCache
550+
""".strip(
551+
"\n"
552+
)
553+
),
529554
action=_ParseDict,
530555
)
531556
parser.add_argument(
532557
"--mop",
533558
metavar="KEY=VALUE",
534559
nargs="*",
535-
help="Additional model options, use to change some parameters of the model, "
536-
"example:\n --mop attn_implementation=sdpa --mop attn_implementation=eager\n "
537-
"--mop \"rope_scaling={'rope_type': 'dynamic', 'factor': 10.0}\"",
560+
help=textwrap.dedent(
561+
"""
562+
Additional model options, used to change some parameters
563+
of the model. Example:
564+
--mop attn_implementation=sdpa --mop attn_implementation=eager"
565+
--mop "rope_scaling={'rope_type': 'dynamic', 'factor': 10.0}"
566+
""".strip(
567+
"\n"
568+
)
569+
),
538570
action=_ParseDict,
539571
)
540572
if name == "validate":
@@ -566,9 +598,32 @@ def get_parser_validate(name: str = "validate") -> ArgumentParser:
566598
parser.add_argument(
567599
"--quiet-input-sets",
568600
default="",
569-
help="Avoids raising an exception when an input sets does not work with "
570-
"the exported model.\nExample: --quiet-input-sets=inputs,inputs22",
601+
help=textwrap.dedent(
602+
"""
603+
Avoids raising an exception when an input sets does not work with
604+
the exported model. Example:
605+
--quiet-input-sets=inputs,inputs22
606+
""".strip(
607+
"\n"
608+
)
609+
),
571610
)
611+
parser.add_argument(
612+
"--expop",
613+
metavar="KEY=VALUE",
614+
nargs="*",
615+
help=textwrap.dedent(
616+
"""
617+
Additional exporter options, use to change some parameters
618+
of the model. Examples:
619+
--expop report=True
620+
--expop report=True --expop verify=True
621+
""".strip(
622+
"\n"
623+
)
624+
),
625+
action=_ParseDict,
626+
)
572627
return parser
573628

574629

@@ -634,6 +689,7 @@ def _cmd_validate(argv: List[Any]):
634689
output_names=(
635690
None if len(args.outnames.strip()) < 2 else args.outnames.strip().split(",")
636691
),
692+
exporter_options=args.expop,
637693
)
638694
print("")
639695
print("-- summary --")

0 commit comments

Comments
 (0)