Skip to content

Instantly share code, notes, and snippets.

View Ryu1845's full-sized avatar
🎯
Focusing

Sofian Mejjoute Ryu1845

🎯
Focusing
View GitHub Profile
@Mikubill
Mikubill / convnext-v2-train.py
Created November 19, 2023 15:24
ConvNeXt V2 Image Classifier
import os
import random
import math, warnings
from copy import deepcopy
import numpy as np
import lightning
import torch
import torch.nn as nn
import torch.nn.functional as F
@norabelrose
norabelrose / dpo.py
Created November 8, 2023 07:04
Training quirky models with DPO
from argparse import ArgumentParser
from datasets import load_dataset
from peft import LoraConfig
from trl import DPOTrainer
from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments
if __name__ == "__main__":
parser = ArgumentParser()
@rtkclouds
rtkclouds / ccore_layer.py
Created November 7, 2023 03:58
ccore layer
class Rezero(layers.Layer):
def __init__(self):
super().__init__()
self.alpha1 = tf.Variable(0.0, trainable=True)
def call(self, inputs, training):
return self.alpha1*inputs
class CustomRezero(tf.keras.layers.Layer):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LiquidityC
LiquidityC / Makefile
Last active March 21, 2025 07:48
Generic drop in Makefile
VERSION = \"1.0.0\"
PREFIX ?= out
INCDIR = include
SRCDIR = src
LANG = c
OBJDIR = .obj
MODULE ?= binary_name
CC ?= gcc
@sekstini
sekstini / Residual_FSQ_Example.ipynb
Last active April 23, 2024 07:41
Residual FSQ MNIST Example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@OhadRubin
OhadRubin / combine_txt.md
Created September 28, 2023 13:13
combine_txt_prompt

Instructions

Your task: Combine multiple texts into one detailed document. Include every piece of information from each source. The goal is to avoid repetition while being thorough and exhaustive.

Essential steps:

  1. Organize structure carefully.
  2. Integrate all details.
  3. Avoid redundancy.

Warnings:

  • Be precise, not general.
@ChrisHayduk
ChrisHayduk / merge_qlora_with_quantized_model.py
Last active June 14, 2025 17:50
Merging QLoRA weights with quantized model
"""
The code below combines approaches published by both @eugene-yh and @jinyongyoo on Github.
Thanks for the contributions guys!
"""
import torch
import peft
@KohakuBlueleaf
KohakuBlueleaf / retention.py
Created July 20, 2023 09:36
A simple implementation of retention (from https://arxiv.org/pdf/2307.08621.pdf)
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
def parallel_retention(
q, k, v, # bsz, heads, seq_len, dim
decay_mask = None # heads, seq_len, seq_len
@cloneofsimo
cloneofsimo / flash.py
Created June 22, 2023 07:51
FlashAttention comparison
import pytest
import torch
import triton
import triton.language as tl
@triton.jit
def _fwd_kernel(
Q, K, V, sm_scale,