Skip to content

Instantly share code, notes, and snippets.

View ekzhang's full-sized avatar

Eric Zhang ekzhang

View GitHub Profile
@ekzhang
ekzhang / hello_matmul.cu
Last active February 2, 2025 19:24
Get started with matmul on CUDA — following https://siboehm.com/articles/22/CUDA-MMM
// nvcc hello_matmul.cu -o hello_matmul
// ./hello_matmul
// Quick setup for cloud GPU with VS Code (Modal):
//
// $ pip install modal && modal setup
// $ modal volume create learn-cuda
// $ modal launch vscode --gpu t4 --volume learn-cuda --image nvidia/cuda:12.4.0-devel-ubuntu22.04
#include <cstdio>
@ekzhang
ekzhang / what-is-modal.md
Last active September 12, 2024 12:51
What is Modal? (2 min)

What is [[Modal]] (to an audience of my people at Harvard/MIT):

(Preface: I really like computers! Just saying.)

Modal does two things: rent out flexible increments of compute, and build the systems for people to interact with remote computers.

Why? Computers are all around us; you checked the weather this morning, but a wind turbine operator might check the state of the electrical grid, restaurants manage inventory, even the ISS navigates in orbit with computers.

Computers are how we process huge amounts of data (in energy, elections, housing, biology…), which would never be possible by hand, and in that sense computation augments how we understand the world.

@ekzhang
ekzhang / Moonray.md
Created September 10, 2024 17:27
Notes on Moonray
  • MoonRay — [[September 8th, 2024]]
    • AOV system is interesting. Light path expressions primarily.
      • "Material AOV" provides different kinds of syntax for debugging materials.
    • Use of different JIT compilation through LLVM to implement their ISPC framework. SPMD computation on an Arras cluster.
  • This is also why the BVH data structure is important? Intel Embree vs Nvidia RTX
@ekzhang
ekzhang / hashlife.rs
Created July 1, 2024 20:30
An incomplete interview question for performance-optimizing Hashlife in Rust
use std::{collections::HashMap, sync::Arc};
use md5::{Digest, Md5};
#[derive(Clone)]
pub enum Node {
Subtree(Arc<Subtree>),
Leaf(Leaf),
}
@ekzhang
ekzhang / posix_psutil_net.py
Created February 14, 2024 23:34
Standalone net_connections() function from psutil for POSIX
"""This is a vendored copy of parts of the 'psutil' Python package.
It only contains what's needed to run the `net_connections()` function, which
lists active network connections from all processes on the system.
"""
import base64
from collections import defaultdict, namedtuple
import errno
@ekzhang
ekzhang / plasmid_data.py
Created November 19, 2023 17:34
Fast API for plasmid data from PLSDB
import json
import subprocess
import numpy as np
import pandas as pd
from fastapi import HTTPException
from modal import Image, Stub, web_endpoint
stub = Stub("plasmid-data")
@ekzhang
ekzhang / Buildcarte.ipynb
Last active April 7, 2025 00:59
Build Systems à la Carte — Python edition
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ekzhang
ekzhang / block_event_loop.py
Created August 16, 2023 17:24
Demo of yield-dependent behavior when a coroutine blocks the event loop.
# Demo of yield-dependent behavior when a coroutine blocks the event loop.
#
# Vary the number of calls to asyncio.sleep(0.0) in either block, and behavior will change greatly.
#
# (4 in top block, 9 in bottom block)
# 0 3.0027458667755127
# 1 2.0022785663604736
# 2 8.320808410644531e-05
# 3 4.38690185546875e-05
# 4 3.838539123535156e-05
@ekzhang
ekzhang / go.mod
Created August 15, 2023 20:44
package r2test for baseline latency
module r2test
go 1.20
require (
github.com/aws/aws-sdk-go-v2 v1.20.1
github.com/aws/aws-sdk-go-v2/config v1.18.33
github.com/aws/aws-sdk-go-v2/credentials v1.13.32
github.com/aws/aws-sdk-go-v2/service/s3 v1.38.2
)
@ekzhang
ekzhang / gened.ipynb
Created July 20, 2023 22:41
Manually adding a bunch of GENED data to the AY 2023 classes.wtf dataset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.