Skip to content

Instantly share code, notes, and snippets.

@gau-nernst
gau-nernst / pytorch_varlen_attn.py
Created August 25, 2025 12:23
PyTorch's built-in varlen attention
import torch
from torch import Tensor
def varlen_attn(
query: Tensor,
key: Tensor,
value: Tensor,
cum_seq_q: Tensor,
cum_seq_k: Tensor,
@gau-nernst
gau-nernst / setup.sh
Created September 6, 2025 04:56
Set up PyTorch dev env
uv venv --python=3.12 --managed-python
source .venv/bin/activate
uv pip install --group dev
uv pip install ninja # or sudo apt install ninja-build
USE_DISTRIBUTED=0 USE_MKLDNN=0 BUILD_TEST=0 USE_FBGEMM=0 USE_NNPACK=0 USE_QNNPACK=0 USE_XNNPACK=0 USE_FLASH_ATTENTION=0 USE_MEM_EFF_ATTENTION=0 uv pip install --no-build-isolation -v -e .