Skip to content

Instantly share code, notes, and snippets.

View yzh119's full-sized avatar

Zihao Ye yzh119

View GitHub Profile
@yzh119
yzh119 / retro-sparsetir-artifact.md
Last active February 21, 2023 00:20
Retrospective on SparseTIR artifact

Retrospective on SparseTIR artifact

Once SparseTIR was accepted to ASPLOS 2023, we began constructing the sparsetir-artifact repository for artifact evaluation. Though we already have lots of benchmarking scripts, we found it still not a trivial job to put them together and evaluate in a unified manner. While preparing our artifact, we also found some problems with our profiler and bugs in existing implementations. We carefully addressed these issues and standardized the settings for all baselines. We are writing this post to document the challenges we faced and the lessons we learned from creating the artifact. We aim to provide insight that will benefit researchers and engineers working in related fields.

Notes on performance difference

If you previously read our manuscript on ArXiv, you may have noticed that there are some discrepancies in the reported performance between SparseTIRv3 and our [camera-ready ver

@yzh119
yzh119 / cite-formatter.py
Created January 26, 2023 18:30
Automatically add `~` before each appearance of `\cite`
import os
import sys
import glob
import logging
logging.basicConfig(level=logging.INFO)
def fix_cite_format(line_number: int, line: str):
out = ""
@yzh119
yzh119 / buggy.py
Created August 5, 2021 08:00
ell spmm with multi-level tiling
import tvm
from tvm import tir
from tvm.script import ty
from tvm.tir.schedule.schedule import Schedule
@tvm.script.tir
def ell_spmm(indices_: ty.handle, a_data: ty.handle, b: ty.handle, c: ty.handle) -> None:
mb = tir.var('int32')
n = tir.var('int32')
@yzh119
yzh119 / tir_sparse.py
Created July 30, 2021 14:53
sparse workloads in tir
import tvm
from tvm import tir
from tvm.script import ty
@tvm.script.tir
def csr_spmm(indptr_: ty.handle, indices_: ty.handle, a_data: ty.handle, b: ty.handle, c: ty.handle) -> None:
m = tir.var('int32')
n = tir.var('int32')
k = tir.var('int32')
nnz = tir.var('int32')
@yzh119
yzh119 / quine.py
Created April 2, 2021 05:50
My solution to quine program in Python
prog = "prog = {:c}{}{:c}{:c}print(prog.format(34, prog, 34, 10))"
print(prog.format(34, prog, 34, 10))
@yzh119
yzh119 / quine.c
Created April 2, 2021 05:47
My solution to quine program in C
#include <stdio.h>
char str[] = "#include <stdio.h>%cchar str[] = %c%s%c;%cint main() {%c printf(str, 10, 34, str, 34, 10, 10, 10);%c}";
int main() {
printf(str, 10, 34, str, 34, 10, 10, 10);
}
@yzh119
yzh119 / dgl-transformer.py
Created December 3, 2020 09:03
Efficient Sparse Transformer implementation with DGL's builtin operators
import dgl
import dgl.ops as ops
import numpy as np
import torch as th
import torch.nn as nn
class FFN(nn.Module):
def __init__(self, d_feat, d_ffn, dropout=0.1):
super().__init__()
self.linear_0 = nn.Linear(d_feat, d_ffn)
@yzh119
yzh119 / dgl_sage_fp16.py
Last active October 12, 2020 07:03
Training GraphSAGE w/ fp16 in DGL.
"""Training graphsage w/ fp16.
Usage:
python train_full.py --gpu 0 --fp16 --dataset
Note that GradScaler is not acitvated because the model successfully converges
without gradient scaling.
DGL's Message Passing APIs are not compatible with fp16 yet, hence we disabled
@yzh119
yzh119 / sgc-dgl.py
Last active February 20, 2019 12:54
DGL implementation of Simplified Graph Convolution
"""
This code was modified from the GCN implementation in DGL examples.
Simplifying Graph Convolutional Networks
Paper: https://arxiv.org/abs/1902.07153
Code: https://github.com/Tiiiger/SGC
SGC implementation in DGL.
"""
import argparse, time, math
@yzh119
yzh119 / draw.py
Created December 3, 2018 17:11 — forked from VoVAllen/draw.py
Draw att
# This part for jupyter notebook setting (if you wants to save, don't use this)
# %matplotlib inline
# %config InlineBackend.figure_format = 'svg'
# import numpy as np
# import matplotlib.pyplot as plt
# plt.rcParams["animation.html"] = "jshtml"
import networkx as nx
from networkx.algorithms import bipartite