Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Aug 19, 2020

Stack from ghstack:

IR emitter uses ModuleValue to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

ModuleValue relies on two pieces of information, the JIT type of the
module, and the ConcreteModuleType, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: D23228738

…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

[ghstack-poisoned]
@suo suo requested a review from apaszke as a code owner August 19, 2020 23:18
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Aug 19, 2020
@dr-ci
Copy link

dr-ci bot commented Aug 19, 2020

💊 CI failures summary and remediations

As of commit 42cf2bd (more details on the Dr. CI page):


  • 2/2 failures possibly* introduced in this PR
    • 2/2 non-CircleCI failure(s)

ci.pytorch.org: 2 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 43 times.

…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

[ghstack-poisoned]
suo added a commit that referenced this pull request Aug 19, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: 5fb8f8a
Pull Request resolved: #43298
…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: [D23228738](https://our.internmc.facebook.com/intern/diff/D23228738)

[ghstack-poisoned]
suo added a commit that referenced this pull request Aug 20, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: 00997e5
Pull Request resolved: #43298
@suo suo requested a review from SplitInfinity August 24, 2020 19:21
Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional question: do we need to do anything for function attributes? I see that they are part of the ConcreteModuleType, but not the JIT type.

// Populate the builder metadata from the JIT type. This is to ensure
// ConcreteModuleTypes produced from Python and ones produced from a JIT
// type directly behave the same to the rest of the system.
for (size_t i = 0; i < classType->numAttributes(); i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (size_t i = 0; i < classType->numAttributes(); i++) {
for (size_t i = 0, e = classType->numAttributes(); i < e, i++) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes the code a little less readable for no clear benefit, so I'm going to skip this one unless you feel strongly about it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer my suggestion to avoid making an extra function call every time the loop exit condition is tested: https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop

But numAttributes() is not an expensive call, so I will not lose sleep over this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I would expect a compiler to inline and then avoid recomputing numAttributes(). I think the suggestion makes more sense if we are computing the iterator of a complicated data structure instead of returning an int. Although if the data structure is that complicated, writing a raw for loop over its iterator is probably bad to begin with…

}
}

for (size_t i = 0; i < classType->numConstants(); i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (size_t i = 0; i < classType->numConstants(); i++) {
for (size_t i = 0, e = classType->numConstants(); i < e, i++) {

@suo
Copy link
Member Author

suo commented Aug 25, 2020

One additional question: do we need to do anything for function attributes? I see that they are part of the ConcreteModuleType, but not the JIT type.

Anything that is not representable on the JIT type can't be captured here. This makes saving/loading a "lossy", since once you save/load all you have is a JIT type, and lose all the other Python-y bits like function attributes, module iterator kind, etc. The way to reduce this lossiness is by making more things representable first-class on the JIT type.

…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: [D23228738](https://our.internmc.facebook.com/intern/diff/D23228738)

[ghstack-poisoned]
suo added a commit that referenced this pull request Aug 25, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: 6baa83f
Pull Request resolved: #43298
@suo suo requested a review from SplitInfinity August 25, 2020 18:38
// Populate the builder metadata from the JIT type. This is to ensure
// ConcreteModuleTypes produced from Python and ones produced from a JIT
// type directly behave the same to the rest of the system.
for (size_t i = 0; i < classType->numAttributes(); i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer my suggestion to avoid making an extra function call every time the loop exit condition is tested: https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop

But numAttributes() is not an expensive call, so I will not lose sleep over this.

…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: [D23228738](https://our.internmc.facebook.com/intern/diff/D23228738)

[ghstack-poisoned]
suo added a commit that referenced this pull request Aug 27, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: 40135c8
Pull Request resolved: #43298
Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: [D23228738](https://our.internmc.facebook.com/intern/diff/D23228738)

[ghstack-poisoned]
suo added a commit that referenced this pull request Aug 31, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: 6c20331
Pull Request resolved: #43298
…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: [D23228738](https://our.internmc.facebook.com/intern/diff/D23228738)

[ghstack-poisoned]
suo added a commit that referenced this pull request Sep 2, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: e0c6e82
Pull Request resolved: #43298
…eshly created ones"

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

Differential Revision: [D23228738](https://our.internmc.facebook.com/intern/diff/D23228738)

[ghstack-poisoned]
suo added a commit that referenced this pull request Sep 3, 2020
…ed ones

IR emitter uses `ModuleValue` to represent ScriptModules and emit IR for
attribute access, submodule access, etc.

`ModuleValue` relies on two pieces of information, the JIT type of the
module, and the `ConcreteModuleType`, which encapsulates Python-only
information about the module.

ScriptModules loaded from a package used to create a dummy
ConcreteModuleType without any info in it. This led to divergences in
behavior during compilation.

This PR makes the two ways of constructing a ConcreteModuleType equivalent,
modulo any py-only information (which, by definition, is never present in
packaged files anyway).

ghstack-source-id: 9caee09
Pull Request resolved: #43298
@codecov
Copy link

codecov bot commented Sep 3, 2020

Codecov Report

Merging #43298 into gh/suo/345/base will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@               Coverage Diff                @@
##           gh/suo/345/base   #43298   +/-   ##
================================================
  Coverage            69.27%   69.27%           
================================================
  Files                  381      381           
  Lines                47265    47265           
================================================
+ Hits                 32744    32745    +1     
+ Misses               14521    14520    -1     
Impacted Files Coverage Δ
torch/testing/_internal/expecttest.py 77.55% <0.00%> (-1.03%) ⬇️
torch/utils/_benchmark/utils/common.py 78.99% <0.00%> (+1.68%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 653f684...42cf2bd. Read the comment docs.

@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in 9dd8670.

@facebook-github-bot facebook-github-bot deleted the gh/suo/345/head branch September 7, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants