Skip to content

Instantly share code, notes, and snippets.

View LiutongZhou's full-sized avatar
🏠
Working

Liutong Zhou LiutongZhou

🏠
Working
  • Apple
  • New York
View GitHub Profile
@LiutongZhou
LiutongZhou / heap.py
Last active June 6, 2022 01:08
Priority queues
"""MinHeap and MaxHeap (Optimized Implementation)"""
from abc import ABC, abstractmethod
from collections import Counter, UserList
from functools import singledispatchmethod
from heapq import (
_heapify_max,
_heappop_max,
_heapreplace_max,
_siftdown,
_siftdown_max,
@LiutongZhou
LiutongZhou / bitmask.py
Last active February 6, 2022 04:57
BitMask
"""BitMask"""
class BitMask:
__slots__ = ("size", "mask")
def __init__(self, size: int = 16):
"""Create a bit mask to store (size) 0/1 status"""
self.size = size
self.mask = 1 << size
@LiutongZhou
LiutongZhou / dist-train.md
Last active February 10, 2023 15:55
Large-Scale Distributed Data and Model Parallel Training

Large-Scale Distributed Data and Model Parallel Training

Data Streaming

image

FastFile Mode

sagemaker.inputs.TrainingInput(S3_INPUT_FOLDER, input_mode='FastFile') 
@LiutongZhou
LiutongZhou / document_project.md
Last active August 18, 2022 19:52
Document a Project

How to document a project

How to update the docs and publish to the Home Page?

Prerequisites One-time installation of dependencies
python3 -m pip install -U jupyter-book ghp-import
@LiutongZhou
LiutongZhou / docker_tips.md
Last active May 1, 2024 00:36
Docker Tips

Docker Tips

Move default docker storage to another location

nano /etc/docker/daemon.json

## add this config
{
"data-root": "/newlocation"
}
"""Data Strutures that extend OrderedDict"""
from collections import Counter, OrderedDict
from typing import Any, Hashable, Optional, Tuple, List
from hypothesis import given, strategies as st
__all__ = ["OrderedDefaultDict", "MinMaxCounter"]
class OrderedDefaultDict(OrderedDict):
@LiutongZhou
LiutongZhou / memory_efficient_training.md
Last active July 11, 2023 15:37
Memory Efficient Training of LLMs
@LiutongZhou
LiutongZhou / universal_decorator.py
Last active May 13, 2024 15:23
Universal Decorator
"""Universal Decorator
Universal decorators can decorate functions, classes, bound methods
(class method / instance method) referenced outside of class definition
and descriptors (class methods, static methods) defined inside class definition.
"""
from __future__ import annotations
import inspect