Open-source project
mlfoundations/open_clip avatar
mlfoundations/open_clip

OpenCLIP after the training refactor: what the main branch actually expects from you

An open source implementation of CLIP.

14,144 stars1,309 forksPythonNOASSERTION

At a glance

What is it?
OpenCLIP is the open implementation of CLIP that most teams reach for when they want pretrained image-text models or a training stack they can modify. The main branch has moved well past the original release, and the README says so in its own warning box.
Who is it for?
Adopt OpenCLIP for pretrained image-text inference and for zero-shot classification work, and treat the main branch as a moving training target rather than a stable one. If your training scripts were written against the older API, pin to the v3 branch or the latest 3.x release on PyPI before you touch anything else.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 7 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The gap OpenCLIP fills between a paper and a runnable checkpoint

CLIP-style contrastive pretraining is easy to describe and tedious to reproduce. OpenCLIP exists to close that gap: it is an open source implementation of CLIP, written in Python, with pretrained models and a training stack you can read and modify. The repository topics list the intended surface: computer vision, contrastive loss, multi-modal learning, pretrained models, PyTorch, zero-shot classification. That is the audience. Someone who wants a pretrained image-text encoder to run zero-shot classification today, or someone who wants to train or fine-tune a contrastive model and cannot do it inside a closed codebase. The README's own framing separates the two uses. Inference with pretrained image and text models is described as still intended to be compatible across the refactor. Training scripts and downstream integrations are told to review the changes before upgrading. That split is the single most useful thing to understand about this project right now: the inference path is the stable product, and the training path is where the churn lives.

TrainingTask wrappers, dict batches, and why the main branch is not the old OpenCLIP

The README states that main now uses a post-refactor training stack by default. Training is organised around TrainingTask wrappers, dict-based batches, FSDP2 support, NaFlex image and audio pipelines, and multiple torch.compile strategies. The scope, in the README's words, has grown well beyond the original refactor and now includes several new model families. Concretely, that means model families that did not exist in the original release: NaFlex CLIP with variable-resolution and variable-aspect image towers built on timm naflexvit and token-budget batching; NaFlex CLAP for audio-text contrastive training with variable-duration audio; NaFlex GenLIP and GenLAP for generative image and audio captioning using prefix-LM attention and packed media-plus-text rows with tiktoken text; a modern text tower configured through text_cfg.text_arch="modern" with RoPE, SwiGLU or ReLU squared, RMSNorm and masked pooling; Hugging Face ModernBERT text towers; MaMMUT, which uses a single text decoder in two passes; and CoCa v2 configs. Variable-length text is a separate switch, text_cfg.variable_text=true, which pads captions to the per-batch maximum instead of a fixed context length. The architectural point is that the text tower, the image tower, the pooling strategy and the padding policy have all become configuration axes rather than fixed choices. If you are evaluating OpenCLIP as a library to embed, that is a lot of surface area to be aware of.

Getting it running: the install path and the flags that changed

The README points at a PyPI package, open_clip_torch, and at two Colab notebooks, one for interacting with OpenCLIP and one for CoCa. For the older release-stable training API, the README says to pin to the v3 branch or the latest 3.x release on PyPI. That is the practical install decision before any code is written. If you are training, the breaking changes to the CLI are the part to read first. --horovod is removed and Horovod support is deleted, leaving DDP and FSDP2. --torchscript and --trace are removed because torch.jit is being deprecated upstream. The default --precision changed from amp to amp_bf16, which the README calls a silent behaviour change, and it says to pass --precision amp explicitly to keep fp16 AMP. SigLIP's --loss-dist-impl now defaults to gather, as does standalone SigLipLoss, and the README notes that gather stores all ranks' text features on each rank; pass --loss-dist-impl bidir to keep bidirectional ring exchange, with reduce and shift still available. --naflex-max-tokens-per-batch now defaults to unset, with the local token budget inferred as --batch-size multiplied by the maximum of --naflex-seq-lens, and GenLIP and GenLAP also include their caption-token cap in the per-row cost. New opt-in flags include --fsdp, --fsdp-no-reshard-after-forward, --fsdp-offload-cpu, --fsdp-checkpoint with full or sharded modes, --torchcompile-strategy with task, model or step, --siglip-chunk-size, --use-naflex with the naflex_ flags, --audio- flags, --length-bucketing with --bucket-pool and --bucket-chunk, and --text-pad-multiple. Note that --fused-caption-loss still requires --accum-freq 1.

Text validity masks and the SimpleTokenizer pad collision

One change deserves its own section because it is a correctness fix rather than a feature. The README describes text validity masks for generative models: CoCa and MaMMUT forward() and encode_text() accept text_valid as a [B, L] tensor where True marks a real token, tokenizers can emit exact masks via tokenizer(texts, output_mask=True), and caption labels are masked to -100 from them. The problem being fixed is stated plainly: the SimpleTokenizer pad-collision class, where id 0 is a real token and strings such as '!' merging like x!=y emit it mid-caption. Absent a mask, behaviour falls back to the historical text != pad_id derivation. If your captions contain punctuation that tokenises to id 0 in the middle of a string, the fallback derivation will mark a real token as padding. That is not a performance question, it is a label-correctness question, and it is exactly the kind of thing that produces a model which trains without error and underperforms for reasons nobody can locate. The text towers keep the Hugging Face style attention_mask kwarg at the tower boundary, so the two masking conventions coexist rather than replacing one another.

Memory, precision and the cost of the new defaults

Several of the new defaults trade memory for correctness or speed, and the README is explicit about at least one of them. The gather default for SigLIP loss distribution stores all ranks' text features on each rank, which is a per-rank memory increase that buys a different communication pattern; bidir is the flag that restores the previous ring exchange. FSDP2 via --fsdp replaces DDP and brings its own knobs: --fsdp-no-reshard-after-forward, --fsdp-offload-cpu, and --fsdp-checkpoint with a full mode that gathers to rank-0 as a single .pt file versus a sharded mode that uses DCP per-rank shards and is described as faster with lower memory. --torchcompile-strategy lets you choose whether compilation captures the task forward and loss, the underlying model, or the full single-batch train step, which is a real decision about compile time against steady-state throughput. The variable-text path with gradient accumulation lets CoCa and MaMMUT handle different caption lengths across microbatches in both training entrypoints, padding caption logits and masked labels when combining loss inputs while preserving the mean over all valid target tokens. That is a genuine capability, and it comes with the constraint that --fused-caption-loss cannot be combined with it. Anyone planning a training run should treat the flag list as a budget, not a menu.

Where OpenCLIP is the wrong tool

The README's own warning box is the clearest limitation statement available: training scripts and downstream integrations should review the changes before upgrading. If your team needs a frozen training API with a slow deprecation cycle, main is not that, and the README says to pin to v3 or the latest 3.x release instead. The second limitation is documentation shape. The README is a changelog of model families and flags. It names config families such as naflexclap_*, naflexgenlip_*, naflexgenlap_*, moderntext-*, mammut_*, mammut2_*, coca2_* and gte-modernbert-base-ViT-B-32-256, but it does not, in the material available, walk through a complete training run end to end or state hardware requirements for any of them. You will be reading configs to learn what the flags mean. The third case is narrower: if you only need a pretrained image-text encoder for embeddings and you never intend to train, the refactor is mostly noise. You are paying attention cost for a surface you will not use, and a smaller inference-only wrapper would serve you with less to track. The fourth is the text_valid fallback. If you train generative captioning models with SimpleTokenizer and never pass a mask, you are on the historical derivation and exposed to the pad-collision case the fix was written for.

Alternatives and what the difference actually is

The most direct alternative is the original CLIP release from OpenAI, which is a research codebase rather than a maintained library: it gives you the reference implementation and the original model weights, but it does not offer the config families, the FSDP2 path, the NaFlex variable-resolution pipelines, the audio training, or the Hugging Face text towers that OpenCLIP's main branch carries. Hugging Face Transformers is the other common route, and the difference is architectural rather than cosmetic. Transformers exposes CLIP and related models through a uniform model, tokenizer and Trainer interface, so swapping architectures or moving to a hosted training service is a configuration change. OpenCLIP keeps a training stack of its own, with TrainingTask wrappers, dict-based batches, and its own CLI. The README even shows the two meeting: OpenCLIP ships Hugging Face ModernBERT text towers and keeps the HF-style attention_mask kwarg at the tower boundary, and it can load MaMMUT weights directly via hf-hub: with fork-format configs and state dicts translated on load. So the choice is not OpenCLIP or Hugging Face. It is whether you want a training loop you control down to the loss distribution and padding policy, or a framework that abstracts those decisions away. OpenCLIP assumes the former.

Maintenance, licensing and what to check before you commit

The repository metadata reports the licence as NOASSERTION, which means the licence could not be classified from the repository contents. That is not a statement that the project is unlicensed, and it is not legal advice; it means anyone adopting OpenCLIP for a commercial product should read the actual licence file and the licences attached to the pretrained checkpoints they plan to use, because model weights and code can carry different terms. On maintenance, the release cadence visible in the material is v3.1.0 in August 2025, v3.2.0 in September 2025, and v3.3.0 in February 2026, with the last push to main in September 2026. That is a project under active development, which is also why the README devotes a box to warning that main has moved beyond the release-stable training API. The upgrade cost is asymmetric. Inference users get compatibility by design. Training users get a list of removed flags, a changed precision default, a changed loss-distribution default, and a changed token-budget default, any one of which can alter a run without raising an error. Budget for a diff against your training scripts, not for a version bump.

Editorial conclusion

Adopt OpenCLIP for pretrained image-text inference and for zero-shot classification work, and treat the main branch as a moving training target rather than a stable one. If your training scripts were written against the older API, pin to the v3 branch or the latest 3.x release on PyPI before you touch anything else. Verify three things first: the licence terms, since the repository metadata reports NOASSERTION; whether your pipeline uses SimpleTokenizer captions that can emit pad id 0 mid-string, which is the case the text_valid mask was added to fix; and whether you rely on the old 16384 default for --naflex-max-tokens-per-batch, which is now unset and inferred from --batch-size and --naflex-seq-lens.

Official sources

  1. Issues
  2. mlfoundations/open_clip on GitHub
  3. README
  4. Releases
Community notes

Community notes