Run this model with HF Jobs

Run neuralcrystal/microduck-crystal 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/neuralcrystal/microduck-crystal. 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/neuralcrystal/microduck-crystal 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.

Microduck Crystal

NeuralCrystal was built by Pete DeLaurentis with Shellcaster, an IDE for building complex projects with agents.

This model represents a small piece of etched glass, sized to fit inside the head of Microduck, Pollen Robotics' little two-legged robot, that walks the robot with light. It has 40 etched surfaces in four stages, and it does the work of the robot's walking policy: it reads its 61 senses every 20 ms and sets its 14 motors.

It was distilled from Pollen Robotics' own walking policy, velstand (pollen-robotics/microduck-policies, Apache-2.0), a small network of four layers: 61 → 512 → 256 → 128 → 14. The crystal has one stage of glass for each of those layers.

It was trained by distillation only, with no reinforcement learning. First each stage of glass learned to copy its own layer of the teacher. Then all four stages were tuned together on the teacher's moves. Last came DAgger: the crystal walked the duck in the simulation and the teacher labeled the moves it should have made at each step, so the crystal also learned to recover from its own mistakes.

Demo

Watch it walk at neuralcrystal.com/microduck: the duck walks in a physics simulation in your browser, with its crystal in a window at the top, and you steer it with the arrow keys. Pick "Glass, all four stages" to have the crystal do the walking, or the duck's own policy to compare with the teacher.

How it works

Each stage is a sandwich: a row of tiny LEDs on one face of the glass, ten etched phase plates inside it, and photodiodes on the far face. The light is incoherent: every LED is its own source, so each stage is linear in how bright its LEDs are. The plates steer each LED's light onto the photodiodes.

The photodiodes are read in balanced pairs. Each unit of a layer gets two photodiodes, one for plus and one for minus, and its value is the difference between them, so glass that can only add light can still compute a signed weight. A small chip on each face of the glass turns each pair's difference into a value with a fixed gain and offset per unit, applies the nonlinearity, and lights the next stage's LEDs.

In the duck, the four stages share one block of glass, folded: the light goes back and forth between two identical chips at the two ends, each stage through its own quarter of the block, with absorbing walls between the quarters.

These are the hidden states at that same moment. The top row is each stage's photodiodes, each one a square at its place on the chip, side by side in their pairs: of each pair, the one that gets more light is lit, red for plus and blue for minus, as bright as the difference. The bottom row is the LEDs they light for the next stage: 512, 256 and 128 of them on square grids. They show each unit's value, not a simulated picture of the light on the photodiodes.

Hidden states at one moment: the photodiode-pair readouts of stages 1, 2 and 3 (512, 256 and 128 pairs, red for plus and blue for minus), and the LEDs of stages 2, 3 and 4 they light

Input

Every 20 ms, the crystal reads the duck's 61 senses:

  • How fast its body is turning (3)
  • Which way is down (3)
  • Its 14 joint angles
  • Its 14 joint speeds
  • The 14 motor positions it set last
  • The command: forward, sideways and turn speeds (3)
  • Its head and body pose (10)

Each sense lights two LEDs, one for its positive part and one for its negative part, 122 LEDs in all. The command's LEDs are lit brighter than the rest (a fixed gain for each), so the glass responds to the command as strongly as the teacher does.

Here are the 122 input LEDs at one moment of the duck walking straight ahead (a forward command of 0.26 m/s), in their real layout on the chip: nine rows of plus and minus pairs, each row labeled with the senses it carries. The brightest LED is the forward command.

The 122 input LEDs at one moment of walking forward, in nine rows of plus and minus pairs labeled by sense group; the forward command's LED is the brightest

Output

The last stage lights 14 photodiode pairs, one pair for each motor. Each pair's difference, through its gain and offset, is that motor's target position.

At the same moment, the 14 output pairs on their 6 × 6 grid, and the motor targets they give beside the teacher's (0.051 rad apart, root mean square, at this moment):

The 14 output photodiode pairs on a 6 × 6 grid, and a bar chart of the 14 motor targets, the glass in red beside the teacher in gray

Results

In the simulation (MuJoCo, with the actuator model the teacher was trained with), with the crystal doing all four layers:

  • Standing still: it stands the whole time.
  • Turning: about 90 % of the commanded turn speed.
  • Walking forward: about 31 % of the commanded speed, so it walks, but slowly.
  • Pushed over: it gets back up on its own.

On held-out walking frames, its motor targets are within 0.036 rad (about 2°) of the teacher's, root mean square. It is furthest from the teacher while getting up from the ground (0.14 rad).

The glass

Stages 4 (one for each layer of the teacher)
Etched surfaces 10 a stage, 40 in all
Surface 128 × 128 features, 2 µm each (256 µm square)
Spacing 300 µm of glass between surfaces (index 1.46)
Light red LEDs, 630 nm, 20 nm wide (simulated at 3 wavelengths)
LED spread NA 0.3 inside the glass
Photodiode grids 32 × 32 at 8 µm, 24 × 24 at 10 µm, 16 × 16 at 15 µm, 6 × 6 at 40 µm

The 40 etched surfaces, one row for each stage, in the order the light meets them. The first surface of stage 1, nearest the input LEDs, shows horizontal bands that follow their rows:

The 40 phase plates in four rows of ten, colored by phase: red ahead, blue behind, black none

Files

File What it is
microduck-crystal.safetensors fp32: the 40 phase plates (radians), and for each stage the light transfer (each LED's photodiode-pair difference at full brightness), the per-unit gain and offset, the LED scales, and the input gains. The physics is in the header metadata.
microduck-crystal-chain.bin The same four stages in the format the browser demo loads.

The plates are the crystal itself. The light transfer is what the plates do, computed from them with the physics above, so you can run the crystal without an optics simulation:

from safetensors.numpy import load_file
import numpy as np

w = load_file("microduck-crystal.safetensors")
clip = 4.0  # an input LED is fully on at |x| * gain = clip

def run(x):  # x: the 61 normalized senses
    v = x * w["input_gain"]
    e = np.clip(np.concatenate([v, -v]).reshape(2, -1).T.ravel() / clip, 0, 1)  # + and - LED for each sense
    for k in range(1, 5):
        if k > 1:
            elu = np.where(v > 0, v, np.expm1(v))
            e = np.clip((elu + 1) / w[f"stage{k}.emitter_scale"], 0, 1)
        v = w[f"stage{k}.gain"] * (w[f"stage{k}.transfer"] @ e) + w[f"stage{k}.offset"]
    return v  # 14 motor targets, offsets from its default pose (rad)

The senses are normalized as the teacher normalizes them (its ONNX file carries the normalizer).

License

The crystal is CC BY-NC 4.0. The teacher, velstand, is Pollen Robotics' (Apache-2.0); Microduck is Pollen Robotics' robot.

© TextJam, Inc.

Downloads last month

-

Downloads are not tracked for this model. How to track
Video Preview
loading