TorchDynamo related cleanup
Author: anijain2305
Pull request: yes

Related to https://github.com/huggingface/transformers/issues/18127

cc @ydshieh @stas00 

Comments:
Thank you for fixing, @anijain2305 

@ydshieh, perhaps let's use this PR to add the CI bits?

> Thank you for fixing, @anijain2305
> 
> @ydshieh, perhaps let's use this PR to add the CI bits?

OK. I will push my work (on CI) to this PR.

Before merge, I would have to push to HF's transformers repo to test everything is fine.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_18685). All of your documentation changes will be reflected on that endpoint.

@ydshieh Please feel free to take over this PR. Do not hesitate to reach out to me if you see more Dynamo related errors.

I will open a tracker in Dynamo repo to avoid such failures in future.

@anijain2305 I rebase my branch on this PR

my branch: https://github.com/huggingface/transformers/commits/to_run_torchdynamo_tests

and it still has an error (for `test_torchdynamo_full_eval`)

```
    def on_enter():
        global most_recent_backend
        if (
            most_recent_backend is not None
            and most_recent_backend is not compiler_fn
        ):
>           raise ResetRequired()
E           torchdynamo.exc.ResetRequired: 
E           Must call `torchdynamo.reset()` before changing backends.  Detected two calls to
E           `torchdynamo.optimize(...)` with a different backend compiler arguments.
```
See this [run page](https://github.com/huggingface/transformers/runs/7914698826?check_suite_focus=true)

Add `torchdynamo.reset()` to some places in `test_torchdynamo_full_eval` should work I guess. But I prefer for you to push the change (to your PR), thank you.

Oh, that test was getting skipped for me. I am gonna send a patch.

@anijain2305 Ping me once it's ready on your side :-), thank you.

@anijain2305, @Chillee - we are excited to integrate your amazing work in our software and make it available to users. But please commit to support it. Otherwise we are spinning wheels waiting and waiting and things continue to remain broken meanwhile.

If you don't feel this is desirable any longer or if the situations has changed and you don't have the resources we can discuss removing what we has been added altogether and only re-add it once you officially release these new features as part of pytorch.

Thank you!


@ydshieh @stas00  Sorry about the long wait. I spent some time to setup trt earlier but was stuck, so this got delayed.

We are committed, and we still believe this is the right approach. Let me prioritize it this week. If I am still stuck with TRT install, I will ping.

Thank you for the follow up, @anijain2305! Please keep us posted on the progress.



@ydshieh Can you restart the CI on your branch when you get a chance with my latest changes?

> @ydshieh Can you restart the CI on your branch when you get a chance with my latest changes?

Sure. Will let you know

@anijain2305 The 2 failed tests now pass. I will incorporate your changes into my PR :-) Thanks a lot for the fix!

Thank you for the fix, @anijain2305! this is super helpful!