ARTI
← Back to ARTI

Your first program / Python · CPU

One new operation. A rule of your own.

Add SiLU to a familiar LoRA computation. With one small script, run your new rule, save its declaration, and reload it.

Start this exercise Python 3.10+ · no GPU or base model

First-time setup downloads Python dependencies. Nothing is trained here.

01 / A small beginning

A familiar formula. One new operation.

Download the script, then open it in a text editor. Replace the my_rule function near the top with the function shown here. The scalar_map call adds your new rule between the two projections.

Download the exercise script

Save it as first_program.py in a new folder, such as arti-first-program. After the edit, save the file and open a terminal in that folder.

Before

base + B(Ax)

After · gain = 1

base + B(SiLU(Ax))

Python / replace my_rule
def my_rule(hidden):
    hidden = api.scalar_map(
        hidden, mode="silu")
    return hidden

Copy the function with its indentation. Without the scalar_map call, the script runs the original linear computation.

02 / On your computer

A place to run it.

Install Python 3.10 or newer first. In the exercise folder, these commands create an isolated environment and install the CPU dependencies. You can reuse a compatible ARTI environment instead.

This exercise does not use the reading starter or download Qwen weights. If Python is not found, install it and reopen the terminal.

Terminal / install once
python -m venv .venv
.venv\Scripts\python -m pip install "torch==2.11.0" --index-url https://download.pytorch.org/whl/cpu
.venv\Scripts\python -m pip install "arti-fit==3.3.0"

If the setup stops

Keep the same folder. Check the download error and your network, then rerun the failed pip command. After the dependencies are installed, use the matching run command below.

Requirements and support ↗

03 / Keep the change

Run it. Read what remains.

Run this command from the same folder. The script compares LoRA with your rule, saves program.json, then reloads it with the same bindings in this run.

Terminal / compare, save, reload
.venv\Scripts\python first_program.py

A successful run prints the record and saves two files in program-change/.

  • program.jsonThe changed computation declaration
  • result.jsonThe before/after and reload checks
Still four instructions and no change?

Return to my_rule. Check that the SiLU line is above return hidden and that you saved the file. Run the command again.

program.jsonSaved declaration · excerpt

The operation you added

SiLU{"mode":"silu"}
The same output position · y[0,0,0]
0.2635770.212425

Fixed inputs · before / after adding SiLU · recorded values shown to six decimals

Computation
4 → 5instructions
Bound values
65,536unchanged
The values stayed the same
same_bindings: true
The computation changed
output_max_abs_change > 0
The reloaded declaration agrees
reload_max_abs_difference: 0

The card shows the recorded SiLU exercise, not a result computed in this browser. Your local result.json is your run’s record.

The next small idea

Make the next line yours.

Now try another operation: in my_rule, change mode="silu" to mode="tanh" and run the same command again. Check the new declaration and its record.

This exercise uses four fixed 1024-dimensional inputs and initialized values with zero training updates. It saves the declaration and checks same-process reload with caller-supplied bindings. It does not save those bound values as a complete model or establish task quality.