vectorphile
v0.3.0 ArchivedProduction completeness — 41 modules, 50+ DL architectures, 5-tier GPU dispatch, full tokenizer suite, pretrained hub, RL algorithms, GGUF export, Lightning-style Trainer, and advanced optimizers. Replaces PyTorch + HuggingFace Transformers + scikit-learn under a single original API.
Overview
vectorphile v0.3.0 reaches production completeness with 41 modules covering every corner of the ML ecosystem. The 5-tier backend dispatch makes it match PyTorch GPU speed when Triton, Numba or CuPy are installed. Every major DL architecture is implemented from scratch — no external DL dependencies required.
| What's new in v0.3.0 | Module / Area |
|---|---|
| 5-tier GPU dispatch (Triton → NumPy) | vp.backend |
| 50+ DL architectures: CNN, SSM, ViT, GAN, UNet, GNN | vp.nn.architectures |
| Flash Attention — O(N) memory, causal masking | vp.nn.flash_attention |
| QAT — FakeQuantize, QATLinear/Conv2d, prepare/convert | vp.nn.qat |
| Advanced optimizers: Lion, Sophia, Adan, Prodigy | vp.nn.optimizers_advanced |
| BPE, WordPiece, SentencePiece tokenizers from scratch | vp.tokenizers |
| Beam search, nucleus sampling, speculative decoding | vp.text |
| Lightning-style Trainer + TrainableModel | vp.trainer |
| RL: DQN, REINFORCE, A2C, PPO, SAC, TD3 | vp.rl |
| ONNX export + GGUF read/write (Q4_0, Q8_0) | vp.export |
| Pretrained hub: load() + 20+ models, HF Hub compatible | vp.pretrained |
| Distributed: DataParallel, DDP, mixed precision | vp.distributed |
| 16→41 modules, 110 Python files | vp (top level) |
Installation
pip install vectorphile # core (numpy + scipy)
pip install "vectorphile[viz]" # + matplotlib
pip install "vectorphile[cuda]" # + cupy (GPU via CuPy)
pip install "vectorphile[numba]" # + numba CUDA kernels
pip install "vectorphile[triton]" # + OpenAI Triton fused kernels
pip install "vectorphile[pretrained]" # + safetensors, huggingface-hub
pip install "vectorphile[onnx]" # + onnx, onnxruntime
pip install "vectorphile[rl]" # + gymnasium
pip install "vectorphile[full]" # all extras
# Requirements: Python >= 3.9, NumPy >= 1.24, SciPy >= 1.10Quick Start
import vectorphile as vp
from vectorphile.trainer import Trainer, TrainableModel
from vectorphile.data.datasets import MNIST
# 1. Data
train_ds, val_ds = MNIST(root='./data').split(val_ratio=0.1)
# 2. Model
class MyNet(TrainableModel):
def __init__(self):
super().__init__()
self.net = vp.nn.Sequential(
vp.nn.Linear(784, 256),
vp.nn.GELU(),
vp.nn.Linear(256, 10),
)
def forward(self, x):
return self.net(x)
def training_step(self, batch):
x, y = batch
loss = vp.nn.CrossEntropyLoss()(self(x), y)
return loss
# 3. Train
trainer = Trainer(
max_epochs=10,
optimizer='adamw', lr=1e-3,
callbacks=['early_stopping', 'model_checkpoint'],
device='auto',
)
trainer.fit(MyNet(), train_ds, val_ds)Tensors
vp.coreThe Tensor is the central primitive. Set requires_grad=True for gradient tracking. Operations dispatch automatically to the fastest available backend.
import vectorphile as vp
x = vp.randn(3, 4); y = vp.ones(4, 5)
z = x @ y # (3, 5) matmul
a = vp.zeros(5, 1) + vp.randn(1, 8)
b = a.reshape(5, 2, 4)
c = b.permute(2, 0, 1)
m = z.mean(); s = z.sum(axis=1, keepdims=True); mx, idx = z.max(axis=0)
x_f16 = x.astype('float16')
arr = x.numpy(); t = vp.from_numpy(arr)Autograd
vp.autogradReverse-mode automatic differentiation. Dynamic computation graph supports arbitrary control flow. v0.3.0 adds jacobian, hessian, vmap, and gradient checkpointing.
x = vp.tensor([2.0, 3.0], requires_grad=True)
w = vp.tensor([[1.0, 0.5], [0.5, 1.0]])
h = x @ w
y = (h ** 2 + vp.log(h.abs() + 1)).sum()
y.backward()
print(x.grad)
from vectorphile.autograd import jacobian, hessian
J = jacobian(lambda v: (v ** 2).sum(), x)
H = hessian(lambda v: (v ** 2).sum(), x)
with vp.no_grad():
logits = model(X_test)Backend Dispatch
vp.backend5-tier automatic dispatch selects the fastest available compute backend at runtime.
Neural Networks
vp.nnComplete neural network layer library. All operations support autograd.
Architecture Zoo
vp.nn.architectures50+ production-grade DL architectures, all implemented from scratch with no external DL dependencies.
- →LeNet5
- →VGG/11-19
- →ResNet/18-152
- →DenseNet
- →MobileNetV2
- →EfficientNet B0-B7
- →S4 (HiPPO-LegT + FFT)
- →Mamba (selective scan)
- →ViT (tiny/small/base/large/huge)
- →DeiT (distillation token)
- →VAE (ELBO)
- →DCGAN (gradient penalty)
- →DDPM (cosine schedule)
- →UNet
- →ResUNet
- →AttentionUNet (gated)
- →GCN
- →GAT (multi-head)
- →GraphSAGE
- →GIN
Tokenizers
vp.tokenizersAll three major tokenization algorithms implemented from scratch.
Text Generation
vp.textfrom vectorphile.text import TextGenerationPipeline, beam_search, nucleus_sampling
pipe = TextGenerationPipeline(model=my_lm, tokenizer=bpe)
out = pipe("Once upon a time", max_new_tokens=100, strategy='nucleus', top_p=0.9)
# or call directly
ids = beam_search(logits_fn, start_ids, beam_width=4, max_len=200, no_repeat_ngram=3)
ids = nucleus_sampling(logits_fn, start_ids, top_p=0.95, temperature=0.8)Trainer
vp.trainerLightning-style Trainer handles the training loop. Subclass TrainableModel and implement training_step().
from vectorphile.trainer import Trainer, TrainableModel
class MyModel(TrainableModel):
def training_step(self, batch):
x, y = batch
return vp.nn.CrossEntropyLoss()(self(x), y)
def validation_step(self, batch):
x, y = batch
return {'val_loss': vp.nn.CrossEntropyLoss()(self(x), y)}
trainer = Trainer(max_epochs=50, optimizer='adamw', lr=3e-4, device='auto')
trainer.fit(MyModel(), train_loader, val_loader)RL Algorithms
vp.rlONNX Export
vp.exportfrom vectorphile.export import to_onnx, ONNXRuntime
to_onnx(model, dummy_input=vp.randn(1, 3, 224, 224), path='model.onnx')
rt = ONNXRuntime('model.onnx')
out = rt.run(input_array)GGUF Format
vp.exportfrom vectorphile.export import to_gguf, from_gguf, GGUFReader, GGUFWriter
to_gguf(model, 'model.gguf', quantization='Q4_0') # or Q8_0
model2 = from_gguf('model.gguf', model_cls=MyModel)
reader = GGUFReader('model.gguf')
writer = GGUFWriter('out.gguf')