A GPU-native programming language made of pure emoji.
π π
π₯ 6
π₯ 7
βοΈ
π¨οΈ
π
EmojiASM is a stack-based assembly language where every opcode is an emoji. It runs on a Python VM, compiles to native binaries via C, and β its primary purpose β executes directly on Apple Silicon GPUs as Metal compute kernels alongside LLM inference.
LLM agents need to execute code. The round-trip from GPU (where inference runs) to CPU (where code runs) and back is the bottleneck. EmojiASM eliminates it:
Traditional: LLM (GPU) β CPU β Python/JS β CPU β back to LLM (GPU)
EmojiASM: LLM (GPU) β EmojiASM kernel (same GPU) β back to LLM
zero copies, zero transfers, ~1.5ΞΌs dispatch
Run 10,000 parallel EmojiASM instances on GPU in the time it takes to run 10 on CPU. The entire execution stays in Apple Silicon unified memory.
from emojiasm import EmojiASMTool
tool = EmojiASMTool()
# Write Python β runs on GPU as EmojiASM
result = tool.execute_python("""
import random
hits = 0
for i in range(10000):
x = random.random()
y = random.random()
if x*x + y*y <= 1.0:
hits += 1
print(4.0 * hits / 10000)
""", n=10_000)
print(result["stats"]["mean"]) # 3.1415...pip install emojiasm
# CPU interpreter
emojiasm examples/hello.emoji
emojiasm examples/fibonacci.emoji
# AOT compile to native binary
emojiasm --compile examples/fibonacci.emoji
# GPU execution (Apple Silicon + MLX)
emojiasm --gpu --gpu-instances 10000 examples/monte_carlo_pi.emoji
# Python transpiler β write Python, run as EmojiASM
emojiasm --from-python examples_py/monte_carlo_pi.py
emojiasm --transpile examples_py/fibonacci.py # emit EmojiASM source37 opcodes. No ASCII keywords.
| Emoji | Name | Stack Effect |
|---|---|---|
| π₯ val | PUSH | ( -- val ) |
| π€ | POP | ( v -- ) |
| π | DUP | ( v -- v v ) |
| π | SWAP | ( a b -- b a ) |
| π«΄ | OVER | ( a b -- a b a ) |
| π | ROT | ( a b c -- b c a ) |
| Emoji | Name | Stack Effect |
|---|---|---|
| β | ADD | ( a b -- a+b ) |
| β | SUB | ( a b -- a-b ) |
| βοΈ | MUL | ( a b -- a*b ) |
| β | DIV | ( a b -- a/b ) |
| π’ | MOD | ( a b -- a%b ) |
| π² | RANDOM | ( -- float ) |
| Emoji | Name | Stack Effect |
|---|---|---|
| π° | CMP_EQ | ( a b -- 0|1 ) |
| π | CMP_LT | ( a b -- 0|1 ) |
| π | CMP_GT | ( a b -- 0|1 ) |
| π€ | AND | ( a b -- 0|1 ) |
| π€ | OR | ( a b -- 0|1 ) |
| π« | NOT | ( a -- 0|1 ) |
| Emoji | Name | Notes |
|---|---|---|
| π label | JMP | Unconditional jump |
| π€ label | JZ | Jump if zero (consumes condition) |
| π€ label | JNZ | Jump if non-zero (consumes condition) |
| π func | CALL | Call function (shared stack) |
| π² | RET | Return from function |
| π | HALT | Stop program |
| π€ | NOP | No operation |
| Emoji | Name | Notes |
|---|---|---|
| π’ | Print without newline | |
| π¨οΈ | PRINTLN | Print with newline |
| π¬ "text" | PRINTS | Push string literal |
| π€ | INPUT | Read line from stdin |
| π | INPUT_NUM | Read number from stdin |
| Emoji | Name | Stack Effect |
|---|---|---|
| π§΅ | STRLEN | ( s -- n ) |
| βοΈ | SUBSTR | ( s start len -- s' ) |
| π | STRINDEX | ( s sub -- n ) |
| π | STR2NUM | ( s -- n ) |
| π€ | NUM2STR | ( n -- s ) |
| Emoji | Name | Notes |
|---|---|---|
| πΎ cell | STORE | Store to named cell (any emoji) |
| π cell | LOAD | Load from named cell |
| Emoji | Purpose |
|---|---|
| π name | Define function (entry point: π ) |
| π·οΈ name | Define jump label |
| π text | Comment |
| π¦ name | Import module (name.emoji) |
The Python VM β full feature support, debug tracing, REPL.
emojiasm examples/fibonacci.emoji # run
emojiasm -d examples/fibonacci.emoji # debug trace
emojiasm --repl # interactive shellCompiles to C, then to a native binary via clang. ~250x faster than the interpreter.
emojiasm --compile examples/fibonacci.emoji
emojiasm --compile --opt=-O3 examples/fibonacci.emoji
emojiasm --emit-c examples/fibonacci.emoji # inspect generated CWrite Python, run as EmojiASM. Compiles a numeric subset of Python (arithmetic, variables, loops, conditionals, functions, random.random()) to EmojiASM via the ast module.
# Transpile and run
emojiasm --from-python examples_py/monte_carlo_pi.py
# See the generated EmojiASM
emojiasm --transpile examples_py/fibonacci.py
# Compose with other flags
emojiasm --from-python script.py --gpu --gpu-instances 10000
emojiasm --from-python script.py --compile --opt=-O3from emojiasm import EmojiASMTool
tool = EmojiASMTool()
result = tool.execute_python("print(6 * 7)", n=1)
# β {"success": true, "mode": "cpu", ...}Supported Python subset: int, float, +, -, *, /, //, %, comparisons, and/or/not, if/elif/else, while, for x in range(), break/continue, def/return (including recursion), print(), random.random().
Runs EmojiASM programs as Metal compute kernels on Apple Silicon. Each GPU thread is an independent VM instance. Designed for parallel agent workloads.
# 10,000 parallel instances on GPU
emojiasm --gpu --gpu-instances 10000 examples/monte_carlo_pi.emoji
# Agent mode: structured JSON output
emojiasm --agent-mode --runs 1000 examples/monte_carlo_pi.emojiGPU execution tiers:
- Tier 1 β Numeric-only programs: full GPU, maximum performance
- Tier 2 β Programs with PRINT: GPU with output buffer
- Tier 3 β Programs with INPUT: automatic CPU fallback
EmojiASM's GPU backend is a switch-dispatch bytecode interpreter kernel β one MSL kernel compiled once, interpreting any program. Each GPU thread runs an independent VM with its own stack.
.emoji β parse() β compile_to_bytecode() β mx.fast.metal_kernel(grid=(N,1,1))
Python uint32[] (ΞΌs) Metal compute, N instances
This is based on 101 research findings from 10 parallel investigation agents, validated by 7+ published GPU VM systems (GVM, ProtonVM, Barracuda, tensorForth). See docs/GPU_FEASIBILITY.md for the full technical report.
| Instances | CPU (Python VM) | GPU (Metal) | Speedup |
|---|---|---|---|
| 100 | 16.3s | 82ms | 199x |
| 1,000 | 163s | 83ms | 1,964x |
| 10,000 | ~27min | 217ms | ~4,700x |
- Zero SIMD divergence β all threads run the same program, same opcodes in lockstep
- Unified memory β zero-copy between CPU and GPU on Apple Silicon
- MLX integration β dispatches alongside LLM inference in the same command buffer (~1.5ΞΌs overhead)
- No prior Metal implementation β EmojiASM is the first bytecode interpreter on Apple Metal
EmojiASM is designed as a tool for LLM agents. EmojiASMTool provides automatic GPU/CPU routing, validation, and OpenAI-compatible tool specs:
from emojiasm import EmojiASMTool
tool = EmojiASMTool(max_instances=10_000)
# Execute EmojiASM source (auto-routes to GPU when beneficial)
result = tool.execute(emoji_source, n=1000)
# Execute Python source (transpile + run)
result = tool.execute_python(python_source, n=1000)
# β {"success": true, "mode": "gpu", "instances": 1000, "completed": 1000,
# "results": [...], "stats": {"mean": 3.14, ...}, "total_time_ms": 83.2}
# Validate without executing
info = tool.validate(emoji_source)
# β {"valid": true, "tier": 1, "gpu_compatible": true, "num_instructions": 37}
# OpenAI function calling
spec = tool.as_tool_spec() # returns tool definition
result = tool.handle_tool_call({"arguments": {"source": "...", "instances": 1000}})Routing logic: GPU when n >= 256, MLX available, and program is Tier 1-2. CPU otherwise.
The CLI also supports structured JSON output:
emojiasm --gpu --gpu-instances 10000 examples/monte_carlo_pi.emoji
emojiasm --agent-mode --runs 1000 examples/monte_carlo_pi.emojiemojiasm/
__init__.py Package exports (EmojiASMTool, transpile)
__main__.py CLI entry point
parser.py Emoji tokenizer + assembler
vm.py Stack-based virtual machine (CPU)
transpiler.py Python-to-EmojiASM transpiler (ast.NodeVisitor)
compiler.py AOT compiler (Program β C β native binary)
bytecode.py GPU bytecode encoder (Program β uint32[])
gpu.py MLX Metal kernel backend + output buffer
inference.py LLM integration (EmojiASMTool, auto GPU/CPU routing)
agent.py Agent mode (parallel CPU runs, JSON output)
repl.py Interactive REPL
opcodes.py Opcode definitions (37 ops, 40 emoji mappings)
disasm.py Disassembler
metal/
vm.metal MSL compute kernel (switch-dispatch bytecode interpreter)
docs/
REFERENCE.md Language reference
GPU_FEASIBILITY.md GPU execution technical report (101 findings)
examples/ Example .emoji programs
examples_py/ Example .py programs (for transpiler)
tests/ 715 tests
scripts/ Agent runner, KB tools
kb/ Knowledge base (185 findings)
- Language Reference β complete opcode reference with stack effects
- GPU Feasibility Report β technical deep-dive on Metal execution
MIT