This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import math | |
from dataclasses import dataclass | |
import torch | |
from torch import nn | |
import torch.nn.functional as F | |
from transformers import AutoProcessor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from functools import lru_cache | |
import torch | |
from torch import nn | |
import torch.nn.functional as F | |
from transformers import Qwen3Config | |
from transformers import Qwen2TokenizerFast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# https://github.com/FateScript/experiments/blob/main/se/mpi/mpi.py | |
# https://github.com/facebookincubator/gloo/tree/main/gloo | |
import math | |
import multiprocessing | |
import os | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
import numpy as np | |
import gym | |
# Hyperparameters | |
num_inputs = 4 | |
num_actions = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
× / | |
← → ↔ ⇐ ⇒ ⇔ | |
⟵ ⟶ ⟷ ⟸ ⟹ ⟺ | |
∀ ∃ | |
∂ ∫ | |
∈ ∊ ∉ | |
∏ ∑ | |
∙ ⋅ | |
√ | |
∞ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class ModelArgs: | |
dim = 288 | |
n_layers = 6 | |
n_heads = 6 | |
norm_eps = 1e-6 | |
def build_cos_sin_cache(head_dim, seq_len, base=10000): | |
theta = 1. / (base ** (np.arange(0, head_dim, 2, dtype=np.float32) / head_dim)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
N_inp = 64 | |
N_out = 64 | |
d = 128 | |
Q = np.random.randn(N_out, d) | |
K = np.random.randn(N_inp, d) | |
V = np.random.randn(N_inp, d) | |
O = np.random.randn(N_out, d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from threading import Barrier, Thread | |
from collections import namedtuple | |
dim3 = namedtuple("dim3", ["x", "y", "z"], defaults=(1, 1)) | |
TILE = 16 | |
def cdiv(a, b): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name adventofcode daylight mode | |
// @namespace Violentmonkey Scripts | |
// @match https://adventofcode.com/* | |
// @grant none | |
// @version 1.0 | |
// @author scturtle | |
// @description 2023/11/27 16:52:13 | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
from pathlib import Path | |
from typing import List | |
MARK = "// -----// IR Dump" | |
PAT = re.compile(r'IR Dump \w+ (\w+)') | |
def main(infile: Path, outdir: Path): | |
assert infile.exists(), f'{infile} not exists' |
NewerOlder