This file contains 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
function num_tokens { | |
prun python -c 'import sys; import tiktoken; s = "\n".join([line for line in sys.stdin]); encoding = tiktoken.get_encoding("cl100k_base"); print(len(encoding.encode(s)))' | |
} | |
# e.g., `echo "Hello World!" | num_tokens` | |
# this should give 3 tokens. |
This file contains 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
from functools import lru_cache | |
@lru_cache # Stores previously computed factorials | |
def factorial(num): | |
if num < 2: | |
return 1 | |
return num * factorial(num - 1) | |
def N(C, m_2, m_1, m_0): | |
count = 0 |
This file contains 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
# Apply a function to any slurm job matching a regexp. | |
# For example, `son 'my_job_32.*' scancel {}` would run `scancel <job>` on any | |
# job matching the regexp. | |
function son { | |
squeue -u $USER --format="%i %j" | awk "/${1}/"' {print $1}' | xargs -I {} ${@:2} | |
} | |
# Watch a detailed `squeue` output (from Siavash Golkar) | |
function sqw { |
This file has been truncated, but you can view the full file.
This file contains 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
┌ Warning: Recursive type | |
│ T = Node{Float64} | |
└ @ Enzyme /dev/shm/.julia/packages/GPUCompiler/BxfIW/src/utils.jl:56 | |
┌ Warning: Recursive type | |
│ T = Node{Float64} | |
└ @ Enzyme /dev/shm/.julia/packages/GPUCompiler/BxfIW/src/utils.jl:56 | |
┌ Warning: Recursive type | |
│ T = Node{Float64} | |
└ @ Enzyme /dev/shm/.julia/packages/GPUCompiler/BxfIW/src/utils.jl:56 | |
┌ Warning: Recursive type |
This file contains 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
using Flux | |
using Fluxperimental: @compact | |
nf = 10 | |
nb = 32 | |
nt = 100 | |
d_attn = 64 | |
d_value = 128 | |
d_head = 16 | |
d_out = 256 |
This file contains 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
using BenchmarkTools | |
using ForwardDiff | |
using ReverseDiff | |
using Random | |
using Plots | |
using Statistics: mean, quantile, std | |
using Measurements | |
using Printf: @sprintf | |
using Colors |
This file contains 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
from argparse import ArgumentParser | |
import time | |
import numpy as np | |
import torch | |
from torch import nn | |
from torch.utils.data import DataLoader, TensorDataset | |
from torch.optim import Adam | |
from torch.nn import functional as F |
This file contains 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
<?php | |
require_once 'vendor/autoload.php'; | |
use Gregwar\Captcha\CaptchaBuilder; | |
// Create a captcha with the text "[email protected]" | |
$builder = new CaptchaBuilder('[email protected]'); | |
$builder->setMaxBehindLines(10); | |
$builder->setMaxFrontLines(10); |
This file contains 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
#main-window[titlepreface*="[Sidebery]"] #TabsToolbar { | |
visibility: collapse !important; | |
} | |
#sidebar-header { | |
display: none; | |
} | |
#main-window #TabsToolbar { | |
overflow: hidden; | |
transition: height .3s .3s !important; |
This file contains 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 re | |
def reduce_precision_of_constants_in_string(s, precision=3): | |
# Find all constants in the string: | |
constants = re.findall(r"\b[-+]?\d*\.\d+|\b[-+]?\d+\.?\d*", s) | |
for c in constants: | |
reduced_c = "{:.{precision}g}".format(float(c), precision=precision) | |
s = s.replace(c, reduced_c) | |
return s |
NewerOlder