How md-mushfiqur123/m2lrf works
M-2LRF is an LLM quantization, fine-tuning, and inference engine. Its main workflow loads a pretrained model, applies architecture patches and low-bit conversion, then trains or exports the result; serving is a separate inference path. The README also documents adapter merging and serving features. Relationships below use the sampled source and SOURCE INDEX references; several documented capabilities have unsampled implementations, so their connections are marked unverified rather than inferred.
Main entry points: main.py Command line · loader.py Model loader · unified_layer.py Unified linear layer · engine.py Generation engine
Components 23
Model preparation
- Model loader
m2lrf/models/loader.py - Architecture patchers
m2lrf/models/base_patcher.py - Model conversion
m2lrf/trainer_eval.py
Quantization runtime
- Hadamard rotation
m2lrf/hadamard_transform.py - Dual-basis quantizer
m2lrf/quantizer.py - Packed weight codec
m2lrf/packed_codec.py - Mixed precision
m2lrf/mixed_precision.py - Unified linear layer
m2lrf/unified_layer.py - GPU kernels
m2lrf/kernels/fast_cross_entropy.py
Training and data
- SFT trainer
m2lrf/trainers/sft_trainer.py - Reasoning data
m2lrf/data/synthetic_reasoning.py - GRPO trainer
m2lrf/trainers/grpo_trainer.py
Inference serving
- OpenAI API server
m2lrf/serving/openai_server.py - Generation engine
m2lrf/serving/engine.py - KV block manager
m2lrf/serving/block_manager.py - Paged attention
m2lrf/serving/paged_attention.py - Prefix cache
m2lrf/serving/radix_cache.py
Export and interfaces
- Command line
m2lrf/cli/main.py - Hugging Face export
m2lrf/export/hf_export.py - GGUF export
m2lrf/export/gguf_export.py
Other components
- Engineer
- Model source
- Inference client
Connections 24
- Engineer → Command line: runs commands
m2lrf/cli/main.py - Command line → Model loader: loads model
m2lrf/cli/main.py - Model loader → Model source: loads weights
m2lrf/models/loader.py - Model loader → Architecture patchers: selects patcher
m2lrf/models/loader.py - Model loader → Model conversion: prepares model
m2lrf/models/loader.py - Architecture patchers → GPU kernels: patches norms
m2lrf/models/base_patcher.py - Architecture patchers → Model conversion: delegates conversion
m2lrf/models/base_patcher.py - Model conversion → Unified linear layer: replaces modules
m2lrf/trainer_eval.py - Model conversion → Hadamard rotation: uses rotation
m2lrf/trainer_eval.py - Unified linear layer → Dual-basis quantizer: quantizes weights
m2lrf/unified_layer.py - Unified linear layer → Packed weight codec: packs weights
m2lrf/unified_layer.py - Unified linear layer → Mixed precision: uses precision
m2lrf/unified_layer.py - Hadamard rotation → Dual-basis quantizer: quantizes rotated weights
m2lrf/hadamard_transform.py - Hadamard rotation → Packed weight codec: packs weights
m2lrf/hadamard_transform.py - SFT trainer → GPU kernels: uses loss
m2lrf/trainers/sft_trainer.py - GRPO trainer → Reasoning data: uses samples
m2lrf/trainers/grpo_trainer.py - Command line → SFT trainer: starts training
m2lrf/cli/main.py - Command line → Hugging Face export: dispatches export
m2lrf/cli/main.py - Command line → GGUF export: dispatches export
m2lrf/cli/main.py - Inference client → OpenAI API server: sends requests
- OpenAI API server → Generation engine: routes generation
- Generation engine → KV block manager: allocates blocks
m2lrf/serving/engine.py - Generation engine → Prefix cache: matches prefixes
m2lrf/serving/engine.py - Generation engine → Paged attention: runs attention
m2lrf/serving/engine.py