The open-source profiler that gives you a unified view of your entire stack - from PyTorch down to the GPU.
Join our Discord community!
Keys & Caches is a Python library that provides experiment tracking and workflow management for machine learning projects. With a simple API, you can:
- 📊 Track experiments — Automatically log metrics and hyperparameters
- 🌐 Cloud dashboard — Real-time visualization of your experiments
- 🏷️ Organize projects — Group related experiments together
- 🎯 Zero-overhead when disabled — Tracking only activates when initialized
pip install kandc
import kandc
import torch
import torch.nn as nn
class SimpleNet(nn.Module):
def __init__(self):
super().__init__()
self.layers = nn.Sequential(
nn.Linear(784, 128),
nn.ReLU(),
nn.Linear(128, 10),
)
def forward(self, x):
return self.layers(x)
def main():
# Initialize experiment tracking
kandc.init(
project="my-project",
name="experiment-1",
config={"batch_size": 32, "learning_rate": 0.01}
)
# Your training/inference code
model = SimpleNet()
data = torch.randn(32, 784)
output = model(data)
loss = output.mean()
# Log metrics
kandc.log({"loss": loss.item(), "accuracy": 0.85})
# Finish the run
kandc.finish()
if __name__ == "__main__":
main()
kandc.init(
project="my-ml-project",
name="experiment-1",
config={
"learning_rate": 0.001,
"batch_size": 32,
"model": "resnet18",
}
)
# Log single or multiple metrics
kandc.log({"loss": 0.25, "accuracy": 0.92})
# Log with step numbers for training loops
for epoch in range(100):
loss = train_epoch()
kandc.log({"epoch_loss": loss}, step=epoch)
# Online mode (default) - full cloud experience
kandc.init(project="my-project")
# Offline mode - local development
kandc.init(project="my-project", mode="offline")
# Disabled mode - zero overhead
kandc.init(project="my-project", mode="disabled")
import kandc
import torch
import torch.nn as nn
class SimpleNet(nn.Module):
def __init__(self):
super().__init__()
self.layers = nn.Sequential(
nn.Linear(784, 128),
nn.ReLU(),
nn.Linear(128, 10),
)
def forward(self, x):
return self.layers(x)
def run_inference():
# Initialize inference tracking
kandc.init(
project="inference-demo",
name="simple-inference",
config={"batch_size": 32}
)
# Create model and wrap with profiler
model = SimpleNet()
model = kandc.capture_model_instance(model, model_name="SimpleNet")
model.eval()
# Run inference
data = torch.randn(32, 784)
with torch.no_grad():
predictions = model(data)
confidence = torch.softmax(predictions, dim=1).max(dim=1)[0].mean()
# Log results
kandc.log({
"avg_confidence": confidence.item(),
"batch_size": 32
})
kandc.finish()
if __name__ == "__main__":
run_inference()
See the examples/
directory for detailed examples:
complete_example.py
- Simple getting started exampleoffline_example.py
- Offline mode usageprofiler_example.py
- Performance profiling with model tracingtimed_block.py
- Using timing decorators and context managersvllm_example.py
- Integration with VLLM for LLM inference tracking
kandc.init()
- Initialize a new run with configurationkandc.finish()
- Finish the current run and save all datakandc.log()
- Log metrics to the current runkandc.get_current_run()
- Get the active run objectkandc.is_initialized()
- Check if kandc is initialized
"online"
- Default mode, full cloud functionality"offline"
- Save everything locally, no server sync"disabled"
- No-op mode, zero overhead
Email us at founders@herdora.com for support and collaboration opportunities!
-
Bump the version in
pyproject.toml
(e.g.,0.0.15
). -
Run the following commands:
rm -rf dist build *.egg-info python -m pip install --upgrade build twine python -m build export TWINE_USERNAME=__token__ twine upload dist/*
-
Bump the dev version in
pyproject.dev.toml
(e.g.,0.0.15.dev1
). -
Run the following commands:
rm -rf dist build *.egg-info cp pyproject.dev.toml pyproject.toml python -m pip install --upgrade build twine python -m build export TWINE_USERNAME=__token__ twine upload dist/* git checkout -- pyproject.toml # Restore the original pyproject.toml