Skip to content

ConstraintViolationError #6782

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

Open
adonnini opened this issue Nov 12, 2024 · 30 comments
Open

ConstraintViolationError #6782

adonnini opened this issue Nov 12, 2024 · 30 comments
Labels
module: exir Issues related to Export IR and the code under exir/ triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@adonnini
Copy link

Hi,
I just upgraded to executorch 0.4 and ran my code which previously failed as described in
#1350

Now it fails with
ConstraintViolationError

Please find the error log below.

Please let me know if you need additional information.

Thanks

ERROR LOG

Traceback (most recent call last):
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 670, in _export_to_aten_ir
    produce_guards_callback(gm)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1655, in _produce_guards_callback
    return produce_guards_and_solve_constraints(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 287, in produce_guards_and_solve_constraints
    raise constraint_violation_error
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 270, in produce_guards_and_solve_constraints
    shape_env.produce_guards(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/fx/experimental/symbolic_shapes.py", line 3788, in produce_guards
    raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: L['args'][0][1].size()[1] = 12 is not equal to L['args'][0][0].size()[1] = 7

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 443, in <module>
    pre_autograd_aten_dialect = torch.export._trace._export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1017, in wrapper
    raise e
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 990, in wrapper
    ep = fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 114, in wrapper
    return fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1880, in _export
    export_artifact = export_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1683, in _non_strict_export
    aten_export_artifact = _to_aten_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 672, in _export_to_aten_ir
    raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e))  # noqa: B904
torch._dynamo.exc.UserError: L['args'][0][1].size()[1] = 12 is not equal to L['args'][0][0].size()[1] = 7
@GregoryComer GregoryComer added the module: exir Issues related to Export IR and the code under exir/ label Nov 12, 2024
@GregoryComer GregoryComer added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed module: exir Issues related to Export IR and the code under exir/ labels Nov 12, 2024
@GregoryComer
Copy link
Member

Hi, @adonnini. Can you provide the dynamic shape constraints that you pass into export, as well as information about the model that you are exporting? Thanks!

@GregoryComer GregoryComer added need-user-input The issue needs more information from the reporter before moving forward and removed triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 12, 2024
@adonnini
Copy link
Author

adonnini commented Nov 12, 2024

@GregoryComer thanks for the follow-up

You can find the entire model with instructions on how to run it here

https://github.com/adonnini/adonnini-trajectory-prediction-transformers-masterContextQ/tree/main

Here is the line where I pass the model and the inputs

        dim1_x = Dim("dim1_x", min=1, max=100000)
        dynamic_shapes = {"enc_input": {1: dim1_x}, "dec_input": {1: dim1_x}, "dec_source_mask": {1: dim1_x}, "dec_target_mask": {1: dim1_x}}

         pre_autograd_aten_dialect = torch.export._trace._export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            pre_dispatch=True,
            strict=False
        )
        # pre_autograd_aten_dialect = capture_pre_autograd_graph(m,
        #                                                        (enc_input, dec_input, dec_source_mask, dec_target_mask), dynamic_shapes=dynamic_shapes)
        aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect,
                                               (enc_input, dec_input, dec_source_mask, dec_target_mask), strict=False)

where
enc_input, dec_input, dec_source_mask, dec_target_mask
are defined earlier in
train-minimum.py

Thanks

@GregoryComer GregoryComer added module: exir Issues related to Export IR and the code under exir/ triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed need-user-input The issue needs more information from the reporter before moving forward labels Nov 13, 2024
@larryliu0820
Copy link
Contributor

L['args'][0][1].size()[1] = 12 is not equal to L['args'][0][0].size()[1] = 7

According to this error message, it seems like one of your input tensor is having an unexpected size. Can you please print out the tensor shapes for (enc_input, dec_input, dec_source_mask, dec_target_mask)?

It's a bit hard to tell from reading your code https://github.com/adonnini/adonnini-trajectory-prediction-transformers-masterContextQ/tree/main

@adonnini
Copy link
Author

adonnini commented Nov 13, 2024

@larryliu0820 , Thanks for getting back to me
I added print statements for the four variables as you requested (also to train-minimum.py in the repository).

The printout of the four variables themselves is very big. I thought that the information about the shapes is what your really wanted given your question.

Below, you will find the output of the four print statements of the shapes of the four variables.

Please note that the model runs successfully when excluding the executorch related code. Even with the executorch code, the frist epoch completes successfully.

By the way, the fact that the shapes of dim 1 of enc_input and dec_input is different is not an issue for the model. As I said, the train_minimum.py runs successfully without the executorch code. You can try it yourself.

Thanks

 - train_minimum - Lowering the Whole Module - enc_input.shape -  torch.Size([27, 7, 2])
 - train_minimum - Lowering the Whole Module - dec_input.shape -  torch.Size([27, 12, 3])
 - train_minimum - Lowering the Whole Module - dec_source_mask.shape -  torch.Size([27, 1, 7])
 - train_minimum - Lowering the Whole Module - dec_target_mask.shape -  torch.Size([27, 12, 12])

@larryliu0820
Copy link
Contributor

@angelayi do you have any suggestions? Is it worth an issue in pytorch/pytorch?

@angelayi
Copy link
Contributor

By specifying dynamic_shapes={"enc_input": {1: dim1_x}, "dec_input": {1: dim1_x}} where dim1_x is the same for both enc_input and dec_input, you're claiming that enc_input.shape[1] == dec_input.shape[1]. However, your input shapes are different for the two enc_input.shape[1] = 7 and dec_input.shape[1] = 12, which results in the ConstraintViolationError.

To fix this you can make each of the dims different, or you can try a new thing, Dim.AUTO: dynamic_shapes = {"enc_input": {1: Dim.AUTO}, "dec_input": {1: Dim.AUTO}, "dec_source_mask": {1: Dim.AUTO}, "dec_target_mask": {1: Dim.AUTO}}

@adonnini
Copy link
Author

adonnini commented Nov 13, 2024

@angelayi Thanks for your suggestion. After making the change you suggested (I should have seen the error, Thanks), execution failes producing the error log reported below.

@larryliu0820 I think the ball may be back in the executorch court.

FYI, below you will also find the executorch related code (in train-minimum.py)

ERROR LOG

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 461, in <module>
    aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect,
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/__init__.py", line 261, in export
    raise ValueError(
ValueError: Expected `mod` to be an instance of `torch.nn.Module`, got <class 'torch.export.exported_program.ExportedProgram'>.

CODE

        dim1_x = Dim("dim1_x", min=1, max=100000)

        dynamic_shapes = {"enc_input": {1: Dim.AUTO}, "dec_input": {1: Dim.AUTO}, "dec_source_mask": {1: Dim.AUTO}, "dec_target_mask": {1: Dim.AUTO}}

        print(" - train_minimum - Lowering the Whole Module - enc_input - ", enc_input)
        print(" - train_minimum - Lowering the Whole Module - dec_input - ", dec_input)
        print(" - train_minimum - Lowering the Whole Module - dec_source_mask - ", dec_source_mask)
        print(" - train_minimum - Lowering the Whole Module - dec_target_mask - ", dec_target_mask)

        print(" - train_minimum - Lowering the Whole Module - enc_input.shape - ", enc_input.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_input.shape - ", dec_input.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_source_mask.shape - ", dec_source_mask.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_target_mask.shape - ", dec_target_mask.shape)

        pre_autograd_aten_dialect = torch.export._trace._export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            pre_dispatch=True,
            strict=False
        )

        aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect,
                                               (enc_input, dec_input, dec_source_mask, dec_target_mask), strict=False)

        print(" - train_minimum - Lowering the Whole Module - ATen Dialect Graph")
        print(" - train_minimum - Lowering the Whole Module - aten_dialect - ", aten_dialect)

        edge_program: EdgeProgramManager = to_edge(aten_dialect)
        to_be_lowered_module = edge_program.exported_program()

        from executorch.exir.backend.backend_api import LoweredBackendModule, to_backend

        lowered_module = edge_program.to_backend(XnnpackPartitioner())

        print(" - train_minimum - Lowering the Whole Module - lowered_module - ", lowered_module)

        # Serialize and save it to a file
        save_path = save_path = "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/trajectory-prediction-transformers-master/models/tpt_delegate.pte"
        with open(save_path, "wb") as f:
            f.write(lowered_module.to_executorch().buffer)

@larryliu0820
Copy link
Contributor

pre_autograd_aten_dialect = torch.export._trace._export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            pre_dispatch=True,
            strict=False
        )

        aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect,
                                               (enc_input, dec_input, dec_source_mask, dec_target_mask), strict=False)

Can you use the new torch.export.export API?

ep = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
)

and the rest should be the same

@adonnini
Copy link
Author

@larryliu0820 , I made the change you suggested. Execution failed with the same error. Please find below the error log and the code change I made. Did I make a mistake in making the change?
Thanks

ERROR LOG

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 475, in <module>
    aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect,
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/__init__.py", line 261, in export
    raise ValueError(
ValueError: Expected `mod` to be an instance of `torch.nn.Module`, got <class 'torch.export.exported_program.ExportedProgram'>.

CODE

        pre_autograd_aten_dialect = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
        )

@larryliu0820
Copy link
Contributor

What I meant is you can skip this line:

aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect,

And do to_edge() to pre_autograd_aten_dialect

@adonnini
Copy link
Author

@larryliu0820 Sorry. I re-ran the code with the corrected code. There was progress (I think). Execution failed.
You will find the error log and updated code below. Hopefully, I did not make any mistakes this time.
Thanks

ERROR LOG

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 511, in <module>
    f.write(lowered_module.to_executorch().buffer)
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/executorch/exir/program/_program.py", line 1322, in to_executorch
    new_gm_res = p(new_gm)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/fx/passes/infra/pass_base.py", line 41, in __call__
    res = self.call(graph_module)
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/executorch/exir/passes/replace_view_copy_with_view_pass.py", line 289, in call
    node.meta["spec"] = _ViewSpec(base.meta["spec"], shape)
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/executorch/exir/passes/replace_view_copy_with_view_pass.py", line 156, in __init__
    raise Exception(
Exception: _ViewSpec is incompatible with its base on creation.  It has shape_dynamism=0, but its base has shape_dynamism=1.

CODE

 
        dim1_x = Dim("dim1_x", min=1, max=100000)

        dynamic_shapes = {"enc_input": {1: Dim.AUTO}, "dec_input": {1: Dim.AUTO}, "dec_source_mask": {1: Dim.AUTO}, "dec_target_mask": {1: Dim.AUTO}}

        print(" - train_minimum - Lowering the Whole Module - enc_input - ", enc_input)
        print(" - train_minimum - Lowering the Whole Module - dec_input - ", dec_input)
        print(" - train_minimum - Lowering the Whole Module - dec_source_mask - ", dec_source_mask)
        print(" - train_minimum - Lowering the Whole Module - dec_target_mask - ", dec_target_mask)

        print(" - train_minimum - Lowering the Whole Module - enc_input.shape - ", enc_input.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_input.shape - ", dec_input.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_source_mask.shape - ", dec_source_mask.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_target_mask.shape - ", dec_target_mask.shape)

       pre_autograd_aten_dialect = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
        )

        edge_program: EdgeProgramManager = to_edge(pre_autograd_aten_dialect)

        to_be_lowered_module = edge_program.exported_program()

        from executorch.exir.backend.backend_api import LoweredBackendModule, to_backend

        print(" - train_minimum - Lowering the Whole Module - lowered_module - ", lowered_module)

        # Serialize and save it to a file
        save_path = save_path = "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/trajectory-prediction-transformers-master/models/tpt_delegate.pte"
        with open(save_path, "wb") as f:
            f.write(lowered_module.to_executorch().buffer)

@larryliu0820
Copy link
Contributor

@metascroy This goes into ReplaceViewCopyWithViewPass. Any thoughts on why this failed?

At the same time @adonnini we can also skip this pass - change your code to:

f.write(lowered_module.to_executorch(ExecutorchBackendConfig(remove_view_copy=False)).buffer)

@adonnini
Copy link
Author

adonnini commented Nov 13, 2024

@larryliu0820 I made the change. Please find below update code and (big) error log.
Thanks
P.S. I am going to bed now (past 11 PM here). I will respond to any further comments first thing tomorrow)

CODE


         dim1_x = Dim("dim1_x", min=1, max=100000)

        dynamic_shapes = {"enc_input": {1: Dim.AUTO}, "dec_input": {1: Dim.AUTO}, "dec_source_mask": {1: Dim.AUTO}, "dec_target_mask": {1: Dim.AUTO}}

        print(" - train_minimum - Lowering the Whole Module - enc_input - ", enc_input)
        print(" - train_minimum - Lowering the Whole Module - dec_input - ", dec_input)
        print(" - train_minimum - Lowering the Whole Module - dec_source_mask - ", dec_source_mask)
        print(" - train_minimum - Lowering the Whole Module - dec_target_mask - ", dec_target_mask)

        print(" - train_minimum - Lowering the Whole Module - enc_input.shape - ", enc_input.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_input.shape - ", dec_input.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_source_mask.shape - ", dec_source_mask.shape)
        print(" - train_minimum - Lowering the Whole Module - dec_target_mask.shape - ", dec_target_mask.shape)

       pre_autograd_aten_dialect = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
        )

        edge_program: EdgeProgramManager = to_edge(pre_autograd_aten_dialect)

        to_be_lowered_module = edge_program.exported_program()

        from executorch.exir.backend.backend_api import LoweredBackendModule, to_backend

        print(" - train_minimum - Lowering the Whole Module - lowered_module - ", lowered_module)

        # Serialize and save it to a file
        save_path = save_path = "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/trajectory-prediction-transformers-master/models/tpt_delegate.pte"
        with open(save_path, "wb") as f:
            f.write(lowered_module.to_executorch(ExecutorchBackendConfig(remove_view_copy=False)).buffer)

ERROR LOG

(see attached file)
6782-errorLogLatest.txt

@larryliu0820
Copy link
Contributor

@adonnini :) this is not helpful for debugging because it seems like it's just a graph dump. Someone from our side need to repro this locally and debug. I don't have the time right now but if you want to wait I may get back next week.

@adonnini
Copy link
Author

@larryliu0820 Thanks for your help. I really appreciate it. I understand about your priorities. Would you mind if I check in with you in 1-2 weeks?
https://github.com/adonnini/adonnini-trajectory-prediction-transformers-masterContextQ/tree/main
has all the code and instructions for running the code., and instructions for local repro.
Please let me know if you need anything else.
Thanks. Have a good day

@larryliu0820
Copy link
Contributor

@adonnini yeah ping me next week I'll spend some time repro your issue

@adonnini
Copy link
Author

@larryliu0820 as we said, Just a reminder to take a look at this issue when you get a chance. Thanks

@adonnini
Copy link
Author

@larryliu0820 Will you be able to take a look at this issue in the coming week? Sorry to bother you. Thanks

@adonnini
Copy link
Author

@larryliu0820 sorry to bother you again. I know you must be very busy. Could you please take a look at this issue? Thanks

@metascroy
Copy link
Contributor

_ViewSpec is incompatible with its base on creation

This error means the tensor being viewed is dynamic, but the shape passed to the view was static. I wonder if it has something to do with the new Dim.AUTO feature @angelayi recommended not working with how ET does shape analysis.

@adonnini, can you try making each of the dims different as Angela first recommended for the constrain violation error instead of using Dim.AUTO.

@adonnini
Copy link
Author

@metascroy, I changed my code:

        dim1_x = Dim("dim1_x", min=1, max=100000)
        dynamic_shapes = {"enc_input": {1: dim1_x}, "dec_input": {1: dim1_x}, "dec_source_mask": {1: dim1_x}, "dec_target_mask": {1: dim1_x}}

pre_autograd_aten_dialect = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
        )

        edge_program: EdgeProgramManager = to_edge(pre_autograd_aten_dialect)
        to_be_lowered_module = edge_program.exported_program()

        from executorch.exir.backend.backend_api import LoweredBackendModule, to_backend
        from executorch.exir import EdgeProgramManager, ExecutorchProgramManager, to_edge_transform_and_lower

        lowered_module = edge_program.to_backend(XnnpackPartitioner())

Unfortunately, execution failes with the same error. Please see traceback log below.

Ami I wrong in thinking that by defining dim1_x as I did, I effectively let it take different values for each dimension? Assigning different values explicitly to each dimension would not work as the values are dynamic.
If what I did is not what you meant, could you give me an example of what you meant?

Thanks,

Alex

TRACEBACK LOG

Traceback (most recent call last):
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 670, in _export_to_aten_ir
    produce_guards_callback(gm)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1655, in _produce_guards_callback
    return produce_guards_and_solve_constraints(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 287, in produce_guards_and_solve_constraints
    raise constraint_violation_error
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 270, in produce_guards_and_solve_constraints
    shape_env.produce_guards(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/fx/experimental/symbolic_shapes.py", line 3788, in produce_guards
    raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: L['args'][0][1].size()[1] = 12 is not equal to L['args'][0][0].size()[1] = 7

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 459, in <module>
    pre_autograd_aten_dialect = torch.export.export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/__init__.py", line 270, in export
    return _export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1017, in wrapper
    raise e
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 990, in wrapper
    ep = fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 114, in wrapper
    return fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1880, in _export
    export_artifact = export_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1683, in _non_strict_export
    aten_export_artifact = _to_aten_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 672, in _export_to_aten_ir
    raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e))  # noqa: B904
torch._dynamo.exc.UserError: L['args'][0][1].size()[1] = 12 is not equal to L['args'][0][0].size()[1] = 7

@metascroy
Copy link
Contributor

@adonnini,

I'm not familiar with your model, but the way you defined it says that enc_input, dec_input, dec_source_mask, and dec_target_mask must all have dimension 1 being equal (dim1_x). It does not look like this is the case, which is why you get a constraint violation error (12 != 7).

Can you instead define up to 4 different dimension variables to capture the input shapes in your program, e.g.,

enc_input_dim1 = Dim("enc_input_dim1", min=1, max=100000)
dec_input_dim1 = Dim("dec_input_dim1", min=1, max=100000)
dec_source_mask_dim1 = Dim("dec_source_mask_dim1", min=1, max=100000)
dec_target_mask_dim1 = Dim("dec_target_mask_dim1", min=1, max=100000)
dynamic_shapes = {"enc_input": {1: enc_input_dim1}, "dec_input": {1: dec_input_dim1}, "dec_source_mask": {1: dec_source_mask_dim1}, "dec_target_mask": {1: dec_target_mask_dim1}}

You need one dim variable for each variable dimension. If some of the dimensions are equal, you'd use fewer dim variables.
For example, if there were two different dynamic dimensions for the encode sequence length and decode sequence length, you might define dim variables for those:

enc_seq_length = Dim("enc_seq_length", min=1, max=100000)
dec_seq_length = Dim("dec_seq_length", min=1, max=100000)
dynamic_shapes = {"enc_input": {1: enc_seq_length}, "dec_input": {1: dec_seq_length}, "dec_source_mask": {1: dec_seq_length}, "dec_target_mask": {1: dec_seq_length}}

This says that the last 3 tensors must be the same size (dec_seq_length) at dimension 1, but the first tensor has a different dynamic size there (enc_seq_length). This is just for illustration. You need to define the dynamic inputs for your model.

@adonnini
Copy link
Author

@metascroy , Thanks very much for your feedback. I really appreciate it.

I followed your suggestion (to the letter).

Not unexpectedly, execution still fails. You will find the traceback log below. It still appears that dynamic shapes are not handled correctly. I could follow the suggestion contained in the traceback log but I don't think it would not work as the shapes are dynamic.

Should I change the range with starting value 2 instead of 1?

Please let me know what you think and what I did wrong.

Thanks

TRACEBACK LOG

Traceback (most recent call last):
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 670, in _export_to_aten_ir
    produce_guards_callback(gm)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1655, in _produce_guards_callback
    return produce_guards_and_solve_constraints(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 305, in produce_guards_and_solve_constraints
    raise constraint_violation_error
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 270, in produce_guards_and_solve_constraints
    shape_env.produce_guards(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/fx/experimental/symbolic_shapes.py", line 4178, in produce_guards
    raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: Constraints violated (dec_input_dim1, dec_source_mask_dim1, dec_target_mask_dim1, enc_input_dim1)! For more information, run with TORCH_LOGS="+dynamic".
  - Not all values of enc_input_dim1 = L['args'][0][0].size()[1] in the specified range enc_input_dim1 <= 100000 are valid because enc_input_dim1 was inferred to be a constant (7).
  - Not all values of dec_input_dim1 = L['args'][0][1].size()[1] in the specified range dec_input_dim1 <= 100000 are valid because dec_input_dim1 was inferred to be a constant (12).
  - Not all values of dec_source_mask_dim1 = L['args'][0][2].size()[1] in the specified range dec_source_mask_dim1 <= 100000 are valid because dec_source_mask_dim1 was inferred to be a constant (1).
  - Not all values of dec_target_mask_dim1 = L['args'][0][3].size()[1] in the specified range dec_target_mask_dim1 <= 100000 are valid because dec_target_mask_dim1 was inferred to be a constant (12).
Suggested fixes:
  enc_input_dim1 = 7
  dec_input_dim1 = 12
  dec_source_mask_dim1 = 1
  dec_target_mask_dim1 = 12

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 467, in <module>
    pre_autograd_aten_dialect = torch.export.export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/__init__.py", line 270, in export
    return _export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1017, in wrapper
    raise e
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 990, in wrapper
    ep = fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 114, in wrapper
    return fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1880, in _export
    export_artifact = export_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1683, in _non_strict_export
    aten_export_artifact = _to_aten_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 672, in _export_to_aten_ir
    raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e))  # noqa: B904
torch._dynamo.exc.UserError: Constraints violated (dec_input_dim1, dec_source_mask_dim1, dec_target_mask_dim1, enc_input_dim1)! For more information, run with TORCH_LOGS="+dynamic".
  - Not all values of enc_input_dim1 = L['args'][0][0].size()[1] in the specified range enc_input_dim1 <= 100000 are valid because enc_input_dim1 was inferred to be a constant (7).
  - Not all values of dec_input_dim1 = L['args'][0][1].size()[1] in the specified range dec_input_dim1 <= 100000 are valid because dec_input_dim1 was inferred to be a constant (12).
  - Not all values of dec_source_mask_dim1 = L['args'][0][2].size()[1] in the specified range dec_source_mask_dim1 <= 100000 are valid because dec_source_mask_dim1 was inferred to be a constant (1).
  - Not all values of dec_target_mask_dim1 = L['args'][0][3].size()[1] in the specified range dec_target_mask_dim1 <= 100000 are valid because dec_target_mask_dim1 was inferred to be a constant (12).
Suggested fixes:
  enc_input_dim1 = 7
  dec_input_dim1 = 12
  dec_source_mask_dim1 = 1
  dec_target_mask_dim1 = 12

@adonnini
Copy link
Author

@metascroy, are you back from the holiday break? If you are you are probably swamped. I hope you will have a chance to take a look at my response to your message immediately above. Thanks

@adonnini
Copy link
Author

adonnini commented Mar 4, 2025

I hope someone is still looking at this issue.

I just set up Executorch 0.5 and ran my model again. Execution failed with the same ContraintViolationError.

Below you will find the complete execution and error log.

Please let me k now if you have any questions and what I should do next.

Thanks

EXECUTION AND ERROR LOG

(executorch) adonnini1@actlnxlpt8:~/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ$ python3 train-minimum.py
Value of eta max is: 0.0001
  0%|                                                                                                                                                            | 0/5 [00:00<?, ?it/s]Epoch 1/5....Training loss = 6.2208
 - train_minimum - Lowering the Whole Module - enc_input -  tensor([[[-9.6240e-05,  7.3358e-06],
         [-9.6240e-05, -9.1524e-03],
         [-9.6240e-05,  9.1670e-03],
         [-9.6240e-05,  7.3358e-06],
         [ 7.6025e-02,  1.0992e-01],
         [ 2.5278e-02, -2.7472e-02],
         [-9.6240e-05,  7.3358e-06]],

        [[ 1.0140e-01,  2.0152e-01],
         [-9.6240e-05,  7.3358e-06],
         [ 1.8015e+00,  4.2135e+00],
         [-1.0159e-01,  1.1908e-01],
         [-9.6240e-05, -9.1524e-03],
         [ 1.0140e-01, -1.3739e-01],
         [-9.6240e-05,  7.3358e-06]],

        [[-9.6240e-05,  7.3358e-06],
         [ 2.5278e-02,  3.6646e-02],
         [-2.5470e-02,  2.7486e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  1.8327e-02],
         [-9.6240e-05, -1.0075e-01]],

        [[-9.6240e-05, -9.1524e-03],
         [ 7.6025e-02, -1.8312e-02],
         [-1.0159e-01,  1.8327e-02],
         [ 1.0140e-01,  1.5572e-01],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05, -9.1590e-02],
         [-7.6218e-02, -1.1907e-01]],

        [[-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [ 2.5278e-02,  2.7486e-02],
         [-9.6240e-05,  7.3358e-06],
         [-2.5470e-02, -4.5791e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06]],

        [[ 5.0652e-02, -1.2823e-01],
         [-9.6240e-05,  7.3358e-06],
         [ 1.2677e-01,  2.4732e-01],
         [-9.6240e-05,  7.3358e-06],
         [-2.2846e-01, -1.0075e-01],
         [ 2.5278e-02, -8.2430e-02],
         [ 7.6025e-02, -6.4111e-02]],

        [[-9.6240e-05,  7.3358e-06],
         [ 7.6025e-02,  8.2445e-02],
         [-9.6240e-05,  7.3358e-06],
         [-7.6218e-02,  5.4966e-02],
         [-9.6240e-05, -2.3814e-01],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  1.9236e-01]],

        [[-9.6240e-05,  9.1604e-02],
         [ 1.0140e-01, -6.4111e-02],
         [-9.6240e-05,  7.3358e-06],
         [-2.5470e-02, -1.3739e-01],
         [-9.6240e-05,  2.7486e-02],
         [-9.6240e-05,  7.3358e-06],
         [-1.2697e-01,  2.8396e-01]],

        [[-9.6240e-05, -9.1524e-03],
         [-9.6240e-05,  9.1670e-03],
         [ 5.0652e-02, -6.4111e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05, -6.4111e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06]],

        [[-7.6218e-02,  1.8327e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [ 1.2677e-01, -1.0991e-01],
         [-9.6240e-05,  7.3358e-06],
         [-1.0159e-01,  1.0076e-01],
         [-2.5470e-02,  9.1670e-03]],

        [[-5.0844e-02,  7.3285e-02],
         [-9.6240e-05,  7.3358e-06],
         [ 5.0652e-02,  3.6646e-02],
         [ 5.0652e-02, -4.5791e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  1.0992e-01],
         [-5.0844e-02, -1.6487e-01]],

        [[ 9.3629e+00,  4.2318e+00],
         [-9.6240e-05,  7.3358e-06],
         [-3.9584e+00,  4.5066e+00],
         [-5.3540e+00, -8.7475e+00],
         [-2.5470e-02, -1.0991e-01],
         [-9.6240e-05,  7.3358e-06],
         [ 1.2677e-01, -8.2430e-02]],

        [[-5.8370e-01,  6.0455e-01],
         [-9.6240e-05,  7.3285e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06]],

        [[-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05, -9.1524e-03],
         [-9.6240e-05,  7.3358e-06],
         [ 1.5215e-01, -2.1067e-01],
         [-1.2697e-01,  1.3740e-01],
         [-9.6240e-05,  7.3358e-06]],

        [[ 9.3874e-01,  4.3967e-01],
         [-9.6240e-05,  7.3358e-06],
         [-1.7771e-01, -2.8120e+00],
         [-3.2996e-01, -1.4106e+00],
         [ 3.2976e-01,  1.4198e+00],
         [ 1.7752e-01,  2.8029e+00],
         [-7.1057e-01, -1.2823e-01]],

        [[ 1.1164e+00,  4.0578e+00],
         [-1.1165e+00, -4.0577e+00],
         [-9.6240e-05,  7.3358e-06],
         [-2.5470e-02,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [ 3.5514e-01,  4.0303e-01],
         [-2.7921e-01, -2.0151e-01]],

        [[ 5.0652e-02, -1.2823e-01],
         [-9.6240e-05,  7.3358e-06],
         [-1.0159e-01,  7.3358e-06],
         [ 7.6025e-02,  3.6646e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  9.1670e-03],
         [-2.0309e-01,  2.1068e-01]],

        [[-9.6240e-05,  7.3358e-06],
         [-2.0309e-01, -6.1369e-01],
         [-9.6240e-05,  1.0076e-01],
         [-9.6240e-05,  7.3358e-06],
         [-7.6218e-02, -1.0991e-01],
         [-2.5470e-02,  1.8320e-01],
         [-9.6240e-05,  7.3358e-06]],

        [[-7.6218e-02, -2.1067e-01],
         [-9.6240e-05,  7.3358e-06],
         [ 5.0652e-02,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-5.0844e-02,  7.3358e-06],
         [ 5.0652e-02,  8.2445e-02],
         [-9.6240e-05,  7.3358e-06]],

        [[-5.0844e-02, -2.2899e-01],
         [ 1.0140e-01,  1.0992e-01],
         [-9.6240e-05,  7.3358e-06],
         [-2.5470e-02, -9.1524e-03],
         [ 2.5278e-02, -8.2430e-02],
         [-9.6240e-05,  7.3358e-06],
         [-5.0844e-02,  2.0152e-01]],

        [[-9.6240e-05,  7.3358e-06],
         [ 1.2677e-01,  8.2445e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  1.1908e-01],
         [-1.0159e-01, -1.2823e-01],
         [ 2.5278e-02, -9.1524e-03],
         [-2.5470e-02,  1.8327e-02]],

        [[-9.6240e-05,  7.3358e-06],
         [-2.5470e-02, -3.6631e-02],
         [ 1.0352e+01,  9.3430e-01],
         [-9.6240e-05,  7.3358e-06],
         [-6.0391e+00,  7.7308e+00],
         [-4.4152e+00, -8.8849e+00],
         [-9.6240e-05,  7.3358e-06]],

        [[ 5.0652e-02, -1.0991e-01],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  9.1670e-03],
         [-2.5470e-02,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [ 2.5278e-02, -9.1524e-03],
         [-9.6240e-05, -1.2823e-01]],

        [[-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-1.2697e-01,  1.0992e-01],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [ 1.2677e-01,  9.1670e-03],
         [-9.6240e-05,  7.3358e-06]],

        [[-2.5470e-02,  1.0076e-01],
         [-9.6240e-05,  7.3358e-06],
         [ 1.2677e-01,  3.6646e-02],
         [-1.2697e-01, -3.6631e-02],
         [-9.6240e-05,  7.3358e-06],
         [ 7.6025e-02,  9.1604e-02],
         [ 2.5278e-02, -9.1524e-03]],

        [[-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  9.1670e-03],
         [ 1.0140e-01, -5.4951e-02],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  7.3358e-06],
         [-9.6240e-05, -9.1524e-03],
         [-9.6240e-05,  7.3358e-06]],

        [[-9.6240e-05,  7.3358e-06],
         [-9.6240e-05,  9.1604e-02],
         [ 1.2677e-01, -2.0151e-01],
         [-9.6240e-05,  7.3358e-06],
         [-2.5470e-02,  4.5806e-02],
         [ 2.5278e-02, -9.1524e-03],
         [-9.6240e-05,  7.3358e-06]]])
 - train_minimum - Lowering the Whole Module - dec_input -  tensor([[[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-2.5470e-02,  2.7486e-02,  0.0000e+00],
         [-7.6218e-02, -1.2823e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.0140e-01,  9.1670e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  1.1908e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -9.1524e-03,  0.0000e+00],
         [-9.6240e-05,  9.1670e-03,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-1.5234e-01,  2.1984e-01,  0.0000e+00],
         [ 2.5278e-02, -3.2974e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02,  1.6488e-01,  0.0000e+00],
         [ 1.2677e-01, -1.8312e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -8.2430e-02,  0.0000e+00],
         [-1.5234e-01,  1.3740e-01,  0.0000e+00],
         [ 1.2677e-01,  1.6488e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.2697e-01, -1.6487e-01,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-7.6218e-02,  2.7486e-02,  0.0000e+00],
         [ 2.5278e-02,  6.4125e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.0159e-01, -7.3270e-02,  0.0000e+00],
         [ 3.2976e-01,  2.7486e-02,  0.0000e+00],
         [-1.2697e-01,  1.0076e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -2.7472e-02,  0.0000e+00],
         [ 5.0652e-02, -5.4951e-02,  0.0000e+00],
         [ 2.5278e-02, -2.7478e-01,  0.0000e+00],
         [-5.0844e-02,  1.6488e-01,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.0140e-01, -5.4951e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-7.6218e-02,  1.9236e-01,  0.0000e+00],
         [-9.6240e-05, -1.4655e-01,  0.0000e+00],
         [-5.0844e-02,  1.3740e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02, -4.2134e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02,  3.1144e-01,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  9.1670e-03,  0.0000e+00],
         [ 7.6025e-02,  1.8327e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02, -1.8319e-01,  0.0000e+00],
         [-1.0159e-01,  5.4966e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02,  3.6646e-02,  0.0000e+00],
         [-1.0159e-01,  8.2445e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -9.1524e-03,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02,  1.5572e-01,  0.0000e+00],
         [ 5.0652e-02,  7.3285e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02, -4.5791e-02,  0.0000e+00],
         [ 1.0140e-01, -1.5571e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.2697e-01, -2.7472e-02,  0.0000e+00],
         [-2.5470e-02, -3.6631e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-1.0159e-01, -1.0991e-01,  0.0000e+00],
         [ 7.6025e-02,  1.5572e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02, -5.4951e-02,  0.0000e+00],
         [-1.2697e-01, -9.1524e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01, -3.6631e-02,  0.0000e+00],
         [-1.2697e-01,  1.0076e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.5215e-01, -1.1907e-01,  0.0000e+00],
         [-2.5470e-02,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02, -1.3739e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02,  9.1670e-03,  0.0000e+00],
         [-2.5470e-02, -9.1524e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02, -8.2430e-02,  0.0000e+00],
         [-1.0159e-01,  1.0992e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01, -1.7403e-01,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-2.5470e-02,  6.4125e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02, -8.2430e-02,  0.0000e+00],
         [-9.6240e-05, -2.7472e-02,  0.0000e+00],
         [ 5.0652e-02,  1.1908e-01,  0.0000e+00],
         [ 7.6025e-02, -1.4655e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02, -2.7472e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.0309e-01,  9.1670e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-2.5470e-02,  6.4125e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02, -7.3270e-02,  0.0000e+00],
         [-2.5470e-02,  9.1670e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02, -9.1524e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02,  7.3358e-06,  0.0000e+00],
         [-7.6218e-02,  7.3285e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02, -1.8312e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  1.2824e-01,  0.0000e+00],
         [-5.0844e-02,  8.2445e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  9.1670e-03,  0.0000e+00],
         [ 2.5278e-02, -3.6631e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  2.7486e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-1.7771e-01,  2.8396e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01, -2.3814e-01,  0.0000e+00],
         [-1.0159e-01,  2.0152e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02, -3.6631e-02,  0.0000e+00],
         [-5.0844e-02,  2.7486e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.5215e-01, -1.6487e-01,  0.0000e+00],
         [-1.5234e-01,  1.9236e-01,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [ 2.5278e-02, -7.3270e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  7.3285e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02, -7.3270e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  2.4732e-01,  0.0000e+00],
         [ 5.0652e-02,  5.4966e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-5.0844e-02, -5.4951e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02, -1.0075e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-5.0844e-02,  2.1984e-01,  0.0000e+00],
         [ 3.0439e-01,  4.2135e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-3.2996e-01, -5.7705e-01,  0.0000e+00],
         [ 1.0140e-01, -9.1524e-03,  0.0000e+00],
         [-5.0844e-02,  2.9312e-01,  0.0000e+00],
         [ 2.5278e-02, -1.5571e-01,  0.0000e+00],
         [-2.5470e-02, -8.2430e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [ 8.6262e-01, -4.2501e+00,  0.0000e+00],
         [-1.5234e-01,  4.3783e+00,  0.0000e+00],
         [-1.1927e+00, -3.1784e+00,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01,  1.2824e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02, -1.8312e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [ 2.5278e-02, -5.4951e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01,  5.7707e-01,  0.0000e+00],
         [-5.0844e-02,  1.4656e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 5.0652e-02, -1.7403e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-5.0844e-02,  1.1908e-01,  0.0000e+00],
         [-1.0159e-01, -6.4117e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02, -1.4655e-01,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01, -9.1524e-03,  0.0000e+00],
         [ 1.0140e-01, -7.3270e-02,  0.0000e+00],
         [-7.6218e-02,  1.0992e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-5.0844e-02, -4.5791e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -1.0075e-01,  0.0000e+00],
         [-9.6240e-05, -4.5791e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [ 1.0140e-01, -1.3739e-01,  0.0000e+00],
         [-1.0159e-01,  1.3740e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.0140e-01, -8.2430e-02,  0.0000e+00],
         [ 2.5278e-02, -3.6631e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02, -1.8312e-02,  0.0000e+00],
         [-9.6240e-05,  6.4125e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-7.6218e-02, -7.3270e-02,  0.0000e+00],
         [-7.6218e-02,  2.7486e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 7.6025e-02,  5.7707e-01,  0.0000e+00],
         [-7.6218e-02, -5.0378e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.0140e-01,  3.6646e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  1.2824e-01,  0.0000e+00],
         [ 1.2677e-01, -1.1907e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [ 2.5278e-02,  2.7486e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02, -1.8312e-02,  0.0000e+00],
         [ 5.0652e-02, -1.3739e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-5.0844e-02,  1.1908e-01,  0.0000e+00],
         [ 7.6025e-02, -1.0075e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02, -7.3270e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05, -1.8312e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  9.1670e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -2.7472e-02,  0.0000e+00],
         [ 7.6025e-02,  1.0076e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05, -2.7472e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05, -1.8312e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02, -9.1524e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  1.8327e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.2697e-01,  1.3740e-01,  0.0000e+00],
         [ 2.0289e-01, -2.7472e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02,  9.1670e-03,  0.0000e+00],
         [ 2.5278e-02, -2.7472e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-5.0844e-02,  2.3816e-01,  0.0000e+00],
         [ 2.5278e-02, -5.4951e-02,  0.0000e+00],
         [ 2.5278e-02, -1.5571e-01,  0.0000e+00],
         [-7.6218e-02,  2.1068e-01,  0.0000e+00],
         [ 5.0652e-02, -8.2430e-02,  0.0000e+00],
         [-2.5470e-02,  9.1604e-02,  0.0000e+00],
         [-7.1057e-01, -2.2441e+00,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.5470e-02,  2.5648e-01,  0.0000e+00],
         [ 7.8649e-01,  1.7678e+00,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05, -6.4111e-02,  0.0000e+00],
         [-1.0159e-01,  8.2445e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.5278e-02,  8.2445e-02,  0.0000e+00],
         [ 5.0652e-02, -8.2430e-02,  0.0000e+00],
         [-7.6218e-02, -1.3739e-01,  0.0000e+00],
         [ 1.0140e-01, -1.3739e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-9.6240e-05,  2.7486e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.2697e-01, -1.1907e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 1.2677e-01,  8.2445e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  1.1908e-01,  0.0000e+00],
         [-1.0159e-01, -1.2823e-01,  0.0000e+00],
         [ 2.5278e-02, -9.1524e-03,  0.0000e+00],
         [-2.5470e-02,  1.8327e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-7.6218e-02,  4.5806e-02,  0.0000e+00],
         [ 1.5215e-01, -9.1524e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.0159e-01, -9.1524e-03,  0.0000e+00],
         [-5.0844e-02, -2.5646e-01,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  3.3892e-01,  0.0000e+00],
         [-2.5470e-02, -8.2430e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  1.8327e-02,  0.0000e+00],
         [ 1.0140e-01, -7.3270e-02,  0.0000e+00]],

        [[ 0.0000e+00,  0.0000e+00,  1.0000e+00],
         [-2.5470e-02,  3.6646e-02,  0.0000e+00],
         [ 7.6025e-02, -8.2430e-02,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-1.7771e-01,  2.1068e-01,  0.0000e+00],
         [-9.6240e-05,  9.1670e-03,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [ 2.1313e+00,  4.2409e+00,  0.0000e+00],
         [-9.6240e-05,  7.3358e-06,  0.0000e+00],
         [-2.1315e+00, -4.2501e+00,  0.0000e+00],
         [ 2.5278e-02,  3.6646e-02,  0.0000e+00]]])
 - train_minimum - Lowering the Whole Module - dec_source_mask -  tensor([[[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]],

        [[1., 1., 1., 1., 1., 1., 1.]]])
 - train_minimum - Lowering the Whole Module - dec_target_mask -  tensor([[[ True, False, False,  ..., False, False, False],
         [ True,  True, False,  ..., False, False, False],
         [ True,  True,  True,  ..., False, False, False],
         ...,
         [ True,  True,  True,  ...,  True, False, False],
         [ True,  True,  True,  ...,  True,  True, False],
         [ True,  True,  True,  ...,  True,  True,  True]],

        [[ True, False, False,  ..., False, False, False],
         [ True,  True, False,  ..., False, False, False],
         [ True,  True,  True,  ..., False, False, False],
         ...,
         [ True,  True,  True,  ...,  True, False, False],
         [ True,  True,  True,  ...,  True,  True, False],
         [ True,  True,  True,  ...,  True,  True,  True]],

        [[ True, False, False,  ..., False, False, False],
         [ True,  True, False,  ..., False, False, False],
         [ True,  True,  True,  ..., False, False, False],
         ...,
         [ True,  True,  True,  ...,  True, False, False],
         [ True,  True,  True,  ...,  True,  True, False],
         [ True,  True,  True,  ...,  True,  True,  True]],

        ...,

        [[ True, False, False,  ..., False, False, False],
         [ True,  True, False,  ..., False, False, False],
         [ True,  True,  True,  ..., False, False, False],
         ...,
         [ True,  True,  True,  ...,  True, False, False],
         [ True,  True,  True,  ...,  True,  True, False],
         [ True,  True,  True,  ...,  True,  True,  True]],

        [[ True, False, False,  ..., False, False, False],
         [ True,  True, False,  ..., False, False, False],
         [ True,  True,  True,  ..., False, False, False],
         ...,
         [ True,  True,  True,  ...,  True, False, False],
         [ True,  True,  True,  ...,  True,  True, False],
         [ True,  True,  True,  ...,  True,  True,  True]],

        [[ True, False, False,  ..., False, False, False],
         [ True,  True, False,  ..., False, False, False],
         [ True,  True,  True,  ..., False, False, False],
         ...,
         [ True,  True,  True,  ...,  True, False, False],
         [ True,  True,  True,  ...,  True,  True, False],
         [ True,  True,  True,  ...,  True,  True,  True]]])
 - train_minimum - Lowering the Whole Module - enc_input.shape -  torch.Size([27, 7, 2])
 - train_minimum - Lowering the Whole Module - dec_input.shape -  torch.Size([27, 12, 3])
 - train_minimum - Lowering the Whole Module - dec_source_mask.shape -  torch.Size([27, 1, 7])
 - train_minimum - Lowering the Whole Module - dec_target_mask.shape -  torch.Size([27, 12, 12])
I0304 10:46:30.700709 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:3192] create_env
V0304 10:46:30.721908 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s0 = VR[2, 100000] (update)
I0304 10:46:30.722279 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4423] create_symbol s0 = 7 for L['args'][0][0].size()[1] [2, 100000] (_export/non_strict_utils.py:125 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s0" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V0304 10:46:30.723096 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6614] runtime_assert True == True [statically known]
V0304 10:46:30.725886 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s1 = VR[2, 100000] (update)
I0304 10:46:30.726110 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4423] create_symbol s1 = 12 for L['args'][0][1].size()[1] [2, 100000] (_export/non_strict_utils.py:125 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s1" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V0304 10:46:30.729428 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s2 = VR[2, 100000] (update)
I0304 10:46:30.729645 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4423] create_symbol s2 = 12 for L['args'][0][3].size()[1] [2, 100000] (_export/non_strict_utils.py:125 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s2" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V0304 10:46:30.805051 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(s0, 1) == True [statically known]
V0304 10:46:30.807034 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(s1, 1) == True [statically known]
V0304 10:46:30.809052 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(s2, 1) == True [statically known]
V0304 10:46:30.815146 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6614] runtime_assert True == True [statically known]
V0304 10:46:30.817328 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(27*s0, 27) == False [statically known]
V0304 10:46:30.822567 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(Mod(27, 27*s0), 0) == True [statically known]
V0304 10:46:30.824596 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 2*s0 > 2 == True [statically known]
V0304 10:46:30.832170 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(27*s0, 27) == True [statically known]
V0304 10:46:30.834353 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(s0, 1) == False [statically known]
I0304 10:46:30.840218 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] eval Ne(s0, 5000) [guard added] (_export/non_strict_utils.py:557 in __torch_function__), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Ne(s0, 5000)"
V0304 10:46:30.846079 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s0 = VR[2, 5000] (update)
I0304 10:46:30.846661 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] eval s0 <= 5000 [guard added] (_decomp/decompositions.py:743 in slice_forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="s0 <= 5000"
V0304 10:46:30.850004 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 2048*s0 > 10240000 == False [statically known]
V0304 10:46:30.892382 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 512*s0 > 512 == True [statically known]
V0304 10:46:30.924374 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 1 < s0 == True [statically known]
V0304 10:46:30.926486 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(512*s0, 512) == True [statically known]
V0304 10:46:30.945084 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(s0**2, 1) == True [statically known]
V0304 10:46:30.958837 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval s0**2 > 1 == True [statically known]
V0304 10:46:30.980833 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(64*s0, 64) == False [statically known]
V0304 10:46:30.983370 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(13824*s0, 13824) == False [statically known]
V0304 10:46:30.984014 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(64*s0, 64) == True [statically known]
V0304 10:46:31.024790 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 2048*s0 > 2048 == True [statically known]
V0304 10:46:31.705899 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(27*s1, 27) == False [statically known]
V0304 10:46:31.708444 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(Mod(27, 27*s1), 0) == True [statically known]
V0304 10:46:31.710867 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 3*s1 > 3 == True [statically known]
V0304 10:46:31.717570 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(27*s1, 27) == True [statically known]
V0304 10:46:31.719687 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(s1, 1) == False [statically known]
I0304 10:46:31.723285 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] eval Ne(s1, 5000) [guard added] (_export/non_strict_utils.py:557 in __torch_function__), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Ne(s1, 5000)"
V0304 10:46:31.726490 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s1 = VR[2, 5000] (update)
I0304 10:46:31.726861 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] eval s1 <= 5000 [guard added] (_decomp/decompositions.py:743 in slice_forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="s1 <= 5000"
V0304 10:46:31.729816 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 2048*s1 > 10240000 == False [statically known]
V0304 10:46:31.768071 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Eq(s2, 1) == False [statically known]
V0304 10:46:31.771676 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 512*s1 > 512 == True [statically known]
V0304 10:46:31.802232 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 1 < s1 == True [statically known]
V0304 10:46:31.804268 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(512*s1, 512) == True [statically known]
V0304 10:46:31.818686 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval Ne(s1**2, 1) == True [statically known]
V0304 10:46:31.827220 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6412] eval 12*s2 > 12 == True [statically known]
V0304 10:46:31.833710 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s1 = VR[12, 12] (update)
I0304 10:46:31.834091 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5963] set_replacement s1 = 12 (range_refined_to_singleton) VR[12, 12]
I0304 10:46:31.834544 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] runtime_assert Eq(s1, 12) [guard added] (_refs/__init__.py:425 in _broadcast_shapes), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s1, 12)"
V0304 10:46:31.838110 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s2 = VR[12, 12] (update)
I0304 10:46:31.838420 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5963] set_replacement s2 = 12 (range_refined_to_singleton) VR[12, 12]
I0304 10:46:31.838792 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] runtime_assert Eq(12, s2) [guard added] (_refs/__init__.py:425 in _broadcast_shapes), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(12, s2)"
V0304 10:46:31.916632 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5802] _update_var_to_range s0 = VR[7, 7] (update)
I0304 10:46:31.916974 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:5963] set_replacement s0 = 7 (range_refined_to_singleton) VR[7, 7]
I0304 10:46:31.917363 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:6281] runtime_assert Eq(s0, 7) [guard added] (_refs/__init__.py:425 in _broadcast_shapes), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s0, 7)"
I0304 10:46:32.253881 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4547] produce_guards
V0304 10:46:32.254144 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].size()[0] 27 None
V0304 10:46:32.254264 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].size()[1] 7 StrictMinMaxConstraint(warn_only=False, vr=VR[1, 100000])
V0304 10:46:32.254651 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].size()[2] 2 None
V0304 10:46:32.254776 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].stride()[0] 14 None
V0304 10:46:32.255021 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].stride()[1] 2 None
V0304 10:46:32.255116 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].stride()[2] 1 None
V0304 10:46:32.255211 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][0].storage_offset() 0 None
V0304 10:46:32.255319 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].size()[0] 27 None
V0304 10:46:32.255406 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].size()[1] 12 StrictMinMaxConstraint(warn_only=False, vr=VR[1, 100000])
V0304 10:46:32.255621 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].size()[2] 3 None
V0304 10:46:32.255721 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].stride()[0] 36 None
V0304 10:46:32.255932 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].stride()[1] 3 None
V0304 10:46:32.256026 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].stride()[2] 1 None
V0304 10:46:32.256118 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][1].storage_offset() 0 None
V0304 10:46:32.256223 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].size()[0] 27 None
V0304 10:46:32.256310 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].size()[1] 1 StrictMinMaxConstraint(warn_only=False, vr=VR[1, 100000])
V0304 10:46:32.256511 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].size()[2] 7 None
V0304 10:46:32.256610 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].stride()[0] 7 None
V0304 10:46:32.256695 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].stride()[1] 7 None
V0304 10:46:32.256778 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].stride()[2] 1 None
V0304 10:46:32.256865 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][2].storage_offset() 0 None
V0304 10:46:32.256966 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].size()[0] 27 None
V0304 10:46:32.257053 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].size()[1] 12 StrictMinMaxConstraint(warn_only=False, vr=VR[1, 100000])
V0304 10:46:32.257258 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].size()[2] 12 None
V0304 10:46:32.257359 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].stride()[0] 144 None
V0304 10:46:32.257464 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].stride()[1] 12 None
V0304 10:46:32.257550 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].stride()[2] 1 None
V0304 10:46:32.257637 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:4755] track_symint L['args'][0][3].storage_offset() 0 None
  0%|                                                                                                                                                            | 0/5 [00:22<?, ?it/s]
Traceback (most recent call last):
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1592, in _export_to_aten_ir_make_fx
    produce_guards_callback(gm)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1746, in _produce_guards_callback
    return produce_guards_and_solve_constraints(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 333, in produce_guards_and_solve_constraints
    raise constraint_violation_error
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_export/non_strict_utils.py", line 298, in produce_guards_and_solve_constraints
    shape_env.produce_guards(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/fx/experimental/symbolic_shapes.py", line 4513, in produce_guards
    return self.produce_guards_verbose(*args, **kwargs)[0]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5188, in produce_guards_verbose
    raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: Constraints violated (dec_input_dim1, dec_source_mask_dim1, dec_target_mask_dim1, enc_input_dim1)! For more information, run with TORCH_LOGS="+dynamic".
  - Not all values of enc_input_dim1 = L['args'][0][0].size()[1] in the specified range enc_input_dim1 <= 100000 are valid because enc_input_dim1 was inferred to be a constant (7).
  - Not all values of dec_input_dim1 = L['args'][0][1].size()[1] in the specified range dec_input_dim1 <= 100000 are valid because dec_input_dim1 was inferred to be a constant (12).
  - Not all values of dec_source_mask_dim1 = L['args'][0][2].size()[1] in the specified range dec_source_mask_dim1 <= 100000 are valid because dec_source_mask_dim1 was inferred to be a constant (1).
  - Not all values of dec_target_mask_dim1 = L['args'][0][3].size()[1] in the specified range dec_target_mask_dim1 <= 100000 are valid because dec_target_mask_dim1 was inferred to be a constant (12).
Suggested fixes:
  enc_input_dim1 = 7
  dec_input_dim1 = 12
  dec_source_mask_dim1 = 1
  dec_target_mask_dim1 = 12

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ/train-minimum.py", line 467, in <module>
    pre_autograd_aten_dialect = torch.export.export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/__init__.py", line 368, in export
    return _export(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1035, in wrapper
    raise e
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1008, in wrapper
    ep = fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 128, in wrapper
    return fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1970, in _export
    return _export_for_training(
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1035, in wrapper
    raise e
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1008, in wrapper
    ep = fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 128, in wrapper
    return fn(*args, **kwargs)
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1834, in _export_for_training
    export_artifact = export_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1772, in _non_strict_export
    aten_export_artifact = _to_aten_func(  # type: ignore[operator]
  File "/home/adonnini1/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/_trace.py", line 1594, in _export_to_aten_ir_make_fx
    raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e))  # noqa: B904
torch._dynamo.exc.UserError: Constraints violated (dec_input_dim1, dec_source_mask_dim1, dec_target_mask_dim1, enc_input_dim1)! For more information, run with TORCH_LOGS="+dynamic".
  - Not all values of enc_input_dim1 = L['args'][0][0].size()[1] in the specified range enc_input_dim1 <= 100000 are valid because enc_input_dim1 was inferred to be a constant (7).
  - Not all values of dec_input_dim1 = L['args'][0][1].size()[1] in the specified range dec_input_dim1 <= 100000 are valid because dec_input_dim1 was inferred to be a constant (12).
  - Not all values of dec_source_mask_dim1 = L['args'][0][2].size()[1] in the specified range dec_source_mask_dim1 <= 100000 are valid because dec_source_mask_dim1 was inferred to be a constant (1).
  - Not all values of dec_target_mask_dim1 = L['args'][0][3].size()[1] in the specified range dec_target_mask_dim1 <= 100000 are valid because dec_target_mask_dim1 was inferred to be a constant (12).
Suggested fixes:
  enc_input_dim1 = 7
  dec_input_dim1 = 12
  dec_source_mask_dim1 = 1
  dec_target_mask_dim1 = 12
I0304 10:46:32.261360 2540058 site-packages/torch/_dynamo/eval_frame.py:398] TorchDynamo attempted to trace the following frames: [
I0304 10:46:32.261360 2540058 site-packages/torch/_dynamo/eval_frame.py:398] 
I0304 10:46:32.261360 2540058 site-packages/torch/_dynamo/eval_frame.py:398] ]
I0304 10:46:32.263755 2540058 site-packages/torch/_dynamo/utils.py:446] TorchDynamo compilation metrics:
I0304 10:46:32.263755 2540058 site-packages/torch/_dynamo/utils.py:446] Function    Runtimes (s)
I0304 10:46:32.263755 2540058 site-packages/torch/_dynamo/utils.py:446] ----------  --------------
V0304 10:46:32.263907 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats constrain_symbol_range: CacheInfo(hits=0, misses=0, maxsize=None, currsize=0)
V0304 10:46:32.264022 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats defer_runtime_assert: CacheInfo(hits=1467, misses=5, maxsize=256, currsize=5)
V0304 10:46:32.264111 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats evaluate_expr: CacheInfo(hits=6768, misses=38, maxsize=256, currsize=38)
V0304 10:46:32.264194 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats _simplify_floor_div: CacheInfo(hits=0, misses=0, maxsize=None, currsize=0)
V0304 10:46:32.264274 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats _maybe_guard_rel: CacheInfo(hits=0, misses=7, maxsize=256, currsize=7)
V0304 10:46:32.264358 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats _find: CacheInfo(hits=171, misses=16, maxsize=None, currsize=3)
V0304 10:46:32.264437 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats has_hint: CacheInfo(hits=0, misses=0, maxsize=256, currsize=0)
V0304 10:46:32.264515 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats size_hint: CacheInfo(hits=2, misses=3, maxsize=256, currsize=3)
V0304 10:46:32.264595 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats simplify: CacheInfo(hits=8, misses=54, maxsize=None, currsize=7)
V0304 10:46:32.264673 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats _update_divisible: CacheInfo(hits=0, misses=0, maxsize=None, currsize=0)
V0304 10:46:32.264751 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats replace: CacheInfo(hits=86766, misses=238, maxsize=None, currsize=23)
V0304 10:46:32.264830 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats _maybe_evaluate_static: CacheInfo(hits=1, misses=50, maxsize=None, currsize=7)
V0304 10:46:32.264910 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats get_implications: CacheInfo(hits=2, misses=5, maxsize=None, currsize=5)
V0304 10:46:32.264991 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats get_axioms: CacheInfo(hits=0, misses=0, maxsize=None, currsize=0)
V0304 10:46:32.265068 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats _maybe_evaluate_static_worker: CacheInfo(hits=9, misses=31, maxsize=None, currsize=31)
V0304 10:46:32.265145 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats safe_expand: CacheInfo(hits=47, misses=63, maxsize=256, currsize=63)
V0304 10:46:32.265220 2540058 site-packages/torch/fx/experimental/symbolic_shapes.py:172] lru_cache_stats uninteresting_files: CacheInfo(hits=310, misses=1, maxsize=None, currsize=1)
(executorch) adonnini1@actlnxlpt8:~/Development/ContextQSourceCode/NeuralNetworks/adonnini-trajectory-prediction-transformers-masterContextQ$ 

@metascroy
Copy link
Contributor

@adonnini I'm trying to understand where the issue with your flow is:

Can you share your export command, with dynamic shapes and provided example_inputs.

@adonnini
Copy link
Author

adonnini commented Mar 4, 2025

@metascroy

Thanks for getting back to me. I appreciate it.

To start with, below you will find all the Executorch related code I am using to create the model.

I am sorry I am not sure what you mean by "provided example_inputs". Could you please clarify?

Please let me know if you need anything else.

Thanks

EXECUTORCH RELATED CODE IN MODEL TRAINING MODULE

    # creating model 
    encoder_ip_size = 2
    decoder_ip_size = 3
    model_op_size = 3
    emb_size = 512
    num_heads = 8
    ff_hidden_size = 2048
    n = 6
    dropout = 0.1
        ENCODER_IP_SIZE = encoder_ip_size
        DECODER_IP_SIZE = decoder_ip_size
        MODEL_OP_SIZE = model_op_size
        EMB_SIZE = emb_size
        NUM_HEADS = num_heads
        FF_HIDDEN_SIZE = ff_hidden_size
        NUMBER_LAYERS = n
        DROPOUT = dropout
        ENC_INPUT = enc_input
        DEC_INPUT = dec_input
        DEC_SOURCE_MASK = dec_source_mask
        DEC_TARGET_MASK = dec_target_mask

        m = model.TFModel(ENCODER_IP_SIZE, DECODER_IP_SIZE, MODEL_OP_SIZE, EMB_SIZE, NUM_HEADS, FF_HIDDEN_SIZE,
                          NUMBER_LAYERS, DROPOUT)

        m.eval()

        data_trg_tuple = tuple(data_trg)
        enc_input_tuple = tuple(enc_input)
        dec_input_tuple = tuple(dec_input)
        dec_source_mask_tuple = tuple(dec_source_mask)
        dec_target_mask_tuple = tuple(dec_target_mask)

        os.environ["TORCH_LOGS"] = "+dynamo"
        torch._logging._init_logs()
        from torch.export import _trace

        enc_input_dim1 = Dim("enc_input_dim1", min=1, max=100000)
        dec_input_dim1 = Dim("dec_input_dim1", min=1, max=100000)
        dec_source_mask_dim1 = Dim("dec_source_mask_dim1", min=1, max=100000)
        dec_target_mask_dim1 = Dim("dec_target_mask_dim1", min=1, max=100000)
        dynamic_shapes = {"enc_input": {1: enc_input_dim1}, "dec_input": {1: dec_input_dim1},
                          "dec_source_mask": {1: dec_source_mask_dim1}, "dec_target_mask": {1: dec_target_mask_dim1}}

        pre_autograd_aten_dialect = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
        )

        edge_program: EdgeProgramManager = to_edge(pre_autograd_aten_dialect)
        to_be_lowered_module = edge_program.exported_program()

        from executorch.exir.backend.backend_api import LoweredBackendModule, to_backend
        from executorch.exir import EdgeProgramManager, ExecutorchProgramManager, to_edge_transform_and_lower
        lowered_module = edge_program.to_backend(XnnpackPartitioner())

        save_path = save_path = "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/trajectory-prediction-transformers-master/models/tpt_delegate.pte"
        with open(save_path, "wb") as f:
            f.write(lowered_module.to_executorch(ExecutorchBackendConfig(remove_view_copy=False)).buffer)

@metascroy
Copy link
Contributor

@metascroy

Thanks for getting back to me. I appreciate it.

To start with, below you will find all the Executorch related code I am using to create the model.

I am sorry I am not sure what you mean by "provided example_inputs". Could you please clarify?

Please let me know if you need anything else.

Thanks

EXECUTORCH RELATED CODE IN MODEL TRAINING MODULE

    # creating model 
    encoder_ip_size = 2
    decoder_ip_size = 3
    model_op_size = 3
    emb_size = 512
    num_heads = 8
    ff_hidden_size = 2048
    n = 6
    dropout = 0.1
        ENCODER_IP_SIZE = encoder_ip_size
        DECODER_IP_SIZE = decoder_ip_size
        MODEL_OP_SIZE = model_op_size
        EMB_SIZE = emb_size
        NUM_HEADS = num_heads
        FF_HIDDEN_SIZE = ff_hidden_size
        NUMBER_LAYERS = n
        DROPOUT = dropout
        ENC_INPUT = enc_input
        DEC_INPUT = dec_input
        DEC_SOURCE_MASK = dec_source_mask
        DEC_TARGET_MASK = dec_target_mask

        m = model.TFModel(ENCODER_IP_SIZE, DECODER_IP_SIZE, MODEL_OP_SIZE, EMB_SIZE, NUM_HEADS, FF_HIDDEN_SIZE,
                          NUMBER_LAYERS, DROPOUT)

        m.eval()

        data_trg_tuple = tuple(data_trg)
        enc_input_tuple = tuple(enc_input)
        dec_input_tuple = tuple(dec_input)
        dec_source_mask_tuple = tuple(dec_source_mask)
        dec_target_mask_tuple = tuple(dec_target_mask)

        os.environ["TORCH_LOGS"] = "+dynamo"
        torch._logging._init_logs()
        from torch.export import _trace

        enc_input_dim1 = Dim("enc_input_dim1", min=1, max=100000)
        dec_input_dim1 = Dim("dec_input_dim1", min=1, max=100000)
        dec_source_mask_dim1 = Dim("dec_source_mask_dim1", min=1, max=100000)
        dec_target_mask_dim1 = Dim("dec_target_mask_dim1", min=1, max=100000)
        dynamic_shapes = {"enc_input": {1: enc_input_dim1}, "dec_input": {1: dec_input_dim1},
                          "dec_source_mask": {1: dec_source_mask_dim1}, "dec_target_mask": {1: dec_target_mask_dim1}}

        pre_autograd_aten_dialect = torch.export.export(
            m,
            (enc_input, dec_input, dec_source_mask, dec_target_mask),
            dynamic_shapes=dynamic_shapes,
            strict=False
        )

        edge_program: EdgeProgramManager = to_edge(pre_autograd_aten_dialect)
        to_be_lowered_module = edge_program.exported_program()

        from executorch.exir.backend.backend_api import LoweredBackendModule, to_backend
        from executorch.exir import EdgeProgramManager, ExecutorchProgramManager, to_edge_transform_and_lower
        lowered_module = edge_program.to_backend(XnnpackPartitioner())

        save_path = save_path = "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/trajectory-prediction-transformers-master/models/tpt_delegate.pte"
        with open(save_path, "wb") as f:
            f.write(lowered_module.to_executorch(ExecutorchBackendConfig(remove_view_copy=False)).buffer)

By example inputs, I just meant the stuff passed to export. It looks like you linked this repo for reproducing your error: https://github.com/adonnini/adonnini-trajectory-prediction-transformers-masterContextQ/

But I don't see the above code in the repo. What python file do I run to reproduce your error?

@adonnini
Copy link
Author

@metascroy I realize this is not a priority. Did oyu get a chance to run my code following the links and instructions I gave you in my last message three weeks ago?

Please let me know if you have any questions or need anything else.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: exir Issues related to Export IR and the code under exir/ 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

6 participants