-
Notifications
You must be signed in to change notification settings - Fork 31.3k
Add model visual debugger #36798
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
Add model visual debugger #36798
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
ArthurZucker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nice! Just missing something like register_model_for_debug(LlamaModel) !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove this/move it to another PR, with #36827 done we should be able to get rid of this check in make fixup
| To note, this decorator enforces `torch.inference_mode()`. | ||
| ## Usage | ||
| add decorator to your model class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would put this in the model_debugging_utils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in the doc :) not sure of the output cause the builder is broken currently
* draft of model tracer visualiser * add context manager in addition to decorator * add debug utils to init * move model debugging utils to dedicated file * add documentation * protect some imports * format * move and protect imports * format * doc: improve errors in case of broken dummy imports. * format * use automatic torch backend * update doc * fix backend * (TEMP) move to dummies while backend wait * update documentation * doc
What does this PR do?
This PR introduces a tool to trace ALL model inputs and outputs to a json nested format. Main values, shapes, dtypes are all outputted.
Usage
It's a simple context manager to add before calling a forward on your inputs. To note,
inference_modeis enforced here.Why??
Because when porting models to
transformers, even from python to python, model adders often have to do a lot of manual operations, involving saving and loading tensors, comparing dtypes, etc. This small tool can hopefully shave off some time.Example output
Here, you can see two jsons of the same model, where the sole difference is the epsilon of a layer normalization. I added the decorator, and we can see with string matching that the outputs start to differ. I'll include a snippet with
difflibtoo I think to make it simpler.