Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamo] Enable dynamo.export for huggingface models w/ ModelOutput #98251

Closed
BowenBao opened this issue Apr 3, 2023 · 6 comments
Closed

[Dynamo] Enable dynamo.export for huggingface models w/ ModelOutput #98251

BowenBao opened this issue Apr 3, 2023 · 6 comments
Labels
feature A request for a proper, new feature. module: pytree oncall: export oncall: pt2 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@BowenBao
Copy link
Collaborator

BowenBao commented Apr 3, 2023

🚀 The feature, motivation and pitch

Initially reported at #96386, dynamo.export raises for any huggingface model that returns a subclass of ModelOutput.

Here is an experimental patch I have done to unblock dynamo.export based ONNX export. The idea is to extend pytree to be able to flatten/unflatten ModelOutput and its subclasses.

@contextlib.contextmanager
def _patch_pytree_huggingface_modeloutput():
"""Patch 'torch.utils._pytree' to support family of 'ModelOutput' from HuggingFace 'transformers'.
The source and details of the issue is described at https://github.com/pytorch/pytorch/issues/96386.
This patch enables 'torch.utils._pytree' to flatten and unflatten all 'ModelOutput'
subclasses defined in HuggingFace 'transformers'. Hence resolving the mismatch between
`dynamo` eager traced model outputs and `dynamo.export` fx graph computed outputs.
FIXME(bowbao): Remove this patch after above issue is resolved for `dynamo.export`.
"""
try:
from transformers import modeling_outputs # type: ignore[import]
except ImportError as e:
# Do nothing if 'transformers' is not installed.
try:
yield
finally:
pass
return
def model_output_flatten(
output: modeling_outputs.ModelOutput,
) -> Tuple[List[Any], _pytree.Context]:
return list(output.values()), (type(output), list(output.keys()))
def model_output_unflatten(
values: List[Any], context: _pytree.Context
) -> modeling_outputs.ModelOutput:
output_type, keys = context
return output_type(**dict(zip(keys, values)))
# All 'ModelOutput' subclasses are defined under module 'modeling_outputs'.
named_model_output_classes = inspect.getmembers(
modeling_outputs,
lambda x: inspect.isclass(x) and issubclass(x, modeling_outputs.ModelOutput),
)
for _, class_type in named_model_output_classes:
_pytree._register_pytree_node(
class_type, model_output_flatten, model_output_unflatten
)
try:
yield
finally:
for _, class_type in named_model_output_classes:
_pytree.SUPPORTED_NODES.pop(class_type)

I wonder if it is a good idea to bring this native into pytree? The context of this patch needs to cover not only dynamo.export but any other subsequent fx pass that may interact with the formatted output, otherwise it won't recognize the output structure.

Feedbacks and suggestions are welcomed. Feel free to let me know if there are other more suitable solutions.

@jansel @voznesenskym @wconstab

Alternatives

No response

Additional context

No response

cc @zou3519 @ezyang @msaroufim @wconstab @bdhirsh @anijain2305 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng @ngimel @Xia-Weiwen @soumith @desertfire

@jansel
Copy link
Contributor

jansel commented Apr 4, 2023

If I recall you can convert a ModelOutput to a tuple(), so a more concise workaround might be something like:

torch.export(lambda *args: orig_model(*args).to_tuple(), ...)

I feel most export targets will have trouble constructing a python class anyway, so getting a basic type in the export might be more useful.

BowenBao added a commit that referenced this issue Apr 5, 2023
…matter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…t formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…ntroduce Input/Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…uptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…uptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
… Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…r; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…namoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…witch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…Exporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…witch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 6, 2023
…Exporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 10, 2023
…ce Input/Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 10, 2023
…formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
@wconstab wconstab added triage review feature A request for a proper, new feature. labels Apr 10, 2023
@wconstab
Copy link
Contributor

@BowenBao how do you feel about just using the workaround proposed by @jansel? Is it crucial to have support for exporting a ModelOutput class? Specifically, do you want the 'ModelOutput' class to show up in the runtime where you load the exported module? or you just want a way to export this model?

@BowenBao
Copy link
Collaborator Author

@wconstab thanks for following up. I'm unblocked with workaround combining the idea from the post and suggestion from @jansel.

For your question, I feel it is a question on the design/goal of dynamo.export, which I may have a few misunderstandings from the start. Is there a hidden requirement/design that the graph module produced by dynamo.export should have identical inputs & outputs interface with the original pytorch function? Because that seems like what the code is doing, and becomes the constraint that lead to the failures in the original post.

For me this issue was opened based on a simple context: dynamo.export cannot succeed on various models from Huggingface, the root cause turns out to be ModelOutput. These are basic models so I thought they should work directly.

BowenBao added a commit that referenced this issue Apr 11, 2023
…ormatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 11, 2023
… to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
@wconstab
Copy link
Contributor

Is there a hidden requirement/design that the graph module produced by dynamo.export should have identical inputs & outputs interface with the original pytorch function?

I think it's a good question for follow up. Tagging some others @voznesenskym @SherlockNoMad @suo

BowenBao added a commit that referenced this issue Apr 11, 2023
…witch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 11, 2023
…Exporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 12, 2023
…Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 12, 2023
…; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 12, 2023
…witch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 12, 2023
…Exporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
@ezyang
Copy link
Contributor

ezyang commented Apr 12, 2023

It is a difficult question to answer, because it depends on the intended use case for the exported model.

For example, let's suppose you are exporting a model just to have a "compiled" callable in Python that you can reload later and then execute. Then it would make sense to have identical inputs and outputs, because you have some sort fancy pickler for functions.

But let's say instead your exporting the model to interoperate with some C++ runtime predictor service. Then obviously the Python structs don't matter, you just need to know enough about the output Tensors to reconstruct them in whatever schema you need.

BowenBao added a commit that referenced this issue Apr 14, 2023
…ce Input/Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…t/Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…er; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…on "[ONNX] Introduce Input/Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…duce Input/Ouptut formatter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output formatter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output formatter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…uptut adapter; Switch to 'DynamoExporter'"


Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…witch to 'DynamoExporter'"


Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…tch to 'DynamoExporter'"


Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…porter'"


Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…tch to 'DynamoExporter'"


Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
BowenBao added a commit that referenced this issue Apr 14, 2023
…porter'"


Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251, 
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept 
`DynamoOptimizeExporter` in the tests for now for coverage of this change.

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this issue Apr 15, 2023
…8421)

Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251,
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept
`DynamoOptimizeExporter` in the tests for now for coverage of this change.
Pull Request resolved: #98421
Approved by: https://github.com/justinchuby, https://github.com/titaiwangms, https://github.com/thiagocrepaldi
ZainRizvi pushed a commit that referenced this issue Apr 19, 2023
…8421)

Summary
* Introduce input/output adapter. Due to design differences, input/output format
between PyTorch model and exported ONNX model are often not the same. E.g., `None`
inputs are allowed for PyTorch model, but are not supported by ONNX. Nested constructs
of tensors are allowed for PyTorch model, but only flattened tensors are supported by ONNX,
etc. The new input/output adapter is exported with the model. Providing an interface to
automatically convert and validate inputs/outputs format.
* As suggested by #98251,
provide extension for unwrapping user defined python classes for `dynamo.export` based
exporter. Unblock huggingface models.
* Re-wire tests to run through `DynamoExporter` w/ `dynamo_export` api. Kept
`DynamoOptimizeExporter` in the tests for now for coverage of this change.
Pull Request resolved: #98421
Approved by: https://github.com/justinchuby, https://github.com/titaiwangms, https://github.com/thiagocrepaldi
@albanD albanD added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed triage review labels May 22, 2023
@tugsbayasgalan
Copy link
Contributor

Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A request for a proper, new feature. module: pytree oncall: export oncall: pt2 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

10 participants