Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Jul 1, 2020

Stack from ghstack:

TracingState::setValue associates a concrete IValue in the traced
program with a Value* symbolic. Previously, the logic for how
GenericDicts worked was special cased to only work for very simple cases
and silently eat other cases.

This PR generalizes the logic to reflect the same behavior as using
dictionaries on input: whenever we encounter a dictionary in the system,
we completely "burn in" all the keys into the graph, and then
recursively call setValue on the associated value.

This has the effect of requiring that any dictionary structure you are
creating in a traced program be of fixed structure, similar to how any
dictionary used as input must be static as well.

Differential Revision: D22342490

`TracingState::setValue` associates a concrete IValue in the traced
program with a `Value*` symbolic. Previously, the logic for how
GenericDicts worked was special cased to only work for very simple cases
and silently eat other cases.

This PR generalizes the logic to reflect the same behavior as using
dictionaries on input: whenever we encounter a dictionary in the system,
we completely "burn in" all the keys into the graph, and then
recursively call `setValue` on the associated value.

This has the effect of requiring that any dictionary structure you are
creating in a traced program be of fixed structure, similar to how any
dictionary used as input must be static as well.

[ghstack-poisoned]
@suo suo requested a review from apaszke as a code owner July 1, 2020 21:28
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jul 1, 2020
@suo suo linked an issue Jul 1, 2020 that may be closed by this pull request
@suo suo requested review from jamesr66a and wanchaol July 1, 2020 21:38
@dr-ci
Copy link

dr-ci bot commented Jul 1, 2020

💊 CI failures summary and remediations

As of commit 4aba185 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


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 3 times.

Copy link
Collaborator

@wanchaol wanchaol left a comment

Choose a reason for hiding this comment

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

looks good!

}
if (value_type->cast<TensorType>()) {
handle_unpack(aten::values);
for (const auto& entry : dict) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will actually implies that if dict[tensor, tensor] (tensor as keys) as input or cross tracing/scripting, the tensor key will always be treated as constant, which is ok, but I am wondering if we should throw some warning here to user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, I filed #40886 as a followup to improve the error messaging in all cases where a key mismatch occurs

setValue(entry.value(), static_value);
}
} else {
std::ostringstream os;
Copy link
Collaborator

Choose a reason for hiding this comment

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

error message seems out dated

`TracingState::setValue` associates a concrete IValue in the traced
program with a `Value*` symbolic. Previously, the logic for how
GenericDicts worked was special cased to only work for very simple cases
and silently eat other cases.

This PR generalizes the logic to reflect the same behavior as using
dictionaries on input: whenever we encounter a dictionary in the system,
we completely "burn in" all the keys into the graph, and then
recursively call `setValue` on the associated value.

This has the effect of requiring that any dictionary structure you are
creating in a traced program be of fixed structure, similar to how any
dictionary used as input must be static as well.

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

[ghstack-poisoned]
suo added a commit that referenced this pull request Jul 1, 2020
`TracingState::setValue` associates a concrete IValue in the traced
program with a `Value*` symbolic. Previously, the logic for how
GenericDicts worked was special cased to only work for very simple cases
and silently eat other cases.

This PR generalizes the logic to reflect the same behavior as using
dictionaries on input: whenever we encounter a dictionary in the system,
we completely "burn in" all the keys into the graph, and then
recursively call `setValue` on the associated value.

This has the effect of requiring that any dictionary structure you are
creating in a traced program be of fixed structure, similar to how any
dictionary used as input must be static as well.

ghstack-source-id: 248b423
Pull Request resolved: #40885
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in 9fa1f27.

@facebook-github-bot facebook-github-bot deleted the gh/suo/337/head branch July 5, 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.

Inconsistent behavior when tracing dictionaries

5 participants