Skip to main content

A fast zero-copy PyTorch tensor streamer

Project description

Vajra

A fast zero-copy PyTorch tensor streamer powered by Dlang.

Usage

Once installed, you can use Vajra in any Python script or Jupyter Notebook:

import torch
from vajra import VajraStreamer, StreamConfig

# Configure the streamer (optional, uses defaults otherwise)
config = StreamConfig(
    auth_token="hf_YOUR_TOKEN", # Required for gated models like Llama 3
    chunk_size_mb=64,
    chunk_workers=16,
    gpu_workers=3,
    disable_cache=False
)

# Context manager ensures VRAM is freed when done
with VajraStreamer(config) as streamer:
    # Pass the URL or a Hugging Face repo ID
    # (e.g. "meta-llama/Meta-Llama-3-8B")
    tensors = streamer.load("meta-llama/Meta-Llama-3-8B")

    # 'tensors' is a dictionary mapping tensor names to zero-copy PyTorch tensors
    # that are backed directly by the downloaded GPU memory.
    for name, tensor in tensors.items():
        print(f"Tensor: {name}, Shape: {tensor.shape}, Dtype: {tensor.dtype}")

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

vajra_streamer-0.0.46a4.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

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

vajra_streamer-0.0.46a4-py3-none-manylinux_2_34_x86_64.whl (8.0 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

File details

Details for the file vajra_streamer-0.0.46a4.tar.gz.

File metadata

  • Download URL: vajra_streamer-0.0.46a4.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for vajra_streamer-0.0.46a4.tar.gz
Algorithm Hash digest
SHA256 60e43d0fd31348cdc1d19f7ac722c4752d6212dfee5921197d41cd1f4ae84a9a
MD5 2499cc366efa1c4167054df1bfe646a8
BLAKE2b-256 034aa0d653aa3c1eb017d7f10bb429ecfb225bd0e9cabb6e36278657d4bcad70

See more details on using hashes here.

File details

Details for the file vajra_streamer-0.0.46a4-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vajra_streamer-0.0.46a4-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2e7313aeeaa3a38d7b1e1db07a7b48f3c2936394ce06a64ace2c4195eea28780
MD5 7aa79cfe5600e788a67c1734d7349d2f
BLAKE2b-256 4e38919fca83a9a646002e2893a04dea3b7399572aa81e8220dd536c61aaa0ab

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