Skip to content

Add HaloBlocks: composable PyTorch model component library#1

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-model-components-library
Draft

Add HaloBlocks: composable PyTorch model component library#1
Copilot wants to merge 3 commits intomainfrom
copilot/add-model-components-library

Conversation

Copy link

Copilot AI commented Mar 2, 2026

Bootstrap the haloblocks Python library — every model component is a composable Block (subclass of nn.Module) that can be freely mixed to build custom architectures.

Core blocks

  • BaseBlock: common interface + num_parameters(trainable_only=False)
  • LayersLinearBlock, LayerNormBlock, DropoutBlock, FeedForwardBlock (GELU/ReLU), EmbeddingBlock
  • AttentionMultiHeadAttentionBlock, SelfAttentionBlock (optional causal mask), CrossAttentionBlock
  • EncodersTransformerEncoderLayerBlock, TransformerEncoderBlock (stacked)
  • DecodersTransformerDecoderLayerBlock (masked self-attn + cross-attn), TransformerDecoderBlock (stacked)
  • HeadsClassificationHead (cls/mean pooling), LanguageModelHead (weight tying), TokenClassificationHead

Example — full Transformer from blocks

import haloblocks as hb

class Seq2Seq(nn.Module):
    def __init__(self, vocab_size):
        super().__init__()
        self.src_emb = hb.EmbeddingBlock(vocab_size, 256)
        self.tgt_emb = hb.EmbeddingBlock(vocab_size, 256)
        self.encoder = hb.TransformerEncoderBlock(256, num_heads=8, d_ff=1024, num_layers=6)
        self.decoder = hb.TransformerDecoderBlock(256, num_heads=8, d_ff=1024, num_layers=6)
        self.head    = hb.LanguageModelHead(256, vocab_size)

    def forward(self, src, tgt):
        memory  = self.encoder(self.src_emb(src))
        decoded = self.decoder(self.tgt_emb(tgt), memory)
        return self.head(decoded)

Packaging

  • pyproject.toml + requirements.txt (torch>=1.13)
  • 35 unit tests across all block categories
Original prompt

python library where all model components are treated as blocks like heads,attention layers, new layers, encoders, decoders


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 2, 2026 13:43
Co-authored-by: basaanithanaveenkumar <67182233+basaanithanaveenkumar@users.noreply.github.com>
Co-authored-by: basaanithanaveenkumar <67182233+basaanithanaveenkumar@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Python library for model components as blocks Add HaloBlocks: composable PyTorch model component library Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants