Skip to content

Liquid Foundation Model 2 support#2905

Merged
winglian merged 5 commits into
mainfrom
lfm2
Jul 12, 2025
Merged

Liquid Foundation Model 2 support#2905
winglian merged 5 commits into
mainfrom
lfm2

Conversation

@winglian

@winglian winglian commented Jul 11, 2025

Copy link
Copy Markdown
Collaborator

Description

LFM2 blog post: https://www.liquid.ai/blog/liquid-foundation-models-v2-our-second-series-of-generative-ai-models

added example with packing (seems to work correctly even though causal_conv1d support isn't quite correct for packed sequences yet, see #state-spaces/mamba/244)

to add proper packing implemented in modeling code might look like this
https://github.com/zigzagcai/varlen_mamba/blob/feat/add-cu_seqlens/mamba_ssm/modules/mamba_simple.py#L188-L198

if cu_seqlens is not None:
    # naive pure python implementation of varlen causal_conv1d
    for i, s in enumerate(cu_seqlens[1:-1]):
        x = torch.cat((x[..., :s + i*(self.d_conv - 1)], torch.zeros_like(x[..., :(self.d_conv - 1)]), x[..., s + i*(self.d_conv - 1):]), dim=2)
    mask = torch.cat([torch.cat((torch.full((s,), True, dtype=torch.bool, device=x.device), 
                                 torch.full((self.d_conv - 1,), False, dtype=torch.bool, device=x.device)), dim=0) 
                      for s in (cu_seqlens[1:] - cu_seqlens[:-1])], dim=0)
    x = self.act(self.conv1d(x)[:, :, mask])
else:
    x = self.act(self.conv1d(x)[..., :seqlen])

Summary by CodeRabbit

Summary by CodeRabbit

  • Documentation

    • Added a README file for the Liquid Foundation Models 2 (LFM2) example, including installation instructions for the latest transformers library.
  • New Features

    • Introduced a configuration file for training the LFM2-350M model, detailing dataset settings and training parameters.

@coderabbitai

coderabbitai Bot commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Two new files have been added under the LFM2 examples: a README providing installation guidance for the latest transformers library, and a YAML configuration file detailing dataset, training, and logging parameters for the LFM2-350M model.

Changes

File(s) Change Summary
examples/lfm2/README.md Added a README with installation instructions for using LFM2 with the latest transformers branch.
examples/lfm2/lfm2-350m-fft.yaml Added a YAML config specifying dataset, training, and logging parameters for LFM2-350M training.

Suggested reviewers

  • NanoCode012

Poem

In the warren of code, a new path appears,
With configs and docs, the intent is clear.
LFM2 now trains, with YAML in tow,
And README instructions for those in the know.
A hop and a skip, let experiments begin—
May your models be swift and your losses be thin! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 310caf2 and 7c6c10e.

📒 Files selected for processing (1)
  • examples/lfm2/lfm2-350m-fft.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/lfm2/lfm2-350m-fft.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: pre-commit
  • GitHub Check: preview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions

github-actions Bot commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

📖 Documentation Preview: https://6871e07b86558bdf0f609fce--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit 7c6c10e

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
examples/lfm2/lfm2-350m-fft.yaml (2)

21-26: Blank WandB fields may cause silent auto-init.

When wandb_project is empty, WandB will fall back to your global default or open an anonymous run, which can be confusing.

Either:

-wandb_project:
+wandb_project: lfm2-experiments

or explicitly disable WandB with wandb: disabled in the launcher.


17-20: pad_to_sequence_len: false + long context may hurt throughput.

Without sample packing and without padding, each example is individually 0-padded to its own length ⇒ poor GPU utilisation on chat datasets with large length variance.

Consider enabling padding to fixed sequence_len once sample-packing support lands, or set sequence_len closer to your dataset’s 90-th percentile length.

examples/lfm2/README.md (1)

3-7: Pin the transformers commit for reproducibility.

pip install git+https://github.com/huggingface/transformers.git pulls moving main, which breaks reproducibility and may introduce incompatible API changes.

pip install git+https://github.com/huggingface/transformers.git@<commit-sha>

Replace <commit-sha> with the commit you validated this example against and mention it in the README.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03b2a11 and 9ea9a7d.

📒 Files selected for processing (2)
  • examples/lfm2/README.md (1 hunks)
  • examples/lfm2/lfm2-350m-fft.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: pre-commit
  • GitHub Check: preview
🔇 Additional comments (1)
examples/lfm2/lfm2-350m-fft.yaml (1)

30-33: Learning rate looks aggressive for 350 M model.

5e-5 with AdamW-fused and cosine schedule tends to diverge when fine-tuning full-precision 350 M models on long-context data. Common practice is 1–2e-5.

Please sanity-check with a short ~200-step pilot run and inspect loss curves.

Comment thread examples/lfm2/lfm2-350m-fft.yaml
Comment thread examples/lfm2/lfm2-350m-fft.yaml

@djsaunde djsaunde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I need to read about this 👀

Comment thread examples/lfm2/README.md
@@ -0,0 +1,7 @@
# Liquid Foundation Models 2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

TIL about liquid foundation models

Comment thread examples/lfm2/README.md Outdated
LFM2 support in transformers exists in the main branch, but is not yet included in the transformers release.

```bash
pip install git+https://github.com/huggingface/transformers.git

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

--upgrade --no-deps maybe?

@winglian winglian merged commit 9a8073e into main Jul 12, 2025
4 checks passed
@winglian winglian deleted the lfm2 branch July 12, 2025 15:41
@coderabbitai coderabbitai Bot mentioned this pull request Aug 14, 2025
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.

3 participants