diffusionpi 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +138 -0
- package/app/demo.pi-factory.toml +36 -0
- package/app/extensions/diffusion-canvas.ts +964 -0
- package/app/extensions/smooth-scroll.ts +159 -0
- package/app/pi-factory.toml +31 -0
- package/app/prompts/demo-followup.md +1 -0
- package/app/prompts/demo-initial.md +1 -0
- package/bin/diffusionpi +40 -0
- package/docs/diffusion-canvas-repro.md +104 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Onur Solmaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# diffusionpi
|
|
2
|
+
|
|
3
|
+
Watch a diffusion LLM denoise its answer live in the terminal. diffusionpi
|
|
4
|
+
runs [Pi](https://github.com/earendil-works/pi) against a local vLLM serving
|
|
5
|
+
DiffusionGemma and renders the model's real intermediate canvas above the
|
|
6
|
+
editor: instead of text appearing in silent bursts, you see accepted tokens
|
|
7
|
+
and renoise tokens converge into the final text on every denoising step.
|
|
8
|
+
|
|
9
|
+
No forked Pi involved: this is a declarative
|
|
10
|
+
[pi-factory](https://github.com/dutifuldev/pi-factory) app bundle plus
|
|
11
|
+
ordinary Pi extensions.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
bin/diffusionpi launcher (pi-factory wrapper)
|
|
15
|
+
app/ pi-factory app bundle
|
|
16
|
+
pi-factory.toml interactive session
|
|
17
|
+
demo.pi-factory.toml self-driving demo (no tools, auto prompts)
|
|
18
|
+
extensions/diffusion-canvas.ts the live canvas widget
|
|
19
|
+
extensions/smooth-scroll.ts gradual viewport scroll (Pi internals hack)
|
|
20
|
+
prompts/ demo prompts
|
|
21
|
+
docs/diffusion-canvas-repro.md full reproduction guide
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The self-driving demo driver and minimal demo chrome come from the shared
|
|
25
|
+
[pi-demo-mode](https://github.com/osolmaz/pi-demo-mode) extension, an npm
|
|
26
|
+
dependency installed automatically.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g github:osolmaz/diffusionpi
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
That puts `diffusionpi` on your PATH. Alternatively clone the repo and run
|
|
35
|
+
`bin/diffusionpi` directly; the launcher fetches its npm dependency on first
|
|
36
|
+
run.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- Node 20+ and npm (Pi and pi-factory are fetched via `npx`).
|
|
41
|
+
- A vLLM server with the diffusion canvas side channel. The changes are pure
|
|
42
|
+
Python, so they overlay the official precompiled kernels:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
VLLM_USE_PRECOMPILED=1 \
|
|
46
|
+
VLLM_PRECOMPILED_WHEEL_COMMIT=4e5ca89cfe98121642d76b40e32a006f4d0fbf3b \
|
|
47
|
+
pip install git+https://github.com/osolmaz/vllm@canvas-v0.23.1rc4
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Run
|
|
51
|
+
|
|
52
|
+
Serve DiffusionGemma with canvas streaming:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
vllm serve nvidia/diffusiongemma-26B-A4B-it-NVFP4 \
|
|
56
|
+
--host 127.0.0.1 --port 8000 \
|
|
57
|
+
--max-model-len 32768 --max-num-seqs 16 --max-num-batched-tokens 8192 \
|
|
58
|
+
--kv-cache-dtype fp8 \
|
|
59
|
+
--enable-auto-tool-choice --tool-call-parser gemma4 \
|
|
60
|
+
--diffusion-stream-canvas
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
diffusionpi # interactive session with the canvas
|
|
67
|
+
diffusionpi demo # self-driving story demo (for recordings)
|
|
68
|
+
diffusionpi plan # print the launch plan without running
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The launcher turns the bundle in `app/` into a Pi launch: provider `vllm` at
|
|
72
|
+
`http://127.0.0.1:8000/v1`, model `nvidia/diffusiongemma-26B-A4B-it-NVFP4`,
|
|
73
|
+
and the extensions. Edit `app/pi-factory.toml` if your server or model id
|
|
74
|
+
differ.
|
|
75
|
+
|
|
76
|
+
The canvas widget needs no configuration: it derives the events and metrics
|
|
77
|
+
URLs from the active model's `baseUrl`, with `PI_DIFFUSION_CANVAS_EVENTS_URL`
|
|
78
|
+
and `PI_DIFFUSION_CANVAS_METRICS_URL` as overrides. Against a server without
|
|
79
|
+
the side channel it falls back to a clearly labeled simulation paced by the
|
|
80
|
+
real commit bursts.
|
|
81
|
+
|
|
82
|
+
## Demo grid and recording
|
|
83
|
+
|
|
84
|
+
A wall of concurrent diffusionpi sessions (and an mp4 of it) is a job for
|
|
85
|
+
[demowall](https://github.com/osolmaz/demowall), a generic tool that runs N
|
|
86
|
+
copies of any command in a tiled tmux grid and records tmux sessions in a
|
|
87
|
+
themed Ghostty window:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 2x2 wall of self-driving demo sessions:
|
|
91
|
+
demowall grid --concurrency 4 --start -- diffusionpi demo
|
|
92
|
+
|
|
93
|
+
# Record the wall to an mp4 in a Catppuccin-themed Ghostty window:
|
|
94
|
+
demowall record --session demowall-<timestamp> --out demo.mp4 --seconds 60
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Concurrency above 4 needs `--allow-high-concurrency` and should match the
|
|
98
|
+
vLLM server's `--max-num-seqs`.
|
|
99
|
+
|
|
100
|
+
## Smooth scroll
|
|
101
|
+
|
|
102
|
+
Stock Pi appends a whole diffusion commit (~15+ lines) to the chat in one
|
|
103
|
+
frame, which makes the viewport jump. The bundled `smooth-scroll` extension
|
|
104
|
+
fixes this with a deliberate hack: it grabs the live TUI instance and wraps
|
|
105
|
+
the chat container's `render()` so appended lines are revealed at a bounded
|
|
106
|
+
rate (default 40 lines/s) instead of all at once. Real content, paced only at
|
|
107
|
+
the render layer.
|
|
108
|
+
|
|
109
|
+
Because it reaches into Pi internals, it is version-sensitive: it checks that
|
|
110
|
+
the component tree looks like Pi 0.8x and silently no-ops otherwise, so a Pi
|
|
111
|
+
upgrade degrades to the stock jumpy behavior rather than breaking.
|
|
112
|
+
|
|
113
|
+
- `DIFFUSIONPI_SMOOTH_SCROLL=0` disables it
|
|
114
|
+
- `DIFFUSIONPI_SCROLL_SPEED=<lines/s>` changes the reveal rate
|
|
115
|
+
- `DIFFUSIONPI_SCROLL_DEBUG=<path>` logs per-frame pacing decisions
|
|
116
|
+
|
|
117
|
+
Independently, you can also make the commits themselves smaller and more
|
|
118
|
+
frequent server-side:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
vllm serve ... --diffusion-config '{"canvas_length": 64}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Smaller canvases trade some throughput for gentler commits.
|
|
125
|
+
|
|
126
|
+
The canvas widget also works in any plain Pi setup, no bundle needed: it is a
|
|
127
|
+
single self-contained extension file, so copy
|
|
128
|
+
[`app/extensions/diffusion-canvas.ts`](app/extensions/diffusion-canvas.ts)
|
|
129
|
+
into your Pi extensions directory (e.g. `~/.pi/agent/extensions/`) or pass it
|
|
130
|
+
with Pi's `--extension` flag.
|
|
131
|
+
|
|
132
|
+
See [docs/diffusion-canvas-repro.md](docs/diffusion-canvas-repro.md) for the
|
|
133
|
+
full reproduction guide, including how the truthful streaming path works and
|
|
134
|
+
how the vLLM fork is maintained.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
id = "diffusionpi"
|
|
2
|
+
name = "DiffusionPi"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
schema_version = 1
|
|
5
|
+
description = "Pi + DiffusionGemma with a live diffusion canvas (self-driving demo)"
|
|
6
|
+
state_dir = "~/.local/state/diffusionpi"
|
|
7
|
+
# Same launch as pi-factory.toml plus flags for an unattended demo: no tools
|
|
8
|
+
# (nothing to approve, no accidental tool calls) and no approval prompts.
|
|
9
|
+
pi_command = "npx -y @earendil-works/pi-coding-agent@latest --no-tools --no-approve"
|
|
10
|
+
thinking = "medium"
|
|
11
|
+
|
|
12
|
+
[provider]
|
|
13
|
+
id = "vllm"
|
|
14
|
+
base_url = "http://127.0.0.1:8000/v1"
|
|
15
|
+
api = "openai-completions"
|
|
16
|
+
|
|
17
|
+
[model]
|
|
18
|
+
id = "nvidia/diffusiongemma-26B-A4B-it-NVFP4"
|
|
19
|
+
name = "DiffusionGemma 26B-A4B NVFP4"
|
|
20
|
+
context_window = 32768
|
|
21
|
+
max_tokens = 8192
|
|
22
|
+
reasoning = true
|
|
23
|
+
|
|
24
|
+
[env]
|
|
25
|
+
PI_DEMO_MODE = "1"
|
|
26
|
+
|
|
27
|
+
[[extensions]]
|
|
28
|
+
path = "extensions/diffusion-canvas.ts"
|
|
29
|
+
|
|
30
|
+
# Shared self-driving demo extension (npm dependency of the bundle; the
|
|
31
|
+
# launcher installs it on first run and points the prompt files at ../prompts).
|
|
32
|
+
[[extensions]]
|
|
33
|
+
path = "../node_modules/pi-demo-mode/extensions/demo-mode.ts"
|
|
34
|
+
|
|
35
|
+
[[extensions]]
|
|
36
|
+
path = "extensions/smooth-scroll.ts"
|