Skip to content

Instantly share code, notes, and snippets.

View zxgx's full-sized avatar
🐼

Geng Zhang zxgx

🐼
View GitHub Profile
@zxgx
zxgx / gist:2874bc7056dd2ec1b8d7ab5570deddd0
Last active September 19, 2024 19:32
qkvpadded flash attn varlen vs padded, v2.6.3
import time
import numpy as np
import torch
from itertools import accumulate
from flash_attn import flash_attn_varlen_qkvpacked_func, flash_attn_qkvpacked_func
device = torch.device('cuda:0')
dtype = torch.bfloat16
@zxgx
zxgx / gist:4891e67b4eacf03e41776212567102b8
Created December 23, 2023 18:27 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@zxgx
zxgx / nsight.sh
Created November 4, 2023 16:55 — forked from mcarilli/nsight.sh
Favorite nsight systems profiling commands for Pytorch scripts
# This isn't supposed to run as a bash script, i named it with ".sh" for syntax highlighting.
# https://developer.nvidia.com/nsight-systems
# https://docs.nvidia.com/nsight-systems/profiling/index.html
# My preferred nsys (command line executable used to create profiles) commands
#
# In your script, write
# torch.cuda.nvtx.range_push("region name")
# ...
@zxgx
zxgx / linear_svm.py
Created August 19, 2020 15:50
linear svm pytorch implementation
import torch
import torch.nn as nn
import random
import math
def hinge_loss(scores, targets):
'''
multi-class extension: https://en.wikipedia.org/wiki/Hinge_loss
Weston Jason & Watkins Chris (1999).
Support Vector Machines for Multi-Class Pattern Recognition.