Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement function for BERT quantization tutorial, resolves issue #1971 #2403

Merged
merged 3 commits into from
Jun 2, 2023
Merged

Implement function for BERT quantization tutorial, resolves issue #1971 #2403

merged 3 commits into from
Jun 2, 2023

Conversation

JoseLuisC99
Copy link
Contributor

Fixes #1971

Fix missing implementation of ids_tensor.

@netlify
Copy link

netlify bot commented Jun 1, 2023

Deploy Preview for pytorch-tutorials-preview ready!

Name Link
🔨 Latest commit f36ee1e
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-tutorials-preview/deploys/647a19910e3f5f000702234b
😎 Deploy Preview https://deploy-preview-2403--pytorch-tutorials-preview.netlify.app/intermediate/reinforcement_ppo
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added quantization Issues relating to quantization tutorials docathon-h1-2023 A label for the docathon in H1 2023 easy and removed cla signed labels Jun 1, 2023
Copy link
Contributor

@carljparker carljparker left a comment

Choose a reason for hiding this comment

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

I continue to wonder about the name=None parameter, but it does exist in the version of this function at the following URL, so I guess we can keep it.

Quantizing BERT Model
https://pytorch.org/tutorials/prototype/graph_mode_dynamic_bert_tutorial.html?highlight=transformer#setup

@carljparker carljparker merged commit b966c1f into pytorch:main Jun 2, 2023
7 checks passed
for _ in range(total_dims):
values.append(rng.randint(0, vocab_size - 1))

return torch.tensor(data=values, dtype=torch.long, device='cpu').view(shape).contiguous()
Copy link
Contributor

Choose a reason for hiding this comment

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

This would create int64 tensor, not int32 one, wouldn't it?

Comment on lines +532 to +544
# Creates a random int32 tensor of the shape within the vocab size
if rng is None:
rng = global_rng

total_dims = 1
for dim in shape:
total_dims *= dim

values = []
for _ in range(total_dims):
values.append(rng.randint(0, vocab_size - 1))

return torch.tensor(data=values, dtype=torch.long, device='cpu').view(shape).contiguous()
Copy link
Contributor

@malfet malfet Jun 3, 2023

Choose a reason for hiding this comment

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

Also, isn't it all just equivalent of

    return torch.randint(0, vocab_size, shape=shape, dtype=torch.int, device='cpu')

Copy link
Contributor

Choose a reason for hiding this comment

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

@JoseLuisC99 JoseLuisC99 deleted the resolve-1971 branch June 3, 2023 03:50
@svekars svekars added docathon-h1-2023 A label for the docathon in H1 2023 and removed docathon-h1-2023 A label for the docathon in H1 2023 labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docathon-h1-2023 A label for the docathon in H1 2023 easy quantization Issues relating to quantization tutorials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ids_tensor function not defined in bert quantization tutorial
5 participants