Skip to content

New serialization format#12384

Closed
houseroad wants to merge 15 commits intopytorch:masterfrom
houseroad:torchproto2
Closed

New serialization format#12384
houseroad wants to merge 15 commits intopytorch:masterfrom
houseroad:torchproto2

Conversation

@houseroad
Copy link
Copy Markdown
Member

@houseroad houseroad commented Oct 5, 2018

Addressed Dima's feedback.

The proposal is here: https://fb.quip.com/TbQmAuqIznCf

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

dzhulgakov has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@houseroad houseroad requested a review from jamesr66a October 8, 2018 22:05
Copy link
Copy Markdown
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

I'd like to see a better overall picture about where this is going in the long term. When we are done merging the formats, what do we want the new format to be?

The format as-is seems like a mishmash of random fields needed by caffe2's current model and a few places string for where a future torch models format would fit in. It feels like it is code that we will have to clean up in the future. There are tons of Argument and NetDef fields sitting throughout the format. Some input/output fields in MethodDef will be redundant with how torch represents networks. I also do not see how Tensors will be stored with proper storages where two tensors can be views of the same storage. This is an important part of the PyTorch format.

I'd like to get this to the point where the core structure reflects the ideal we are working toward that will be shared by all of our serialization formations, with the per-backend fields put inside sub objects. Otherwise it is very hard to see what can be shared among formats vs what is only filled in for a specific format.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Copy Markdown
Member Author

@houseroad houseroad left a comment

Choose a reason for hiding this comment

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

Great thanks to @zdevito for the valuable input! I agree with that we should have a clean design at this moment instead of cleaning it up in the future. I will remove the unnecessary fields, make sure that from the organization side, nothing looks redundant.

At high level, since right now we need to support both static graph and torch script, we aim unifying the model format (proto), APIs and tooling. Later when everything is ready, we can start unifying the methods.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Comment thread caffe2/core/blob_serialization.cc Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Copy Markdown
Collaborator

@dzhulgakov dzhulgakov left a comment

Choose a reason for hiding this comment

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

For the OpDef changes - they probably require the longer discussion on input/argument distinction and what's the longer term migration path. Before that discussion adding random fields might be premature. So if you want to proceed with other parts of this diff (modules and tensors) - maybe commenting out and keeping NetDef as is mostly is best.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/core/blob_serialization.cc Outdated
Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Member Author

@houseroad houseroad left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the valuable inputs from @Yangqing @dzhulgakov @kennyhorror .

I have made the following changes:

  1. premature design are removed, i.e., named_inputs/outputs and Non-tensor type support
  2. unnecessary fields are removed, e.g., debug_info in multiple structures
  3. extract external data into a separate structure, strides and id/path are binded to ExternalData
  4. add another layer of abstract - ParameterDef, and move is_buffer and requires_gradient to it
  5. more comments are added

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated
Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Collaborator

@dzhulgakov dzhulgakov left a comment

Choose a reason for hiding this comment

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

minor naming tweaks and ship it

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

Comment thread caffe2/proto/caffe2.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread caffe2/proto/torch.proto Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@Yangqing
Copy link
Copy Markdown
Contributor

Maybe a rebase and see if circleCI passes? It is showing weird failure at the moment.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@houseroad
Copy link
Copy Markdown
Member Author

Yeah, I guess some docker images are updated and this caused the problems. Just rebased the PR, and let's see.

@ezyang ezyang added the merged label Jun 26, 2019
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Addressed Dima's feedback.

The proposal is here: https://fb.quip.com/TbQmAuqIznCf
Pull Request resolved: pytorch#12384

Reviewed By: dzhulgakov

Differential Revision: D10246743

Pulled By: houseroad

fbshipit-source-id: c80db0c35d60ca32965275da705f2b1dfb2a7265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants