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
  • 00:23 (UTC -04:00)
View GitHub Profile
@drbh
drbh / test_gen.py
Created August 25, 2025 18:41
generate template for tests for all torch bindings exposed in a so
import re
def extract_strings(binary_path, min_length=4):
with open(binary_path, "rb") as f:
data = f.read()
strings = []
current = []
for byte in data:
if 32 <= byte <= 126:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# Read the data
df = pd.read_csv("de_results/filtered_results.csv")
# Get unique targets and calculate stats
targets = df['target'].unique()
n_targets = len(targets)
@drbh
drbh / output.txt
Created August 19, 2025 19:54
get pairwise DE genes for each gene in the set
Target: CHMP3, DE genes: 3508
Target: AKT2, DE genes: 908
Target: SHPRH, DE genes: 121
Target: TMSB4X, DE genes: 291
Target: KLF10, DE genes: 6500
Target: TARBP2, DE genes: 1073
Target: KDM2B, DE genes: 4582
Target: non-targeting, DE genes: 0
Target: SV2A, DE genes: 198
Target: CLDN6, DE genes: 124
@drbh
drbh / output.txt
Created August 18, 2025 23:30
Explores the difference in fdr by adding a pairwise fdr column to pdex
uv run pdex-pairwise-fdr.py
Installed 44 packages in 198ms
Selected target: LAD1
Selected target: TWF2
INFO:pdex._single_cell:vectorized processing: 3 targets, 18080 genes
INFO:pdex._single_cell:Processing 2 targets
Processing targets: 100%|█████████████████████████████████████████████████████████████████| 2/2 [00:05<00:00, 2.82s/it]
target reference feature target_mean ... statistic pairwise_fdr fdr diff
22040 TWF2 non-targeting MASP1 0.135913 ... 18364126.0 0.044305 0.062304 -0.017999
34612 TWF2 non-targeting PTPRT 0.887897 ... 17946027.5 0.041230 0.057592 -0.016361
#!/usr/bin/env python3
import json
import subprocess
import sys
from typing import Dict, Set, Tuple
def run_nix_eval(commit: str) -> Dict[str, str]:
"""Run nix eval command with the specified commit and return parsed JSON."""
cmd = [
"nix", "eval",
@drbh
drbh / chunk_h5ad.py
Created July 14, 2025 14:25
tool to chunk h5ad files
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "anndata",
# "numpy",
# ]
# ///
import anndata as ad
import numpy as np
import os
@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