Skip to main content

OMGFormers

Parallel Diffusion Language Model — 66 features

PyPI version License Python

GitHub: https://github.com/fastloraoffical/OMGformers


Install

pip install omgformers

What is OMGFormers?

OMGFormers is a research-grade PyTorch library for building Parallel Diffusion Language Models. It provides a modular, composable set of building blocks covering:

  • Attention mechanisms — GQA, MLA, Sliding Window, Linear, Block-Sparse, Flash Attention 2, RoPE variants (YaRN, NTK, LongRoPE), ALiBi, T5 relative bias
  • Feed-forward layers — SwiGLU, GeGLU, ReGLU, Standard FFN
  • Mixture of Experts — Dense MoE, Soft MoE, load-balancing loss
  • Diffusion — Mask scheduler, Parallel decoder for masked diffusion LM training
  • LoRA / DoRA — Parameter-efficient fine-tuning adapters with merge/save/load
  • Training utilities — EMA, Lion optimizer, warm-up cosine schedules, FSDP, gradient checkpointing, checkpoint manager
  • Tokenizer — HuggingFace-compatible tokenizer with char-level fallback, special token management, encode/decode batch, mask_tokens for diffusion
  • Advanced — KV cache, multi-token prediction, model merging (SLERP, DARE, TIES), reward model, PPO, int8/int4 quantization, GGUF export, RAG context injection, dynamic batching, chunked long-doc attention

Quick Start

import torch
from omgformers import OMGConfig, OMGModel, create_base_model, OMGTokenizer

# Build a small model
cfg = OMGConfig(
    vocab_size=32000,
    hidden_size=512,
    num_layers=6,
    num_heads=8,
)
model = OMGModel(cfg)

# Or use the fast initializer
model, cfg = create_base_model(hidden_size=512, num_layers=6)

# Tokenizer
tok = OMGTokenizer.from_pretrained("gpt2")  # or char-level fallback
ids = tok.encode("Hello, world!")
print(tok.decode(ids))

Fine-tuning

from omgformers import FineTuneConfig, FineTuner

ft_cfg = FineTuneConfig(method="lora", lora_rank=16, steps=1000)
tuner  = FineTuner(model, tokenizer=tok, config=ft_cfg)
tuner.train(train_dataloader)

LoRA

from omgformers import add_lora, merge_lora, save_lora, LoRAConfig

lora_cfg = LoRAConfig(rank=16, alpha=32, target_modules=["q_proj", "v_proj"])
model    = add_lora(model, lora_cfg)
# ... train ...
model    = merge_lora(model)
save_lora(model, "my_lora_weights/")

Mixture of Experts

from omgformers import MoEConfig, OMGConfig

cfg = OMGConfig(
    hidden_size=1024,
    num_layers=12,
    moe=MoEConfig(num_experts=8, top_k=2, aux_loss_coeff=0.01),
)

What's New in v2.0.6-preview

Feature Description
#53 Fast base model initialization (create_base_model)
#54 Fine-tuning engine (FineTuner)
#55 Resume from checkpoint (Trainer.resume_from_checkpoint)
#56 Checkpoint manager (CheckpointManager)
#57 Flash Attention 2 real implementation (flash_attention_forward)
#58 MoE → OMGConfig full integration (MoEConfig)
#61 OMGTokenizer (HF + char-level fallback)
#62 Special token management
#63 Tokenizer save/load
#64 Tokenizer from_pretrained
#65 encode_batch / decode_batch
#66 mask_tokens for diffusion training

Bug fixes: #T5, #T6, #T7, #Mo1–Mo4, #A1–A5, #M1–M3, #C1–C3


Requirements

  • Python ≥ 3.9
  • PyTorch ≥ 2.0
  • Optional: transformers, safetensors, flash-attn, bitsandbytes

License

Apache License 2.0 — see LICENSE.

Metadata

Release files for omgformers 2.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omgformers 2.0.6
File Size Uploaded
omgformers-2.0.6.tar.gz 87.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for omgformers 2.0.6
File Interpreter ABI Platform
omgformers-2.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 178.1 kB

Release files / omgformers-2.0.6.tar.gz

Download URL omgformers-2.0.6.tar.gz
Size 87.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0b08a849537e3e8c9ae659a3cade0bb3b16ee1694468218452742bf65c14f3b2
BLAKE2b-256 checksum
How to use checksums
f931701a2ec952f38bbf3105fcc23f65f0d881b43b986d9bed54044c2b76915d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / omgformers-2.0.6-py3-none-any.whl

Download URL omgformers-2.0.6-py3-none-any.whl
Size 90.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fa8be0b77dc56245c182c0287684451bf69353c050acabd7d07ddb5abf46dbe
BLAKE2b-256 checksum
How to use checksums
c86515fe612bd78bd584040f38dec7e249cc1f0bd54e01697c3dd963e3888028
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

2.0.6 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page