Run this model with HF Jobs

Run NoesisLab/LITOperator 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 to fine-tune https://huggingface.co/NoesisLab/LITOperator. 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/NoesisLab/LITOperator 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.
LITOperator / demo /tree_io.py
OzTianlu's picture
Duplicate from ReasoningKingdom/LITOperator
1ddfac5
Raw History Blame Contribute Delete
1.84 kB
#!/usr/bin/env python3
"""tree_io.py — read a pretrained LIT tree snapshot with numpy.
The C safetensors loader rejects checkpoints that contain duplicate
keys, which an open-set tree produces. The snapshot arrays are standard
safetensors tensors, so the render demos read them directly.
"""
import json
import os
import struct
import sys
import numpy as np
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(ROOT, "sandbox", "lerobot_host"))
CKPT = os.path.join(ROOT, "sandbox", "lerobot_host",
"community_open_pretrain.safetensors")
REPO = "lerobot/community_dataset_v3"
SUB = "00ri/so100_battery"
LINK = (0.10, 0.12, 0.12, 0.08)
_DT = {"U32": "<u4", "U64": "<u8", "U8": "u1"}
def load_snapshot(path=CKPT):
with open(path, "rb") as f:
hlen = struct.unpack("<Q", f.read(8))[0]
hdr = json.loads(f.read(hlen))
data = f.read()
def tensor(name):
h = hdr[name]
dt = _DT[h["dtype"]]
a = h["data_offsets"][0]
n = int(np.prod(h["shape"]))
return np.frombuffer(data, dtype=dt, count=n, offset=a).reshape(
h["shape"])
return {k: tensor(k) for k in hdr if k != "__metadata__"}
def children_map(parent):
children = {}
for i in range(1, len(parent)):
children.setdefault(int(parent[i]), []).append(i)
return children
def chain_from(children, g, start, limit=4000):
"""Follow g == 0 (data) children from a start node."""
cur = start
path = []
for _ in range(limit):
ch = [c for c in children.get(cur, []) if int(g[c]) == 0]
if not ch:
break
nxt = min(ch)
path.append(nxt)
cur = nxt
return path
def data_path(parent, g, limit=4000):
return chain_from(children_map(parent), g, 0, limit)