flash_att_v2_commit_cuda := v2.5.8
flash_att_v2_commit_rocm := 2554f490101742ccdc56620a938f847f61754be6


flash-attention-v2-cuda:
  # Clone flash attention
	pip install -U packaging ninja  --no-cache-dir
	git clone https://github.com/Dao-AILab/flash-attention.git flash-attention-v2

build-flash-attention-v2-cuda: flash-attention-v2-cuda
	cd flash-attention-v2 && git fetch && git checkout $(flash_att_v2_commit_cuda)
	cd flash-attention-v2 && git submodule update --init --recursive
	cd flash-attention-v2 && python setup.py build

install-flash-attention-v2-cuda: build-flash-attention-v2-cuda
	cd flash-attention-v2 && git submodule update --init --recursive && python setup.py install

flash-attention-v2-rocm:
  # Clone flash attention
	pip install -U packaging ninja  --no-cache-dir
	git clone https://github.com/ROCm/flash-attention.git flash-attention-v2

build-flash-attention-v2-rocm: flash-attention-v2-rocm
	cd flash-attention-v2 && git fetch && git checkout $(flash_att_v2_commit_rocm)
	cd flash-attention-v2 && git submodule update --init --recursive
	cd flash-attention-v2 && GPU_ARCHS="gfx90a;gfx942" PYTORCH_ROCM_ARCH="gfx90a;gfx942" python setup.py build

install-flash-attention-v2-rocm: build-flash-attention-v2-rocm
	cd flash-attention-v2 && git submodule update --init --recursive && python setup.py install
