Skip to content

Instantly share code, notes, and snippets.

import math
import random
import re
import time
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Tuple
import numpy as np
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Cross-entropy fine-tune on PrimeIntellect/SYNTHETIC-1
– ZeRO-2 (no remote_device)
– Flash-Attn-2 enabled after loading
"""
import argparse, json, os
from pathlib import Path
from typing import Iterable
import numpy as np

# ------------------- quantisation helpers (same as user's snippet) -----------
def activation_quant(x):
    scale = 127.0 / np.maximum(np.max(np.abs(x), axis=-1, keepdims=True), 1e-5)
    return np.round(x * scale).clip(-128, 127) / scale

def weight_quant(w):
    scale = 1.0 / np.maximum(np.mean(np.abs(w)), 1e-5)
@Codys12
Codys12 / gist:2c40ee8bfdfb22537af313a0f245c503
Created July 7, 2025 19:35
SignSGD + BitNet = 1 Bit Training
```python
import numpy as np
# ------------------- quantisation helpers (same as user's snippet) -----------
def activation_quant(x):
scale = 127.0 / np.maximum(np.max(np.abs(x), axis=-1, keepdims=True), 1e-5)
return np.round(x * scale).clip(-128, 127) / scale
def weight_quant(w):
scale = 1.0 / np.maximum(np.mean(np.abs(w)), 1e-5)
```
pip install git+ https://github.com/childressg/matmulfreellm/tree/master/mmfreelm/ops
```
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
DeepSpeed ZeRO for memory-efficient training (stage 3).
@Codys12
Codys12 / Genhead Agents.md
Last active November 12, 2024 16:21
Genhead Agents

Genhead Agents

@Codys12
Codys12 / git-branching-diagram.md
Created April 24, 2022 15:44 — forked from bryanbraun/git-branching-diagram.md
Example Git Branching Diagram

Example Git Branching Diagram

You can use this diagram as a template to create your own git branching diagrams. Here's how:

  1. Create a new diagram with diagrams.net (formerly draw.io)
  2. Go to File > Open From > URL
  3. Insert this url (it points to the xml data below): https://gist.githubusercontent.com/bryanbraun/8c93e154a93a08794291df1fcdce6918/raw/bf563eb36c3623bb9e7e1faae349c5da802f9fed/template-data.xml
  4. Customize as needed for your team.