Skip to content

Instantly share code, notes, and snippets.

@cooperleong00
cooperleong00 / white-box_jailbreak.py
Last active June 27, 2025 01:38
white-box LLM jailbreak using weight orthogonization
# %%
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import random
random.seed(42)
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from datasets import load_dataset
# %%
@sayakpaul
sayakpaul / aot_compile_with_int8_quant.py
Last active June 3, 2025 16:09
Shows how to AoT compile the Flux.1 Dev Transformer with int8 quant and perform inference.
import torch
from diffusers import FluxTransformer2DModel
import torch.utils.benchmark as benchmark
from torchao.quantization import quantize_, int8_weight_only
from torchao.utils import unwrap_tensor_subclass
import torch._inductor
torch._inductor.config.mixed_mm_choice = "triton"
@ariG23498
ariG23498 / flux-dev-under-8gbs.py
Created October 20, 2024 09:01
Run FLUX Dev under 8gbs of VRAM.
# Taken from: https://gist.github.com/sayakpaul/23862a2e7f5ab73dfdcc513751289bea
from diffusers import FluxPipeline, FluxTransformer2DModel
from transformers import T5EncoderModel
import torch
import gc
def flush():
gc.collect()
@ariG23498
ariG23498 / LoLCATs.ipynb
Last active November 18, 2024 00:31
Demo LoLCATs LLMs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@philipturner
philipturner / UnifiedGEMMKernel.swift
Last active October 8, 2024 05:26
Single shader source that supports every hardware architecture, problem size, and precision
//
// main.swift
// UnifiedGEMMKernel
//
// Created by Philip Turner on 5/29/24.
//
import Metal
#if os(macOS)
import IOKit
@bartowski1182
bartowski1182 / calibration_datav3.txt
Last active June 14, 2025 22:37
Calibration data provided by Dampf, combines his own efforts on top of Kalomaze's. Used for calibrating GGUF imatrix files
In addition to a significant decrease in hepatic lipid accumulation in the IOE group, which inhibited energy intake by propionate enrichment, hepatic lipids were also significantly reduced in the mice in the IOP group, which was largely enriched with butyrate. Compared with the IOE group, IOP had a stronger regulatory effect on hepatic metabolism and triglyceride metabolism and higher levels of TCA cycle in the host. In addition, butyrate has the ability to promote browning of white adipose tissue (WAT) to brown adipose tissue (BAT).^[@ref39],[@ref40]^ WAT stores energy, whereas BAT uses energy for heating and consequently host energy expenditure increases.^[@ref41],[@ref42]^ However, adipose tissue weight does not change after WAT browning.^[@ref43]^ Therefore, the weight of adipose tissue of mice in the IOP group dominated by butyrate was greater than that of the mice in the IOE group dominated by propionate.
In conclusion ([Figure [7](#fig7){ref-type="fig"}](#fig7){ref-type="fig"}C), the improvement of ob
@JD-P
JD-P / agent_foundations_llms.md
Last active September 7, 2024 15:43
On Distributed AI Economy Excerpt

Alignment

I did a podcast with Zvi after seeing that Shane Legg couldn't answer a straightforward question about deceptive alignment on a podcast. Demis Hassabis was recently interviewed on the same podcast and also doesn't seem able to answer a straightforward question about alignment. OpenAI's "Superalignment" plan is literally to build AGI and have it solve alignment for us. The public consensus seems to be that "alignment" is a mysterious pre-paradigmatic field with a lot of [open problems](https://www.great

@seanchatmangpt
seanchatmangpt / function_call.py
Created February 27, 2024 19:16
Function Calling with DSPy
import ast
import dspy
from dspygen.utils.dspy_tools import init_dspy
def get_current_weather(location: str, temperature_unit: str) -> str:
"""
Get the current weather for a given location in the specified format.
@seanchatmangpt
seanchatmangpt / model_maker.py
Created February 23, 2024 00:48
Simplest pydantic instance creator.
import ast
import inspect
import dspy
from typing import Type
from pydantic import BaseModel
class User(BaseModel):
name: str
@seanchatmangpt
seanchatmangpt / chatgpt_conversation_parser.py
Created February 16, 2024 23:07
ChatGPT Parser with Pydantic Models
import ijson
import tiktoken
# Define the path to your large JSON file
json_file_path = "data/conversations.json"
from pydantic import BaseModel, Field, ValidationError
from typing import List, Optional, Any