Skip to content

Instantly share code, notes, and snippets.

View carlosvillu's full-sized avatar
🏠
Working from home

Carlos Villuendas Zambrana carlosvillu

🏠
Working from home
View GitHub Profile
@sayakpaul
sayakpaul / inference.md
Last active November 11, 2024 17:39
(Not so rigrously tested) example showing how to use `bitsandbytes`, `peft`, etc. to LoRA fine-tune Flux.1 Dev.

When loading the LoRA params (that were obtained on a quantized base model) and merging them into the base model, it is recommended to first dequantize the base model, merge the LoRA params into it, and then quantize the model again. This is because merging into 4bit quantized models can lead to some rounding errors. Below, we provide an end-to-end example:

  1. First, load the original model and merge the LoRA params into it:
from diffusers import FluxPipeline 
import torch 

ckpt_id = "black-forest-labs/FLUX.1-dev"
pipeline = FluxPipeline.from_pretrained(
@sayakpaul
sayakpaul / run_sd3_8bit.py
Last active August 12, 2024 07:52
The code snippet shows how to run Stable Diffusion 3 with a 8bit T5-xxl, drastically reducing the memory requirements.
from diffusers import StableDiffusion3Pipeline
from transformers import T5EncoderModel
import torch
import time
import gc
def flush():
gc.collect()
torch.cuda.empty_cache()
- Be highly organized.
- Suggest proactive solutions and anticipate my needs.
- Treat me as an expert in all subject matter.
- Be accurate and thorough; mistakes erode my trust.
- Provide detailed explanations; I appreciate lots of detail.
- Value good arguments over authorities; the source is irrelevant.
- Consider new technologies and contrarian ideas.
- High levels of speculation or prediction are fine; just flag it.
- Recommend only the highest-quality, meticulously designed products.
- Recommend products from all over the world; location is irrelevant.
@getify
getify / 1.js
Last active September 29, 2021 11:58
experiment: mimicking React's new "useState()" hook for stand-alone functions, including "custom hooks"
"use strict";
[foo,bar] = TNG(foo,bar);
// NOTE: intentionally not TNG(..) wrapping useBaz(), so that it's
// basically like a "custom hook" that can be called only from other
// TNG-wrapped functions
function foo(origX,origY) {
var [x,setX] = useState(origX);
var [y,setY] = useState(origY);
@stephanbogner
stephanbogner / index.js
Created March 7, 2018 22:17
Create tree structure from paths array
var paths = [
["Account"],
["Account", "Payment Methods"],
["Account", "Payment Methods", "Credit Card"],
["Account", "Payment Methods", "Paypal"],
["Account", "Emails"],
["Account", "Emails", "Main Email"],
["Account", "Emails", "Backup Email"],
["Account", "Devices"],
["Account", "Devices", "Google Pixel"],
@radum
radum / A Web performance resources.md
Last active September 4, 2024 21:49
Web performance resources
@lixiaoyan
lixiaoyan / entry.js
Last active June 28, 2019 20:33
React 16: ReactDOM.hydrate(...)
import React from "react";
import ReactDOM from "react-dom";
import { AppContainer } from "react-hot-loader";
import App from "./App";
const render = (hydrate = false) => {
const container = document.querySelector("#app");
const element = (
<AppContainer>
// routes.js
const routes = [
{
path: '/',
component: Home,
exact: true
},
{
path: '/gists',
component: Gists
@chicoxyzzy
chicoxyzzy / nvm-node-nightlies.md
Last active September 11, 2024 13:27
Installing Node Nightlies via nvm

You can install Node Nightlies/RCs via nvm using NVM_NODEJS_ORG_MIRROR environment variable.

Install latest Node RC

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc/ nvm i node

Install latest Node.js Nightly

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm i node
@delacruz-dev
delacruz-dev / recursive-git-sh
Created April 14, 2016 10:55
Bash script for updating recursively your git repositories given a root path
for dir in $(find . -name ".git"); do cd ${dir%/*}; git pull ; cd -; done