[jit] clean up exported source format#26788
Conversation
The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test.
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
suo
left a comment
There was a problem hiding this comment.
Looks good to me generally and cleans things up nicely. I think we need to split up the land of this for forward compat reasons though; please do that before landing.
| if (env_.count("torch") == 0) { | ||
| env_["torch"] = std::make_shared<BuiltinModule>("aten", version); | ||
| env_["ops"] = std::make_shared<OpsValue>(version); | ||
| void parsePossibleVersionNumber(Lexer& L) { |
There was a problem hiding this comment.
Trying to figure out what exactly the forward compat implications are here. We already removed the necessity for import statements so that doesn't matter I guess.
So it seems the only thing left is the version number. If a newer version exports a model without the version number and a newer version tries to read it and fails, we will leave users in a bad spot.
We could avoid this by landing this change making the version number optional, waiting a bit, then landing the part of the code that removes that. Since this breakage happens on every model (since version numbers are put in every file today), I think it's worth doing the extra work to avoid the forward compat breakage.
|
|
||
| ~PythonPrintImpl() {} | ||
|
|
||
| private: |
There was a problem hiding this comment.
yes, the class is private to the file now, so there is no need to further protect its members.
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
[jit] clean up exported source format The previous PR in the stack removed the need to order classes/functions or have correct import statements. This resolved circular depedency issues that can arise when class constructors like ModuleList put new instances of themselves in a common namespace. This PR changes our export format to no longer produce this information. By doing so we can make the logic signficantly simpler, since we just keep track of an individual PythonPrint object per file. Notes: * PythonPrint was changed to manage its own stream/list of ranges. It was doing this anyway internally, this just makes the API more clear. * Since we are changing the serialization format, I also removed op_version_set. It is now replaced with the VERSION number that written in the zip archive. This further simplifies the code emission process. * A test of op_version_set was removed since there is no longer any behavior to test. gh-metadata: pytorch pytorch 26788 gh/zdevito/118/head
Stack from ghstack:
The previous PR in the stack removed the need to order classes/functions
or have correct import statements. This resolved circular depedency issues
that can arise when class constructors like ModuleList put new instances
of themselves in a common namespace.
This PR changes our export format to no longer produce this information.
By doing so we can make the logic signficantly simpler, since we just
keep track of an individual PythonPrint object per file.
Notes:
was doing this anyway internally, this just makes the API more clear.
It is now replaced with the VERSION number that written in the zip archive.
This further simplifies the code emission process.
to test.
Differential Revision: D17566438