Skip to content

Add iter singular value into TBE optimizer state#3228

Closed
csmiler wants to merge 1 commit into
pytorch:mainfrom
csmiler:export-D63909559
Closed

Add iter singular value into TBE optimizer state#3228
csmiler wants to merge 1 commit into
pytorch:mainfrom
csmiler:export-D63909559

Conversation

@csmiler

@csmiler csmiler commented Oct 7, 2024

Copy link
Copy Markdown

Summary:
When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the iter number is a single value tensor, which cannot be tracked and checkpointed properly (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value iter can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

Differential Revision: D63909559

@netlify

netlify Bot commented Oct 7, 2024

Copy link
Copy Markdown

Deploy Preview for pytorch-fbgemm-docs failed.

Name Link
🔨 Latest commit 4c23038
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/6708036ccbfc730008d25c18

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63909559

csmiler pushed a commit to csmiler/FBGEMM that referenced this pull request Oct 9, 2024
Summary:
X-link: meta-pytorch/torchrec#2474


X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: spcyppt

Differential Revision: D63909559
csmiler pushed a commit to csmiler/FBGEMM that referenced this pull request Oct 9, 2024
Summary:
X-link: meta-pytorch/torchrec#2474


X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559
csmiler pushed a commit to csmiler/torchrec that referenced this pull request Oct 9, 2024
Summary:

X-link: pytorch/FBGEMM#3228

X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63909559

csmiler pushed a commit to csmiler/FBGEMM that referenced this pull request Oct 10, 2024
Summary:
X-link: meta-pytorch/torchrec#2474


X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559
csmiler pushed a commit to csmiler/torchrec that referenced this pull request Oct 10, 2024
Summary:

X-link: pytorch/FBGEMM#3228

X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63909559

Summary:
X-link: meta-pytorch/torchrec#2474


X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559
csmiler pushed a commit to csmiler/torchrec that referenced this pull request Oct 10, 2024
Summary:

X-link: pytorch/FBGEMM#3228

X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63909559

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in f9f0600.

facebook-github-bot pushed a commit to meta-pytorch/torchrec that referenced this pull request Oct 11, 2024
Summary:
Pull Request resolved: #2474

X-link: pytorch/FBGEMM#3228

X-link: facebookresearch/FBGEMM#326

When the optimizer states for sharded embedding tables are tracked in TorchRec, they are assumed to be either point-wise (same shape as the embedding table, for example, Adam's exp_avg), or row-wise (same length as the embedding hashsize, for example, rowwise_adagrad's momentum/sum). However, there may be other formats, a single value for each table. Specifically, for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb and GWD, the `iter` number is a single value tensor, which **cannot be tracked and checkpointed properly** (this also means that there is a bug in Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb usages!)

Here we support tracking and checkpointing single-value states, by constructing ShardMetadata with rowwise-sharding and replicating the single-value for each Sharded param (this is similar to how the rowwise state for colume-wise sharded tables are concatenated along row-dim).

By doing so, single-value `iter` can be properly checkpointed just like other states, ensuring correct reloading of states and continuous training.

This diff checkpoints `iter` for rowwise_adagrad with GWD. The next diff would checkpoint `iter` for Adam/Partial_rowwise_adam/Lamb/Partial_rowwise_lamb.

Reviewed By: iamzainhuda, spcyppt

Differential Revision: D63909559

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants