Skip to main content

Pluggable Transformer building blocks: GQA, RoPE, SwiGLU, RMSNorm, Conformer conv, adapters with registry system

Project description

torchblocks-vp

Pluggable Transformer building blocks with a plugin registry system.

Part of the MorphFormer project by Voluntas Progressus.

Installation

pip install torchblocks-vp

Requires Python >= 3.14 and PyTorch >= 2.0.

Features

  • Registry system@register(category, name) decorator + get(category, name) factory lookup
  • Attention — Grouped Query Attention (GQA), Multi-Head Attention (MHA), Cross-Attention with KV cache support
  • Feed-forward — SwiGLU, GeLU variants
  • Normalization — RMSNorm, LayerNorm
  • Positional encoding — Rotary Position Embeddings (RoPE)
  • Convolution — Conformer-style depthwise separable conv1d
  • Adapters — Language-conditioned, bottleneck, and no-op adapters

Quick Start

import torchblocks

# List all registered modules
print(torchblocks.list_modules())
# {'attention': ['gqa', 'mha', 'cross'], 'feedforward': ['swiglu', 'gelu'], ...}

# Get a specific module class by category and name
GQA = torchblocks.get("attention", "gqa")
attention = GQA(d_model=512, num_heads=8, num_kv_heads=2)

# Register your own module into the registry
@torchblocks.register("feedforward", "my_custom_ff")
class MyFeedForward(torch.nn.Module):
    ...

Registry Categories

Category Registered modules
attention gqa, mha, cross
feedforward swiglu, gelu
norm rmsnorm, layernorm
conv local, none
adapter language_conditioned, bottleneck, none

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchblocks_vp-1.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchblocks_vp-1.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file torchblocks_vp-1.1.0.tar.gz.

File metadata

  • Download URL: torchblocks_vp-1.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for torchblocks_vp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f2367b26a201d022fc39e10a1fac731d2c1fb9387a879a28f481d27db3339643
MD5 c657e582a94f745ffbdee7855f47337d
BLAKE2b-256 562f24c4fcbd3678948199271841e173c8080f0068dd3f29c46adb3fa1836a75

See more details on using hashes here.

File details

Details for the file torchblocks_vp-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: torchblocks_vp-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for torchblocks_vp-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f8903f421e51f088c59924ea6a93389d8f74fda63ddc92468c8988ac455b6c
MD5 8b56c162216099ef630e9491554dc9ef
BLAKE2b-256 4415e0e714fe889c2b4711e4c9b51a13aadf7c16b7428d7be2034b9e97ece475

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page