PML Framework
A high-performance machine learning framework for PHP 8.2+.
All tensor math runs in a C engine (libtensor.so) via FFI — PHP orchestrates,
C computes. OpenBLAS + AVX2 + OpenMP + LAPACKE. No Python. No ONNX. No wrappers.
Architecture
Key Properties
Zero-Copy FFI
PHP holds TensorC* C pointers. No PHP-side float arrays. All math crosses the FFI boundary once per operator.
OpenBLAS + AVX2
GEMM via OpenBLAS. Element-wise ops via 256-bit AVX2 SIMD. OpenMP multi-threading. LAPACKE for SVD/eigendecomp.
INT8 Quantization
Dense layers quantize to INT8 block format (Q8_0). 4× memory reduction. AVX2 fused int8→fp32 dot kernel. 7B model in ~7 GB RAM.
KV-Cache
Multi-head KV cache for autoregressive decode. Milakov online-softmax. O(1) decode per token vs O(T²) recompute.
SafeTensors I/O
HuggingFace-compatible checkpoint format. mmap()-backed zero-copy weight loading. No PHP serialize().
Full ML Stack
19 classifiers · 15 regressors · 6 anomaly detectors · 5 clusterers · 44 transformers · 29 NN layers · Vision module.
Documentation Pages
Getting Started
Installation, building libtensor.so, your first model, quick examples.
Tensor
Core tensor class: creation, arithmetic, BLAS, reduction, shape ops, Arena, QuantizedTensor.
Dataset & DataFrame
Dataset container, DataFrame for tabular data, DataLoader for streaming batches.
Estimators
All 45 estimators: classifiers, regressors, anomaly detectors, clusterers, decomposition, meta.
Transformers
44 data transformers: scalers, encoders, text vectorizers, image transforms, feature selection.
Neural Networks
Sequential model, 29 layers, 9 optimizers, 5 loss functions, INT8 quantization.
Training System
Trainer, TrainingArguments, LR schedulers, GradScaler, EarlyStopping, callbacks.
Inference & LLM
InferenceSession for LLaMA-style GQA, KV-cache, BPE tokenizer, ModelConfig.
Vision
Image I/O, object detection (YOLO, NanoDet), segmentation, MobileNetV3, augmentation.
Pipeline & CV
Pipeline, cross-validation strategies, ensemble methods, autograd.
Vulkan GPU Roadmap
Plan for universal GPU support via Vulkan compute shaders replacing AVX2/OpenBLAS.
Namespace Map
| Namespace | Location | Description |
|---|---|---|
Pml\ | src/ | Root: Tensor, Dataset, DataFrame, Pipeline, Arena, QuantizedTensor |
Pml\Estimators\Classifiers\ | src/Estimators/Classifiers/ | 19 classification estimators |
Pml\Estimators\Regression\ | src/Estimators/Regression/ | 15 regression estimators |
Pml\Estimators\AnomalyDetectors\ | src/Estimators/AnomalyDetectors/ | 6 anomaly detectors |
Pml\Estimators\Clusterers\ | src/Estimators/Clusterers/ | 5 clustering algorithms |
Pml\Transformers\ | src/Transformers/ | 44 data transformers |
Pml\NeuralNetwork\ | src/NeuralNetwork/ | Sequential, layers, optimizers, activations, initializers |
Pml\Losses\ | src/Losses/ | Loss functions |
Pml\Training\ | src/Training/ | Trainer, LRScheduler, GradScaler, callbacks |
Pml\Inference\ | src/Inference/ | InferenceSession, ModelConfig, Tokenizer |
Pml\Vision\ | src/Vision/ | Image, detection, segmentation, augmentation, models |
Pml\Interfaces\ | src/Interfaces/ | 15 contracts used across the framework |
Pml\Lib\ | src/Lib/ | TensorEngine, QuantEngine, VisionEngine, Arena, ModelStore, SafeTensorsIO |
Pml\Autograd\ | src/Autograd/ | Variable, Tape — automatic differentiation |