Skip to content

Instantly share code, notes, and snippets.

View lyuwen's full-sized avatar

LFu lyuwen

View GitHub Profile
@devymex
devymex / saver_llama2_hf.py
Last active April 18, 2025 06:24
Plugin of Megatron-LM for saving llama-2 checkpoint as HuggingFace format
import os, torch, torch.multiprocessing as mp
from transformers import AutoModelForCausalLM, LlamaConfig
CHECK_EQUAL_WITH_HF = '' # A pretrain directory eg. '/data/models/llama-2-hf/7b-chat'
def add_arguments(parser):
group = parser.add_argument_group(title='Llama-2 HF saver.')
group.add_argument('--megatron-path', type=str, default=None,
help='Base directory of megatron checkpoint')
@xenova
xenova / tiktoken-to-hf.ipynb
Last active February 8, 2026 23:15
Convert tiktoken tokenizers to the Hugging Face tokenizers format
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ozbillwang
ozbillwang / Git_Behind_Proxy.md
Last active October 17, 2025 22:34
Configure Git to use a proxy (https or SSH+GIT)
@mauler
mauler / http_server_auth.py
Last active January 21, 2026 21:55 — forked from fxsjy/SimpleAuthServer.py
Python3 http.server supporting basic HTTP Auth (username/password)
# Extended python -m http.serve with --username and --password parameters for
# basic auth, based on https://gist.github.com/fxsjy/5465353
from functools import partial
from http.server import SimpleHTTPRequestHandler, test
import base64
import os
class AuthHTTPRequestHandler(SimpleHTTPRequestHandler):
@mprostock
mprostock / dataloader_mem_leak_copy-on-access_problem.ipynb
Created December 10, 2018 10:32
"Memory Leak" copy-on-access problem in pytorch dataloaders
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sloanlance
sloanlance / jq_jsonl_conversion.md
Last active February 8, 2026 05:39
jq: JSONL ↔︎ JSON conversion

jq: JSONL ↔︎ JSON conversion

Prerequisites

  • jqhttps://jqlang.org/ — "like sed for JSON data"

    There are several options available for installing jq. I prefer to use Homebrew: brew install jq

  • JSONL → JSON

@smiley
smiley / README.md
Last active September 7, 2025 21:16
How to make an automatic "stream's live" notification for your Discord server

Making an automatic Twitch -> Discord notification (using IFTTT)

So you went live and you want everyone to know. Here's how you do it:

Part 1 - Register on IFTTT

Go to https://ifttt.com/ and create an account (if you don't already have one)

Part 2 - Make a Discord Webhook

  • Find the Discord channel in which you would like to send Tweets.
  • In the settings for that channel, find the Webhooks option and create a new webhook. Note: This URL should be kept private. It allows anyone to write messages to that specific channel using that specific URL. Keep it safe!
@brannondorsey
brannondorsey / README.md
Last active January 19, 2026 00:02
Ubuntu internet sharing and LAN over Ethernet between two+ machines

Its easy to setup a LAN between two Ubuntu machines connected over ethernet. If one of those machines, which we will call the server, is also connected to the internet via another device (like a wireless card) it will automagically share its internet connection as well. Begin by connecting the client and server machines via ethernet.

On the server machine, click the network icon on the top right and select "Edit Connections > Wired connection 1 > Edit > IPv4 Settings" and change "Method" to "Shared to other computers". Then open the network icon menu again and click "Wired connection 1" to ensure that the connection has been established. Running ifconfig in the terminal should show that the wired interface has an ip address.

On the client machine, click the network icon on the top right and select "Wired connection 1". All done. Run ifconfig on this machine as well to see the ip address you've been assigned.

@redpony
redpony / logdet.cc
Last active May 13, 2023 12:49
Computing log(M.determinant()) in Eigen C++ is risky for large matrices since it may overflow or underflow. This gist uses LU (or, if applicable, Cholesky) decompositions to do the risky components in the log space.
// set use_cholesky if M is symmetric - it's faster and more stable
// for dep paring it won't be
template <typename MatrixType>
inline typename MatrixType::Scalar logdet(const MatrixType& M, bool use_cholesky = false) {
using namespace Eigen;
using std::log;
typedef typename MatrixType::Scalar Scalar;
Scalar ld = 0;
if (use_cholesky) {
LLT<Matrix<Scalar,Dynamic,Dynamic>> chol(M);
@magnetikonline
magnetikonline / README.md
Last active March 4, 2026 21:11
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}