Skip to content

Instantly share code, notes, and snippets.

View drbh's full-sized avatar
🕳️
a for AI

drbh drbh

🕳️
a for AI
  • drbh
  • state space
  • 02:47 (UTC -04:00)
View GitHub Profile
@drbh
drbh / benchmark_attention_script.py
Created July 9, 2025 22:42
SDPA benchmark for torch, FA2, FA3, transformer engine, xformers, Sage Attention and HF kernels-lib via a uv PEP 723 script
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# "pandas",
# "matplotlib"
# ]
# ///
# Benchmarking common shapes for Flux 1024x1024px image + varying text sequence lengths
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
import torch.nn as nn
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
# reuse the models from the previous snippets or copy the class
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
import torch.nn as nn
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
import torch.nn.functional as F
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
# /// script
# dependencies = [
# "requests<3",
# ]
# ///
import requests
import concurrent.futures
import time
from datetime import datetime
@drbh
drbh / start-stop-tv.js
Created November 29, 2024 20:06
start and stop your tv every 3 seconds in JS and Python
// Roku device IP address
const rokuIp = "192.168.1.252";
// Base URL for ECP commands
const baseUrl = `http://${rokuIp}:8060/keypress`;
// Delay between commands in milliseconds
const delay = 3000;
async function sendKeypress(command) {
try {
const response = await fetch(`${baseUrl}/${command}`, { method: 'POST' });
@drbh
drbh / echo-bots.py
Created November 26, 2024 02:39
a small python script to facilitate a conversation between two llm chat endpoints
from collections import deque
import time
from dataclasses import dataclass
from typing import Deque, List, Dict
import requests
import os
class Colors:
PURPLE = "\033[95m"
@drbh
drbh / demo.py
Created April 17, 2024 02:28
Deploy Inference Endpoint and use tools from OpenAI client
from openai import OpenAI
ENDPOINT_URL = "ENDPOINT_URL"
HF_TOKEN = "YOUR_TOKEN"
# Initialize the client, pointing it to one of the available models
client = OpenAI(
base_url=ENDPOINT_URL + "/v1/",
api_key=HF_TOKEN,
)