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.17.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.17-cp310-cp310-manylinux_2_34_x86_64.whl (8.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file vajra_streamer-0.0.17.tar.gz.

File metadata

  • Download URL: vajra_streamer-0.0.17.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.17.tar.gz
Algorithm Hash digest
SHA256 427a0eadf51d38f8822cb465ffbec722013f723da62aec777e8d942a0ea64aa6
MD5 2af023db8d4affcca2ed5af96d5a6178
BLAKE2b-256 f34b8e0f5cf54d4e7d2a701d736a7d637af8d6bc5df19e63875a4ee6d4232844

See more details on using hashes here.

File details

Details for the file vajra_streamer-0.0.17-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for vajra_streamer-0.0.17-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b39b96eb8e5e0600c0f81b197e50435fdb58c9892b4dfb23506f12944b084a6b
MD5 2da7fa6a77d5f9617399224730c45eea
BLAKE2b-256 84184a457d8e7557c9d2ede05e4caa222c0fa4b501b8203955f237123a168166

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