-
Notifications
You must be signed in to change notification settings - Fork 654
model : support LiquidAI LFM2 hybrid family #13805
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
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13805
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 32441b0 with merge base 1520f9f ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Hi @tdakhran! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, can you try running with the C++ runner? https://github.com/pytorch/executorch/blob/main/examples/models/llama/README.md#step-3-run-on-your-computer-to-validate
} | ||
|
||
|
||
def lfm_2_tune_to_meta(state_dict: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just call this lfm_2_to_meta
, I think some of the others are only named that way because we used to use TorchTune to load the checkpoints
|
||
from torchtune.models.convert_weights import get_mapped_key | ||
|
||
_LFM_2_FROM_META = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LFM_2_FROM_META = { | |
_LFM_2_TO_META = { |
And reverse keys and values
Dict[str, torch.Tensor]: State dict in Meta's format. | ||
""" | ||
converted_state_dict = {} | ||
inverted_mapping_dict = {v: k for k, v in _LFM_2_FROM_META.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inverted_mapping_dict = {v: k for k, v in _LFM_2_FROM_META.items()} | |
inverted_mapping_dict = {v: k for k, v in _LFM_2_FROM_META.items()} |
Remove, use _LFM_2_TO_META
Please rebase to main and resolve the conflicts Don't merge yet, I will have to import internally and run a few internal tests. |
Add support for [LiquidAI LFM2](https://huggingface.co/collections/LiquidAI/lfm2-686d721927015b2ad73eaa38) model family. For more information about models, please read [the blog post](https://www.liquid.ai/blog/liquid-foundation-models-v2-our-second-series-of-generative-ai-models). - Support hybrid LFM2-350M, LFM2-700M, and LFM2-1.2B models. - Add `ShortConvBlock`. - Modify `construct_transformer` to construct hybrid architectures. - Move FeedForward to avoid cyclid dependency
73aa3b8
to
32441b0
Compare
@jackzhxng @mergennachin thanks for the review, I've rebased and addressed the feedback. All commands in README.md work, including the C++ runner. However, the C++ runner output differs from the Python runner. |
Summary
Add support for LiquidAI LFM2 model family. For more information about models, please read the blog post.
ShortConvBlock
.construct_transformer
to construct hybrid architectures.Instructions are in
examples/models/lfm2/README.md
.Test plan
All commands in
README.md
are tests.