Skip to content

Set teacher ckptr output_dir to match student in KD configs #2185

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

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

ebsmothers
Copy link
Contributor

@ebsmothers ebsmothers commented Dec 19, 2024

There are still a few cases left that will raise errors after #2181. This PR changes the rest of them (just the teacher checkpointer in our KD recipes). Since we don't write the teacher checkpoints anyways this is a no-op.

Python script to find all such instances where checkpointer.checkpoint_dir == checkpointer.output_dir:

import os
from omegaconf import OmegaConf

def main():
    for root, dirs, files in os.walk("/data/users/ebs/ebs-torchtune-alt/recipes"):
        for file in files:
            if file.endswith(".yaml"):
                # print(root, dirs, file)
                cfg = OmegaConf.load(os.path.join(root, file))
                OmegaConf.resolve(cfg)
                for k in cfg:
                    if "checkpointer" in k:
                        checkpointer_cfg = cfg.get(k, {})
                        output_dir = checkpointer_cfg.get('output_dir', None)
                        checkpoint_dir = checkpointer_cfg.get('checkpoint_dir', None)
                        if output_dir == checkpoint_dir:
                            print(os.path.join(root, file), k)

if __name__ == "__main__":
    main()

Test plan

tune run knowledge_distillation_single_device --config llama3_2/8B_to_1B_KD_lora_single_device \
max_steps_per_epoch=5 epochs=2
...
rm -r /tmp/torchtune/llama3_2_8B_to_1B/KD_lora_single_device/epoch_1
tune run knowledge_distillation_single_device --config llama3_2/8B_to_1B_KD_lora_single_device \
max_steps_per_epoch=5 epochs=2 resume_from_checkpoint=True
...
INFO:torchtune.utils._logging:Loss is initialized.
INFO:torchtune.utils._logging:Dataset and Sampler are initialized.
INFO:torchtune.utils._logging:Learning rate scheduler is initialized.
WARNING:torchtune.utils._logging: Profiling disabled.
INFO:torchtune.utils._logging: Profiler config after instantiation: {'enabled': False}
2|10|Loss: 1.7557275295257568: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:11<00:00,  2.22s/it]INFO:torchtune.utils._logging:Model checkpoint of size 2.30 GiB saved to /tmp/torchtune/llama3_2_8B_to_1B/KD_lora_single_device/epoch_1/ft-model-00001-of-00001.safetensors
INFO:torchtune.utils._logging:Adapter checkpoint of size 0.08 GiB saved to /tmp/torchtune/llama3_2_8B_to_1B/KD_lora_single_device/epoch_1/adapter_model.pt
INFO:torchtune.utils._logging:Adapter checkpoint of size 0.08 GiB saved to /tmp/torchtune/llama3_2_8B_to_1B/KD_lora_single_device/epoch_1/adapter_model.safetensors
INFO:torchtune.utils._logging:Adapter checkpoint of size 0.00 GiB saved to /tmp/torchtune/llama3_2_8B_to_1B/KD_lora_single_device/epoch_1/adapter_config.json

Copy link

pytorch-bot bot commented Dec 19, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/2185

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

✅ No Failures

As of commit 1858150 with merge base cdf5ea2 (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 Dec 19, 2024
@ebsmothers ebsmothers changed the title Set teacher checkpointer output_dir to match student Set teacher ckptr output_dir to match student in KD configs Dec 19, 2024
Copy link
Contributor

@felipemello1 felipemello1 left a comment

Choose a reason for hiding this comment

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

it would be much better if we could pass None to all of these configs that dont need an output_dir, otherwise it gives an impression that it does something

@felipemello1 felipemello1 merged commit 46a1ef0 into pytorch:main Dec 19, 2024
17 checks passed
mori360 pushed a commit to mori360/torchtune that referenced this pull request Dec 20, 2024
rahul-sarvam pushed a commit to sarvamai/torchtune that referenced this pull request Dec 23, 2024
rahul-sarvam pushed a commit to sarvamai/torchtune that referenced this pull request Dec 23, 2024
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.

3 participants