Skip to content

Instantly share code, notes, and snippets.

View jingwangsg's full-sized avatar
💭
I may be slow to respond.

jingwangsg jingwangsg

💭
I may be slow to respond.
  • Singapore
  • 21:54 (UTC +08:00)
View GitHub Profile
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) [2023] [Captain Vincent]
* Original Source: https://gist.github.com/CaptainVincent/74a15cd9d9c450e961b867f69008ee6e
*
* Everyone is permitted to copy and distribute verbatim copies of this license document,
* but changing it is not allowed.
*
@jingwangsg
jingwangsg / Dockerfile
Created February 10, 2025 05:31
eval docker image
# stage 1: clone repo using ssh key
FROM ubuntu:22.04 AS clone
RUN apt-get update
RUN apt-get install -y git
# Add the keys and set permissions
ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa
import os
import os.path as osp
import json
import glob
from prompts import *
import google.generativeai as genai
import time
from queue import Queue, Empty
from typing import Dict
import threading
@jingwangsg
jingwangsg / ratio_sampler.py
Last active October 8, 2024 09:59
ratio sampler
import torch
import random
class RatioSampler(torch.utils.data.Sampler):
def __init__(self, dataset, ratio=1.0, shuffle=True):
self.dataset_size = len(dataset)
self.ratio = ratio
self.shuffle = shuffle
# Calculate the number of samples per episode
@jingwangsg
jingwangsg / rotaryemb_patch.py
Created October 7, 2024 21:09
rotaryemb_patch
import torch
import torch.nn as nn
class RotaryEmbeddingPatched(nn.Module):
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
super().__init__()
self.dim = dim
self.max_position_embeddings = max_position_embeddings
@jingwangsg
jingwangsg / sailconfig.fish
Last active August 6, 2024 12:00
sailconfig
if status is-interactive
# Commands to run in interactive sessions can go here
end
# ================== PATH ==================
# set -x PATH
set -x AWS_ACCESS_KEY_ID wangjing01
set -x AWS_SECRET_ACCESS_KEY jm2E6gBaFZvD
set -x TZ Asia/Singapore
if status is-interactive
# Commands to run in interactive sessions can go here
end
# ================== PATH ==================
# set -x PATH
set -x AWS_ACCESS_KEY_ID wangjing01
set -x AWS_SECRET_ACCESS_KEY jm2E6gBaFZvD
set -x TZ Asia/Singapore
@jingwangsg
jingwangsg / blocks.py
Created July 1, 2024 06:36
Common Blocks
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# References:
# PixArt: https://github.com/PixArt-alpha/PixArt-alpha
# Latte: https://github.com/Vchitect/Latte
# DiT: https://github.com/facebookresearch/DiT/tree/main
# GLIDE: https://github.com/openai/glide-text2im
# MAE: https://github.com/facebookresearch/mae/blob/main/models_mae.py
# --------------------------------------------------------
@jingwangsg
jingwangsg / crawl.py
Last active June 25, 2024 06:07
Crawler
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException, TimeoutException
import time
import random
import os, os.path as osp
import tempfile
@jingwangsg
jingwangsg / gist:ace43e86c24453aacfd0621ff777bd5b
Last active April 16, 2024 03:36
DDP Synchronize Trace for multi-gpu debugging
from ...dist import synchronize, get_rank
ignored = False
def ddp_synchronize_trace(frame, event, arg):
if event == "line" and not ignored:
synchronize()
return ddp_synchronize_trace