Skip to content

Instantly share code, notes, and snippets.

View jackalcooper's full-sized avatar

Shenghang Tsai jackalcooper

View GitHub Profile
@willccbb
willccbb / grpo_demo.py
Last active April 28, 2025 01:48
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
@leizaf
leizaf / tokenizer.zig
Created August 30, 2024 06:20
Zig MLIR Lexer
const std = @import("std");
const cc = std.ascii.control_code;
const startsWith = std.mem.startsWith;
fn isDigitNotZero(c: u8) bool {
return switch (c) {
'1'...'9' => true,
else => false,
};
}
@banach-space
banach-space / matmul.mlir
Last active June 3, 2024 07:11
C += A*B
// The following matmul maps very nicely onto SME with SVL=128bits. For f32, there are 4 4x4 tiles,
// that can be assembled as a 8x8 matrix.
// %mat_A_tr - transpose of A
func.func @matmul(%mat_A_tr: memref<6x8xf32>, %mat_B: memref<6x8xf32>, %mat_C: memref<8x8xf32>) {
linalg.matmul ins(%mat_A_tr, %mat_B: memref<6x8xf32>, memref<6x8xf32>)
outs(%mat_C: memref<8x8xf32>)
return
}
@caspg
caspg / 1_searchbar_live.ex
Last active February 23, 2025 13:52
Example of real-time search bar implementation in Phoenix LiveView and Tailwind. Working example on https://travelermap.net/parks/usa
defmodule TravelerWeb.SearchbarLive do
use TravelerWeb, :live_view
alias Phoenix.LiveView.JS
alias Traveler.Places
def mount(_params, _session, socket) do
socket = assign(socket, places: [])
{:ok, socket, layout: false}
end
@shingohry
shingohry / ViewController.swift
Created June 11, 2019 17:13
NetworkingWithCombine
import UIKit
import Combine
/*
# References
- [ra1028/SwiftUI-Combine: This is an example project of SwiftUI and Combine using GitHub API.](https://github.com/ra1028/SwiftUI-Combine)
- [marty-suzuki/GitHubSearchWithSwiftUI: SwiftUI and Combine based GitHubSearch example.](https://github.com/marty-suzuki/GitHubSearchWithSwiftUI)
- [DataTaskPublisherを作ってみた](https://gist.github.com/yamoridon/16c1cc70ac46e50def4ca6695ceff772)
- [【iOS】Combineフレームワークまとめ(2019/6/9時点) - Qiita](https://qiita.com/shiz/items/5efac86479db77a52ccc)
*/
@alexito4
alexito4 / RemoteImage.swift
Last active August 19, 2020 15:32
Rough sketch of SwiftUI RemoteImage using AlamofireImage
import SwiftUI
import Combine
import AlamofireImage
let imageDownloader = ImageDownloader(
configuration: ImageDownloader.defaultURLSessionConfiguration(),
downloadPrioritization: .fifo,
maximumActiveDownloads: 4,
imageCache: AutoPurgingImageCache()
)
@mjambon
mjambon / parallel
Last active March 28, 2024 11:09
bash: Run parallel commands and fail if any of them fails
#! /usr/bin/env bash
#
# Run parallel commands and fail if any of them fails.
#
set -eu
pids=()
for x in 1 2 3; do
@TomFaulkner
TomFaulkner / ubuntu18.04-vfio.md
Last active January 24, 2025 13:52
VFIO Setup on Ubuntu 18.04
@gangliao
gangliao / plot_bench_1.py
Last active May 24, 2024 10:53
Horovod with TCP and IB
import matplotlib.pyplot as plt
#for plotting
import numpy as np
# create plot
fig, ax = plt.subplots()
bar_width = 0.15
opacity = 0.8
xlabel= np.array([8, 16, 32, 64])
@peterroelants
peterroelants / mnist_new_dataset_hook.py
Created August 8, 2017 08:32
Tensorflow Dataset API initialiser hook fix
from __future__ import division, print_function, absolute_import, \
unicode_literals
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
from tensorflow.contrib.learn import ModeKeys
from tensorflow.contrib.learn.python.learn import learn_runner