Skip to content

Conversation

@linziyi96
Copy link
Contributor

No description provided.

This commit makes two changes during model creation:
1. Decouples promote_trainable_params_to_fp32 from model __init__. This
   is to avoid casting to fp32 to save memory in inference-only mode
   (#4).
2. Use a context manager to manage default tensor type change. In the
   previous version, the default tensor type is reset to
   torch.FloatTensor after creating the vision model, which is
   technically incorrect and should be the previous default tensor type
   instead. We implement our own context manager because the official
   context managers seem to be incomplete at this time (PyTorch 2.0.1):
   No dtype manager is provided and set_default_device is ineffective to
   the torch.Tensor calls which are used in fairscale.
It is probably safer to keep CLIP at its original precision (e.g., fp16)
regardless of the autocast setting: Some casting (e.g., from fp16 to
bf16) may be lossy and can potentially harm the pre-trained model.

Keep the changes to llama.py only at this moment since a lot of copy-
pasted codes may be refactored in the future (#3).
Checkpoint merge is suported in misc/tensor_parallel.py. Merge requires
that the checkpoint_mp_world_size % mp_world_size == 0. Support for
split (i.e., when mp_world_size % checkpoint_mp_world_size == 0) and
redistribute (for general mp_world_size and checkpoint_mp_world_size
values) will be added in the future.

Also changing multi_turn demo to use the new loading function with merge
support.
@linziyi96 linziyi96 merged commit ab84c96 into main Aug 4, 2023
@linziyi96 linziyi96 deleted the multi_turn_demo_dev branch August 20, 2023 14:14
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.

2 participants