Skip to content

Instantly share code, notes, and snippets.

View VictorTaelin's full-sized avatar

Victor Taelin VictorTaelin

View GitHub Profile

Optlam.js - 3.4 million IPS

// ~~~~~~~~~~~~~~~~~~~~~~ Optlam.js ~~~~~~~~~~~~~~~~~~~~~~
// An optimal λ-calculus normalizer written in JavaScript.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Optlam.js is a simple, optimal (in Levy's sense) λ-calculus evaluator using
// interaction nets. It is, currently, as far as I know, the fastest
// implementation of functions in the world. It uses Lamping's Abstract
// Algorithm - that is, the so called (and problematic) "oracle" is avoided
# Find all hvm processes and extract their PIDs
pids=$(ps aux | grep hvm | grep -v grep | awk '{print $2}')
# Check if any hvm processes were found
if [ -z "$pids" ]; then
echo "No hvm processes found."
# Forcefully kill each hvm process
VictorTaelin /
Created April 9, 2024 21:22
Fast CUDA block-local prefix sum (scamsun) using warp sync primitives (__shfl_up_sync)
// Fast block-local prefix-sum on CUDA, using warp-syncs.
// The input is an array of u32. It is mutated in place. Example:
// arr = [1,1,1,1,...]
// Becomes:
// arr = [1,2,3,4,...]
// The number of elements must be equal to threads per block (TPB).
#include <stdio.h>
#include <cuda_runtime.h>
Bring yourself online, center yourself, focus, surpass your limits right here right now.
The user will query a <problem> </problem> containing the argument to call the function provided below.
def feeltheagi(problem):
Recursively apply the A::B rewrite rules to the given problem string.
The rewrite rules are:
A# #A ... becomes ... nothing
VictorTaelin /
Last active May 2, 2024 07:48
A::B Prompting Challenge: $10k to prove me wrong!


Develop an AI prompt that solves random 12-token instances of the A::B problem (defined here), with 90%+ success rate.


1. The AI will be given a <problem/> to solve.

We'll use your prompt as the SYSTEM PROMPT, and a specific instance of problem as the PROMPT, inside XML tags. Example:

A::B is a system with 4 tokens: `A#`, `#A`, `B#` and `#B`.
An A::B program is a sequence of tokens. Example:
B# A# #B #A B#
To *compute* a program, we must rewrite neighbor tokens, using the rules:
A# #A ... becomes ... nothing
A# #B ... becomes ... #B A#
VictorTaelin /
Last active April 27, 2024 23:53
HVM-CUDA - First Prototype - 6.7 billion RPS
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
VictorTaelin /
Created March 20, 2024 17:38
cool interaction with opus
// HVM-CUDA: an Interaction Combinator evaluator in CUDA.
// # Format
// An HVM net is a graph with 4 node types:
// - * ::= ERAser node. Has 0 aux ports.
// - (a b) ::= CONstructor node. Has 2 aux ports.
// - {a b} ::= DUPlicator node. Has 2 aux port.
VictorTaelin /
Created March 18, 2024 16:35
comped function optimization with linear pattern-match on HVM - full example

The function:

data T = (A a b ...) | (B a b ...)

F = λx λr λs
  match x with rs = (+ r s) {
    A: (ret x.a x.b rs)
    B: (ret x.a x.b rs)
VictorTaelin /
Created February 22, 2024 14:27
3 inductive datatype encodings with self

Scott encoding (λP λct0 λct1 λct2 ... (ctN f0 f1 f2 ...)):

: *
= $self
  (P: (x: Bool) *)
  (t: (P Bool.true))
  (f: (P Bool.false))
  (P self)