Skip to content

Conversation

@neuropilot-captain
Copy link
Collaborator

This PR contains the following modifications/udpates:

  • Add Llama 3.2 related files
  • Fix bug for tie word embeddings weight naming
  • Exclude embedding .bin file during weight checking in sanity checks
  • Get Embedding layer before loading of main model if calibration dataset provided to prevent tied word embedding weight name from being removed from state dict during main model weight loading
  • Add keep_in_memory during dataset mapping function to prevent disk out of space issue

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 8, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6726

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit fc75330 with merge base 97a4600 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 8, 2024
Copy link
Contributor

@cccclai cccclai left a comment

Choose a reason for hiding this comment

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

Most nit comments, thank you for adding support for 3.2

"eos_token_id_tensor": torch.tensor(tokenizer.eos_token_id),
"response_cap": args.response_cap,
},
keep_in_memory=True
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind sharing what is keep in memory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @cccclai, keep in memory stores the dataset in RAM instead of caching it. It was a temporary workaround for an OSError I encountered on my end. I have since resolved the issue and will remove this argument in the next commit.

if get_dym_shape:
nt = Dim("num_token", max=num_token)
cache_dims = tuple(({} for _ in range(2 * self.num_blocks)))
dynamic_shapes = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I may ask in the previous PR - what does dynamic_shape do? Probably good to add a comment to explain

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @cccclai, dynamic_shape is passed in to torch.export.export_for_training to indicate that the input shapes during calibration for some of the inputs may be different. After calibration, the dynamic_shape argument is not needed

cal_dataset = None
if args.dataset is not None:
cal_dataset = load_dataset("text", data_files=args.dataset, split="train")
embedding_layer = get_embedding_layer(config, weight_dir, state_dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason to remove this line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I didn't remove it. I shifted it above to line 422. The reason being that during chunk.load_weights (line 437), the weights are popped from the original state_dict and for the tie word embedding True case, this would mean that the embedding weights are not present in the state_dict anymore by the time we get the embedding layer, hence I shifted it up

@cmodi-meta
Copy link
Contributor

Thanks @neuropilot-captain! do we also need to make to the examples/mediatek/shell_scripts/export_llama.sh file to include Llama 3.2 1B and 3B model in the if-else conditions?

@cccclai
Copy link
Contributor

cccclai commented Nov 9, 2024

There are some lint errors. Could you send a fix?

@neuropilot-captain
Copy link
Collaborator Author

Thanks @neuropilot-captain! do we also need to make to the examples/mediatek/shell_scripts/export_llama.sh file to include Llama 3.2 1B and 3B model in the if-else conditions?

Hi @cmodi-meta, yes the script would need to be modified to include Llama 3.2 1B and 3B in the if else. I can modify the script and update it in the next commit

@facebook-github-bot
Copy link
Contributor

@cccclai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot merged commit 5663e3c into pytorch:main Nov 15, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants