Skip to main content

Keys & Caches CLI - Accelerate your Python functions with cloud GPUs

Project description

Keys & Caches

Keys & Caches Banner

The fastest way to run PyTorch models on cloud GPUs with automatic profiling and performance insights.


๐Ÿš€ What is Keys & Caches?

Keys & Caches is a command-line tool that makes it effortless to run PyTorch models on high-performance cloud GPUs. With just one command, you can:

  • ๐Ÿš€ Submit jobs to cloud GPUs - Access A100, H100, and L4 GPUs instantly
  • ๐Ÿ“Š Get automatic profiling - Detailed performance traces for every model forward pass
  • ๐Ÿ” Debug performance bottlenecks - Chrome trace format for visual analysis
  • โšก Stream real-time logs - Watch your training progress live
  • ๐Ÿ’ฐ Pay only for what you use - No idle time charges

๐ŸŽฏ Key Features

๐ŸŽฎ One-Command Deployment

# Run any PyTorch script on cloud GPUs
kandc python train.py --model-size large --epochs 100

๐Ÿ“ˆ Automatic Model Profiling

from kandc import capture_model_class

@capture_model_class(model_name="MyModel")
class MyModel(nn.Module):
    # Your model automatically gets profiled!

๐ŸŽฎ Flexible GPU Configurations

  • A100 GPUs (40GB/80GB) - Proven performance for training and inference
  • H100 GPUs (80GB) - Latest architecture with enhanced performance
  • L4 GPUs (24GB) - Cost-effective option for efficient workloads
  • Scale 1-8 GPUs - From development to massive scale training

๐Ÿ”ง Installation

Prerequisites

  • Python 3.8+ (Python 3.9+ recommended)
  • PyTorch installed in your environment

Install Keys & Caches

pip install kandc

Verify Installation

kandc --version

๐ŸŽฏ Quick Start (5 Minutes)

1. Create a Simple Model

Create my_first_model.py:

import torch
import torch.nn as nn
from kandc import capture_model_class

@capture_model_class(model_name="FirstModel")
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.Sequential(
            nn.Linear(784, 256),
            nn.ReLU(),
            nn.Linear(256, 128),
            nn.ReLU(),
            nn.Linear(128, 10)
        )
    
    def forward(self, x):
        return self.layers(x)

def main():
    print("๐Ÿš€ Running my first Keys & Caches job!")
    
    model = SimpleModel()
    x = torch.randn(32, 784)
    
    # Forward pass (automatically profiled!)
    model.eval()
    with torch.no_grad():
        output = model(x)
        print(f"โœ… Output shape: {output.shape}")
    
    print("โœ… Job completed successfully!")

if __name__ == "__main__":
    main()

2. Test Locally First

python my_first_model.py

3. Run on Cloud GPUs

kandc python my_first_model.py

That's it! Your model runs on high-performance GPUs with automatic profiling. ๐ŸŽ‰

๐ŸŽฎ Command Formats

Interactive Format (Beginner-Friendly)

kandc python my_model.py --epochs 10 --batch-size 32
  • Prompts you for job configuration (app name, GPU count, etc.)
  • Great for getting started and experiments

Separator Format (Automation-Ready)

kandc --app-name "my-experiment" --gpu A100-80GB:2 -- python my_model.py --epochs 10
  • Fully specified with -- separator
  • Ideal for scripts and automation

๐ŸŽฏ GPU Options

GPU Type Count Memory Use Case Example Flag
A100-40GB 1-8 40GB each Cost-effective training --gpu A100:4
A100-80GB 1-8 80GB each High-memory models --gpu A100-80GB:2
H100 1-8 80GB each Latest architecture --gpu H100:8
L4 1-8 24GB each Efficient inference --gpu L4:1

๐Ÿ“Š Automatic Model Profiling

Keys & Caches automatically profiles your models:

Class Decorator (Most Common)

from kandc import capture_model_class

@capture_model_class(model_name="MyModel")
class MyModel(nn.Module):
    # Your model definition

Instance Wrapper (For Pre-built Models)

from kandc import capture_model_instance

# For HuggingFace models, etc.
model = AutoModel.from_pretrained("bert-base-uncased")
model = capture_model_instance(model, model_name="BERT")

Profiling Features

  • โฑ๏ธ Layer-level timing - See which layers are bottlenecks
  • ๐Ÿ’พ Memory tracking - Monitor GPU memory usage
  • ๐Ÿ” Shape recording - Debug tensor dimension issues
  • ๐Ÿ“ˆ Chrome traces - Visual timeline in chrome://tracing

๐Ÿ’ก Examples

Computer Vision

# ResNet training
kandc python examples/vision_models/resnet_example.py

NLP & Transformers

# HuggingFace BERT
kandc --requirements requirements_examples/nlp_requirements.txt -- python examples/nlp_models/pretrained_models.py

Vision-Language Models

# OpenAI CLIP
kandc --requirements requirements_examples/vlm_requirements.txt -- python examples/vlm_models/clip_example.py

Generative Models

# GANs and VAEs
kandc python examples/generative_models/gan_example.py

๐Ÿ“š Documentation

๐Ÿ’ฐ Publishing to PyPI

Prerequisites

# Install build and publishing tools
pip install build twine

# Ensure you have PyPI credentials configured
# Create ~/.pypirc or use environment variables

Build and Upload Process

# 1. Update version in pyproject.toml
# Edit the version field: version = "0.1.1"

# 2. Clean previous builds
rm -rf dist/ build/

# 3. Build the package
python -m build

# 4. Check the built package
twine check dist/*


# 6. Upload to PyPI
twine upload dist/*

๐Ÿ†˜ Support

๐Ÿ“œ License

MIT License - see LICENSE for details.


Ready to accelerate your ML workflows? Install Keys & Caches and run your first GPU job in under 5 minutes! ๐Ÿš€

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

kandc-0.0.2.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

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

kandc-0.0.2-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file kandc-0.0.2.tar.gz.

File metadata

  • Download URL: kandc-0.0.2.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for kandc-0.0.2.tar.gz
Algorithm Hash digest
SHA256 69505d983601d59addff3aaf3a6407a324e148d14f16a6e63c857b29d4684a17
MD5 5e52afe49b57147ff7501e44c8bc6b1a
BLAKE2b-256 ceba9cbacae1b5263ccfecc22845b02d27194cebc4f1510ee52569415f397b80

See more details on using hashes here.

File details

Details for the file kandc-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: kandc-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for kandc-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88e6e7ea424e3897236b1b603f456ccccade03bfc545ad141c172752dd1284b7
MD5 1d90f0a53b12e255135b557714261ba1
BLAKE2b-256 d2815ddaa2a2e67ca44094ae409804eccf25c8d28e0deff4342cd88198243d52

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