Run this model with HF Jobs

Run jgalego/olmputer-tiny on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/jgalego/olmputer-tiny. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/jgalego/olmputer-tiny on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/jgalego/olmputer-tiny. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/jgalego/olmputer-tiny. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
olmputer-tiny / example.py
jgalego's picture
Upload folder using huggingface_hub
a080b45 verified
Raw History Blame Contribute Delete
1.61 kB
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "chipformer @ https://github.com/JGalego/olmputer/archive/98639dff4c84a18542e3ca12a286a4df563b3a27.tar.gz#subdirectory=experimental/riscv", # pylint: disable=line-too-long
# "huggingface_hub",
# "torch==2.14.1",
# "transformers==5.19.0",
# ]
# ///
"""Run fibonacci(25) on olmputer-tiny, the RISC-V computer in its weights.
The program's code and registers are written into the model's Gated DeltaNet states, and greedy
generate then runs the CPU: each token it generates is the next token of the execution trace. The
program ends with mv a0, t0 (the result), li a7, 93 and the exit ecall, so the result is the
second-to-last value record the model wrote.
"""
import torch
from chipformer.q35.ir import OLMO
from chipformer.rv import core, firmware, ref, spec
from chipformer.rv.programs import program
from transformers import OlmoHybridForCausalLM
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
MODEL = OlmoHybridForCausalLM.from_pretrained("jgalego/olmputer-tiny", dtype=torch.bfloat16)
MODEL = MODEL.to(DEVICE).eval()
CIRCUIT = core.build(OLMO) # the CPU as a circuit: it writes the program into the model's cache
TRACE = firmware.run(MODEL, CIRCUIT, ref.Machine.from_program(program("fib")))
VALUES = [spec.decode_value(TRACE[:i + 1]) for i, t in enumerate(TRACE)
if spec.family(t)[0] in ("F0", "F1", "F2")]
print("fibonacci(25) =", VALUES[-2])
print(f"{len(TRACE)} trace tokens on {DEVICE}, identical to the reference machine:",
TRACE == ref.Machine.from_program(program("fib")).run()[1:])