Skip to content

Instantly share code, notes, and snippets.

@pcuenca
pcuenca / vscode-launch.json
Created August 11, 2024 12:58
Debug Rust dylib from Python script in Visual Studio Code
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// To debug a Rust dylib (tiktoken) from a Pyton script:
// - Launch the Python script with the Python debugger and stop at a breakpoint.
// - Get the process id (for example, `os.getpid()`)
@pcuenca
pcuenca / reshard.py
Last active November 28, 2024 22:26
Simple reshard
# Simple Llama resharding
# Tested on Llama 3.1 70B only
# Shards are released from memory as soon as we're done with each
import torch
from pathlib import Path
checkpoint = Path("original")
output_dir = Path("resharded")
output_dir.mkdir(parents=True, exist_ok=True)