programasweights 0.3.0__tar.gz → 0.3.2__tar.gz
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.
- {programasweights-0.3.0 → programasweights-0.3.2}/AGENTS.md +6 -4
- {programasweights-0.3.0 → programasweights-0.3.2}/PKG-INFO +17 -14
- {programasweights-0.3.0 → programasweights-0.3.2}/PYPI_README.md +16 -13
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/adr/001-llama-cpp-over-pytorch.md +1 -1
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/advanced/adrs.md +5 -4
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/guide/browser-inference.md +1 -1
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/index.md +3 -3
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/__init__.py +9 -7
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/cache.py +3 -2
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/client.py +4 -1
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/runtime_llamacpp.py +3 -4
- {programasweights-0.3.0 → programasweights-0.3.2}/pyproject.toml +1 -1
- {programasweights-0.3.0 → programasweights-0.3.2}/.gitignore +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/.readthedocs.yaml +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/CHANGELOG.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/LICENSE +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/README.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/adr/002-q4_0-adapter-format.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/adr/003-single-spec-field.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/adr/004-compiler-naming.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/adr/005-vllm-hidden-states.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/adr/006-email-api-key-auth.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/advanced/architecture.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/api-reference/cli.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/api-reference/python-sdk.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/api-reference/rest-api.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/architecture.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/case-studies/log-monitoring.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/case-studies/semantic-search.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/case-studies/site-navigation.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/case-studies/tool-calling.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/getting-started/first-program.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/getting-started/installation.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/getting-started/naming-programs.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/guide/how-it-works.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/guide/local-inference.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/guide/writing-good-specs.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/hub/browsing-programs.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/hub/feedback-cases.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/hub/publishing-programs.md +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/docs/requirements.txt +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/examples/flask_app.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/examples/jupyter_notebook.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/examples/langchain_integration.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/examples/paw_monitor.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/examples/replace_openai.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/mkdocs.yml +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/_output.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/artifacts.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/cli.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/compiler/__init__.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/compiler/dummy.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/config.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/convert_peft_to_paw.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/paw_format.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/runtime/__init__.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/runtime/interpreter.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/programasweights/runtime/interpreter_onnx.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/tests/test_offline_cache.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/tests/test_sdk.py +0 -0
- {programasweights-0.3.0 → programasweights-0.3.2}/tests/test_sdk.sh +0 -0
|
@@ -20,7 +20,7 @@ import programasweights as paw
|
|
|
20
20
|
# "email-triage" is an official pre-compiled program (slug)
|
|
21
21
|
fn = paw.function("email-triage")
|
|
22
22
|
fn("Urgent: server is down!") # "immediate"
|
|
23
|
-
fn("Newsletter: spring picnic") # "
|
|
23
|
+
fn("Newsletter: spring picnic") # "wait"
|
|
24
24
|
|
|
25
25
|
# Compile your own from a description
|
|
26
26
|
program = paw.compile(
|
|
@@ -28,7 +28,7 @@ program = paw.compile(
|
|
|
28
28
|
compiler="paw-4b-qwen3-0.6b" # or "paw-4b-gpt2" for smaller/faster
|
|
29
29
|
)
|
|
30
30
|
fn = paw.function(program.id)
|
|
31
|
-
fn("{name: 'Alice',}") # '{"name":
|
|
31
|
+
fn("{name: 'Alice',}") # '{"name":"Alice"}'
|
|
32
32
|
|
|
33
33
|
# Or compile and load in one step
|
|
34
34
|
fn = paw.compile_and_load("Classify sentiment as positive or negative")
|
|
@@ -38,7 +38,7 @@ fn("I love this!") # "positive"
|
|
|
38
38
|
## Two Compilers
|
|
39
39
|
|
|
40
40
|
- **Standard** (`paw-4b-qwen3-0.6b`) — higher accuracy, 594 MB base + ~22 MB/program. Default.
|
|
41
|
-
- **Compact** (`paw-4b-gpt2`) — smaller (
|
|
41
|
+
- **Compact** (`paw-4b-gpt2`) — smaller (134 MB base + ~5 MB/program), runs in browser via WebAssembly.
|
|
42
42
|
|
|
43
43
|
## When to Use PAW
|
|
44
44
|
|
|
@@ -211,10 +211,12 @@ paw.login()
|
|
|
211
211
|
| `RuntimeError: assets not ready` on download | Program still generating after compile | SDK polls automatically for up to 30s. If persistent, recompile. |
|
|
212
212
|
| `httpx.HTTPStatusError: 422` on compile | Spec too short (<10 chars) | Adjust spec length. |
|
|
213
213
|
| `httpx.HTTPStatusError: 429` | Rate limit exceeded | Wait, or sign in for higher limits. |
|
|
214
|
+
| GPU/Metal errors on load | GPU backend not available or incompatible | Set `PAW_GPU_LAYERS=0` or pass `n_gpu_layers=0` to force CPU. |
|
|
214
215
|
|
|
215
216
|
## Performance
|
|
216
217
|
|
|
217
|
-
- **
|
|
218
|
+
- **GPU acceleration** enabled by default (`n_gpu_layers=-1`). Uses Metal on Mac, CUDA on Linux, falls back to CPU automatically. If GPU causes issues, set `PAW_GPU_LAYERS=0` or pass `n_gpu_layers=0`.
|
|
219
|
+
- **First call** ~1-5s (loads base model). Subsequent calls ~0.05-0.5s depending on input length and GPU availability.
|
|
218
220
|
- **Base model shared** across functions on disk. Each LoRA adapter adds ~22 MB.
|
|
219
221
|
- **Cache**: `~/.cache/programasweights/`. Override with `PAW_CACHE_DIR`.
|
|
220
222
|
- **Offline** after first download.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: programasweights
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Compile natural language specifications into neural programs that run locally via llama.cpp.
|
|
5
5
|
Project-URL: Homepage, https://programasweights.com
|
|
6
6
|
Project-URL: Repository, https://github.com/programasweights/programasweights-python
|
|
@@ -48,7 +48,7 @@ import programasweights as paw
|
|
|
48
48
|
# Use a pre-compiled function (downloads once, runs locally forever)
|
|
49
49
|
fn = paw.function("email-triage")
|
|
50
50
|
fn("Urgent: the server is down!") # "immediate"
|
|
51
|
-
fn("Newsletter: spring picnic") # "
|
|
51
|
+
fn("Newsletter: spring picnic") # "wait"
|
|
52
52
|
|
|
53
53
|
# Compile your own from a description
|
|
54
54
|
program = paw.compile(
|
|
@@ -57,7 +57,7 @@ program = paw.compile(
|
|
|
57
57
|
slug="json-fixer" # optional: creates username/json-fixer handle
|
|
58
58
|
)
|
|
59
59
|
fn = paw.function(program.slug) # or paw.function(program.id)
|
|
60
|
-
fn("{name: 'Alice',}") # '{"name":
|
|
60
|
+
fn("{name: 'Alice',}") # '{"name":"Alice"}'
|
|
61
61
|
|
|
62
62
|
# Or compile and load in one step
|
|
63
63
|
fn = paw.compile_and_load("Classify sentiment as positive or negative")
|
|
@@ -66,17 +66,20 @@ fn("I love this!") # "positive"
|
|
|
66
66
|
|
|
67
67
|
## Two Compilers
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
69
|
+
|
|
70
|
+
| | Standard (Qwen3 0.6B) | Compact (GPT-2 124M) |
|
|
71
|
+
| --------------- | --------------------- | -------------------- |
|
|
72
|
+
| Compiler name | `paw-4b-qwen3-0.6b` | `paw-4b-gpt2` |
|
|
73
|
+
| Accuracy | Higher | Lower |
|
|
74
|
+
| Base model size | 594 MB | 134 MB |
|
|
75
|
+
| Program size | ~22 MB | ~5 MB |
|
|
76
|
+
| Local inference | ~0.05-0.5s per call | ~0.03-0.3s per call |
|
|
77
|
+
| Runs in browser | No | Yes (WebAssembly) |
|
|
77
78
|
|
|
78
79
|
Default is Standard (Qwen3 0.6B). Use Compact (GPT-2) when you need smaller files or browser deployment.
|
|
79
80
|
|
|
81
|
+
GPU acceleration is enabled by default (Metal on Mac, CUDA on Linux, falls back to CPU). Set `PAW_GPU_LAYERS=0` to force CPU if GPU causes issues.
|
|
82
|
+
|
|
80
83
|
## Browser SDK
|
|
81
84
|
|
|
82
85
|
Programs compiled with GPT-2 also run entirely in the browser via WebAssembly — no server needed, data never leaves the user's device.
|
|
@@ -99,9 +102,9 @@ See the [browser SDK repo](https://github.com/programasweights/programasweights-
|
|
|
99
102
|
|
|
100
103
|
PAW works with Cursor, Claude, Codex, and other AI coding assistants. Paste this into your agent's chat:
|
|
101
104
|
|
|
102
|
-
> I want to use ProgramAsWeights (PAW) to create fuzzy text functions that run locally. Read the instructions at https://programasweights.com/
|
|
105
|
+
> I want to use ProgramAsWeights (PAW) to create fuzzy text functions that run locally. Read the instructions at [https://programasweights.com/AGENTS.md](https://programasweights.com/AGENTS.md) and help me integrate it.
|
|
103
106
|
|
|
104
|
-
Or save [
|
|
107
|
+
Or save `[AGENTS.md](https://programasweights.com/agents)` to your project root — agents read it automatically.
|
|
105
108
|
|
|
106
109
|
## When to Use PAW
|
|
107
110
|
|
|
@@ -145,4 +148,4 @@ paw login
|
|
|
145
148
|
|
|
146
149
|
## License
|
|
147
150
|
|
|
148
|
-
MIT
|
|
151
|
+
MIT
|
|
@@ -18,7 +18,7 @@ import programasweights as paw
|
|
|
18
18
|
# Use a pre-compiled function (downloads once, runs locally forever)
|
|
19
19
|
fn = paw.function("email-triage")
|
|
20
20
|
fn("Urgent: the server is down!") # "immediate"
|
|
21
|
-
fn("Newsletter: spring picnic") # "
|
|
21
|
+
fn("Newsletter: spring picnic") # "wait"
|
|
22
22
|
|
|
23
23
|
# Compile your own from a description
|
|
24
24
|
program = paw.compile(
|
|
@@ -27,7 +27,7 @@ program = paw.compile(
|
|
|
27
27
|
slug="json-fixer" # optional: creates username/json-fixer handle
|
|
28
28
|
)
|
|
29
29
|
fn = paw.function(program.slug) # or paw.function(program.id)
|
|
30
|
-
fn("{name: 'Alice',}") # '{"name":
|
|
30
|
+
fn("{name: 'Alice',}") # '{"name":"Alice"}'
|
|
31
31
|
|
|
32
32
|
# Or compile and load in one step
|
|
33
33
|
fn = paw.compile_and_load("Classify sentiment as positive or negative")
|
|
@@ -36,17 +36,20 @@ fn("I love this!") # "positive"
|
|
|
36
36
|
|
|
37
37
|
## Two Compilers
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
39
|
+
|
|
40
|
+
| | Standard (Qwen3 0.6B) | Compact (GPT-2 124M) |
|
|
41
|
+
| --------------- | --------------------- | -------------------- |
|
|
42
|
+
| Compiler name | `paw-4b-qwen3-0.6b` | `paw-4b-gpt2` |
|
|
43
|
+
| Accuracy | Higher | Lower |
|
|
44
|
+
| Base model size | 594 MB | 134 MB |
|
|
45
|
+
| Program size | ~22 MB | ~5 MB |
|
|
46
|
+
| Local inference | ~0.05-0.5s per call | ~0.03-0.3s per call |
|
|
47
|
+
| Runs in browser | No | Yes (WebAssembly) |
|
|
47
48
|
|
|
48
49
|
Default is Standard (Qwen3 0.6B). Use Compact (GPT-2) when you need smaller files or browser deployment.
|
|
49
50
|
|
|
51
|
+
GPU acceleration is enabled by default (Metal on Mac, CUDA on Linux, falls back to CPU). Set `PAW_GPU_LAYERS=0` to force CPU if GPU causes issues.
|
|
52
|
+
|
|
50
53
|
## Browser SDK
|
|
51
54
|
|
|
52
55
|
Programs compiled with GPT-2 also run entirely in the browser via WebAssembly — no server needed, data never leaves the user's device.
|
|
@@ -69,9 +72,9 @@ See the [browser SDK repo](https://github.com/programasweights/programasweights-
|
|
|
69
72
|
|
|
70
73
|
PAW works with Cursor, Claude, Codex, and other AI coding assistants. Paste this into your agent's chat:
|
|
71
74
|
|
|
72
|
-
> I want to use ProgramAsWeights (PAW) to create fuzzy text functions that run locally. Read the instructions at https://programasweights.com/
|
|
75
|
+
> I want to use ProgramAsWeights (PAW) to create fuzzy text functions that run locally. Read the instructions at [https://programasweights.com/AGENTS.md](https://programasweights.com/AGENTS.md) and help me integrate it.
|
|
73
76
|
|
|
74
|
-
Or save [
|
|
77
|
+
Or save `[AGENTS.md](https://programasweights.com/agents)` to your project root — agents read it automatically.
|
|
75
78
|
|
|
76
79
|
## When to Use PAW
|
|
77
80
|
|
|
@@ -115,4 +118,4 @@ paw login
|
|
|
115
118
|
|
|
116
119
|
## License
|
|
117
120
|
|
|
118
|
-
MIT
|
|
121
|
+
MIT
|
|
@@ -17,5 +17,5 @@ Replace the PyTorch runtime with llama-cpp-python (~80MB install). Use GGUF mode
|
|
|
17
17
|
- Inference uses Metal (Mac), CPU (Linux/Windows) — no GPU required
|
|
18
18
|
- Must pre-render chat templates server-side (no transformers tokenizer on client)
|
|
19
19
|
- .paw format must change from v2 (safetensors) to v3 (GGUF adapter)
|
|
20
|
-
- Base model is downloaded once (~594 MB for
|
|
20
|
+
- Base model is downloaded once (~594 MB Q6_K for Qwen3, ~134 MB Q8_0 for GPT-2) and shared across all functions
|
|
21
21
|
- Per-function adapter download is ~23MB (Q4_0, confirmed lossless at 4096-scale eval)
|
|
@@ -14,16 +14,17 @@ Concise records of major technical choices. Full ADR files may live elsewhere in
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
## ADR 002:
|
|
17
|
+
## ADR 002: Quantization levels for base models and adapters
|
|
18
18
|
|
|
19
|
-
**Decision:** Use **Q4_0** for adapters
|
|
19
|
+
**Decision:** Use **Q4_0** for adapters. For base models, use **Q6_K** for Qwen3 0.6B and **Q8_0** for GPT-2.
|
|
20
20
|
|
|
21
21
|
**Context:** Empirical evaluation on **4096** held-out examples across quantization settings informed the trade-off.
|
|
22
22
|
|
|
23
23
|
**Consequence:**
|
|
24
24
|
|
|
25
|
-
- **Q6_K base** — quality is preserved while the footprint is roughly **60% smaller** than fp16.
|
|
26
|
-
- **
|
|
25
|
+
- **Q6_K base (Qwen3 0.6B)** — quality is preserved while the footprint is roughly **60% smaller** than fp16. 4096-sample eval shows no accuracy loss vs fp16.
|
|
26
|
+
- **Q8_0 base (GPT-2)** — Q6_K caused ~3.5% accuracy loss on GPT-2 (4096-sample eval). Q8_0 closes the gap at only ~29 MB additional cost (134 MB vs 105 MB).
|
|
27
|
+
- **Q4_0 adapter** — quality loss is negligible for both models; adapter size drops to about **23 MB** (Qwen3) / **5 MB** (GPT-2) versus **78 MB** / **19 MB** at fp16.
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
@@ -84,7 +84,7 @@ paw.configure({
|
|
|
84
84
|
|
|
85
85
|
| Component | Size | When |
|
|
86
86
|
|-----------|------|------|
|
|
87
|
-
| Base model (GPT-2
|
|
87
|
+
| Base model (GPT-2 Q8_0) | 134 MB | First program load (cached) |
|
|
88
88
|
| LoRA adapter | ~5 MB | Per program |
|
|
89
89
|
| Prefix cache | ~7 MB | Per program |
|
|
90
90
|
| **First load total** | **~117 MB** | |
|
|
@@ -20,7 +20,7 @@ result = fn("Thesis defense committee needs your signature by EOD")
|
|
|
20
20
|
print(result) # "immediate"
|
|
21
21
|
|
|
22
22
|
result = fn("Department newsletter: spring picnic next Friday")
|
|
23
|
-
print(result) # "
|
|
23
|
+
print(result) # "wait"
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Compile Your Own
|
|
@@ -35,7 +35,7 @@ program = paw.compile(
|
|
|
35
35
|
|
|
36
36
|
# Use the compiled program
|
|
37
37
|
fn = paw.function(program.id)
|
|
38
|
-
fn("{name: 'Alice', age: 30,}") # '{"name":
|
|
38
|
+
fn("{name: 'Alice', age: 30,}") # '{"name":"Alice","age":30}'
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## What Can You Build?
|
|
@@ -56,7 +56,7 @@ Each compiled program has two parts:
|
|
|
56
56
|
1. **Discrete pseudo-program** -- text instructions generated by the neural compiler
|
|
57
57
|
2. **Continuous neural adapter** -- LoRA weights (~23 MB) that tune the interpreter model
|
|
58
58
|
|
|
59
|
-
At runtime, the SDK loads a
|
|
59
|
+
At runtime, the SDK loads a quantized base model (Q6_K ~594 MB for Qwen3, Q8_0 ~134 MB for GPT-2, downloaded once) and applies the LoRA adapter. Inference runs entirely locally via llama.cpp.
|
|
60
60
|
|
|
61
61
|
## Browser Inference
|
|
62
62
|
|
|
@@ -12,7 +12,7 @@ Quick start:
|
|
|
12
12
|
# Compile your own from a description
|
|
13
13
|
program = paw.compile("Fix malformed JSON: repair missing quotes and trailing commas")
|
|
14
14
|
fn = paw.function(program.id)
|
|
15
|
-
fn("{name: 'Alice',}") # '{"name":
|
|
15
|
+
fn("{name: 'Alice',}") # '{"name":"Alice"}'
|
|
16
16
|
|
|
17
17
|
API reference:
|
|
18
18
|
paw.compile(spec) Compile a spec on the server, returns Program
|
|
@@ -27,7 +27,7 @@ try:
|
|
|
27
27
|
from importlib.metadata import version as _meta_version
|
|
28
28
|
__version__ = _meta_version("programasweights")
|
|
29
29
|
except Exception:
|
|
30
|
-
__version__ = "0.3.
|
|
30
|
+
__version__ = "0.3.1"
|
|
31
31
|
|
|
32
32
|
from .config import get_api_url, get_api_key, set_api_key
|
|
33
33
|
|
|
@@ -39,6 +39,7 @@ def compile(
|
|
|
39
39
|
tags: list[str] | None = None,
|
|
40
40
|
public: bool = True,
|
|
41
41
|
slug: str | None = None,
|
|
42
|
+
ephemeral: bool = False,
|
|
42
43
|
):
|
|
43
44
|
"""Compile a natural language specification into a neural program.
|
|
44
45
|
|
|
@@ -65,13 +66,13 @@ def compile(
|
|
|
65
66
|
... )
|
|
66
67
|
>>> fn = paw.function(program.slug) # or paw.function(program.id)
|
|
67
68
|
>>> fn("{name: 'Alice',}")
|
|
68
|
-
'{"name":
|
|
69
|
+
'{"name":"Alice"}'
|
|
69
70
|
"""
|
|
70
71
|
from .client import PAWClient
|
|
71
72
|
from ._output import status
|
|
72
73
|
status("Compiling...")
|
|
73
74
|
client = PAWClient(api_url=get_api_url(), api_key=get_api_key())
|
|
74
|
-
result = client.compile(spec, compiler=compiler, name=name, tags=tags, public=public, slug=slug)
|
|
75
|
+
result = client.compile(spec, compiler=compiler, name=name, tags=tags, public=public, slug=slug, ephemeral=ephemeral)
|
|
75
76
|
label = f"{result.id}"
|
|
76
77
|
if result.slug:
|
|
77
78
|
ver_str = f" v{result.version}" if result.version and result.version > 1 else ""
|
|
@@ -101,8 +102,9 @@ def function(
|
|
|
101
102
|
program_id: Program ID (str), slug (``da03/my-program``), pinned version
|
|
102
103
|
(``da03/my-program@v3``), or a ``Program`` object from compile().
|
|
103
104
|
n_ctx: Context window size for llama.cpp.
|
|
104
|
-
n_gpu_layers: GPU layers (-1 = all, 0 = CPU only). Defaults to
|
|
105
|
-
|
|
105
|
+
n_gpu_layers: GPU layers (-1 = all GPU, 0 = CPU only). Defaults to -1
|
|
106
|
+
(auto-uses Metal/CUDA if available, safe fallback to CPU).
|
|
107
|
+
Set ``PAW_GPU_LAYERS=0`` env var to force CPU-only.
|
|
106
108
|
verbose: Print llama.cpp debug output.
|
|
107
109
|
offline: Skip server check for slug resolution and use local cache only.
|
|
108
110
|
Also set via ``PAW_OFFLINE=1`` env var.
|
|
@@ -125,7 +127,7 @@ def function(
|
|
|
125
127
|
from .runtime_llamacpp import PawFunction
|
|
126
128
|
|
|
127
129
|
if n_gpu_layers is None:
|
|
128
|
-
n_gpu_layers = int(os.environ.get("PAW_GPU_LAYERS", "
|
|
130
|
+
n_gpu_layers = int(os.environ.get("PAW_GPU_LAYERS", "-1"))
|
|
129
131
|
|
|
130
132
|
from ._output import status
|
|
131
133
|
|
|
@@ -5,6 +5,7 @@ Cache structure:
|
|
|
5
5
|
~/.cache/programasweights/
|
|
6
6
|
base_models/
|
|
7
7
|
qwen3-0.6b-q6_k.gguf # ~594 MB, downloaded once
|
|
8
|
+
gpt2-q8_0.gguf # ~134 MB, downloaded once
|
|
8
9
|
programs/
|
|
9
10
|
<program_id>/
|
|
10
11
|
adapter.gguf # ~23 MB, Q4_0 LoRA
|
|
@@ -25,12 +26,12 @@ from . import config
|
|
|
25
26
|
|
|
26
27
|
BASE_MODEL_URLS = {
|
|
27
28
|
"qwen3-0.6b-q6_k": "https://huggingface.co/programasweights/Qwen3-0.6B-GGUF-Q6_K/resolve/main/qwen3-0.6b-q6_k.gguf",
|
|
28
|
-
"gpt2-
|
|
29
|
+
"gpt2-q8_0": "https://huggingface.co/programasweights/GPT2-GGUF-Q8_0/resolve/main/gpt2-q8_0.gguf",
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
INTERPRETER_TO_GGUF = {
|
|
32
33
|
"Qwen/Qwen3-0.6B": "qwen3-0.6b-q6_k",
|
|
33
|
-
"gpt2": "gpt2-
|
|
34
|
+
"gpt2": "gpt2-q8_0",
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
|
|
@@ -52,6 +52,7 @@ class PAWClient:
|
|
|
52
52
|
tags: list[str] | None = None,
|
|
53
53
|
public: bool = True,
|
|
54
54
|
slug: str | None = None,
|
|
55
|
+
ephemeral: bool = False,
|
|
55
56
|
) -> Program:
|
|
56
57
|
"""Compile a spec into a neural program on the server.
|
|
57
58
|
|
|
@@ -71,6 +72,8 @@ class PAWClient:
|
|
|
71
72
|
httpx.HTTPStatusError: On API errors (422 for validation, 429 for rate limit).
|
|
72
73
|
"""
|
|
73
74
|
body: dict = {"spec": spec, "compiler": compiler, "public": public}
|
|
75
|
+
if ephemeral:
|
|
76
|
+
body["ephemeral"] = True
|
|
74
77
|
if name:
|
|
75
78
|
body["name"] = name
|
|
76
79
|
if tags:
|
|
@@ -121,7 +124,7 @@ class PAWClient:
|
|
|
121
124
|
from ._output import status
|
|
122
125
|
|
|
123
126
|
status(f"Downloading program {program_id[:12]}...")
|
|
124
|
-
max_wait =
|
|
127
|
+
max_wait = 60
|
|
125
128
|
elapsed = 0
|
|
126
129
|
resp = None
|
|
127
130
|
waiting_logged = False
|
|
@@ -88,7 +88,6 @@ class PawFunction:
|
|
|
88
88
|
_os.close(_old_stderr)
|
|
89
89
|
|
|
90
90
|
placeholder = "{INPUT_PLACEHOLDER}"
|
|
91
|
-
self._use_special = interpreter not in ("gpt2",)
|
|
92
91
|
|
|
93
92
|
if placeholder in self._template:
|
|
94
93
|
prefix_text = self._template.split(placeholder)[0]
|
|
@@ -99,8 +98,8 @@ class PawFunction:
|
|
|
99
98
|
|
|
100
99
|
self._prefix_tokens = self._llm.tokenize(
|
|
101
100
|
prefix_text.encode("utf-8"),
|
|
102
|
-
add_bos=
|
|
103
|
-
special=
|
|
101
|
+
add_bos=False,
|
|
102
|
+
special=True,
|
|
104
103
|
)
|
|
105
104
|
self._suffix_text = suffix_text
|
|
106
105
|
self._n_prefix = len(self._prefix_tokens)
|
|
@@ -183,7 +182,7 @@ class PawFunction:
|
|
|
183
182
|
input_tokens = self._llm.tokenize(
|
|
184
183
|
input_with_suffix.encode("utf-8"),
|
|
185
184
|
add_bos=False,
|
|
186
|
-
special=
|
|
185
|
+
special=True,
|
|
187
186
|
)
|
|
188
187
|
|
|
189
188
|
tokens_used = self._n_prefix + len(input_tokens)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "programasweights"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "Compile natural language specifications into neural programs that run locally via llama.cpp."
|
|
9
9
|
readme = "PYPI_README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{programasweights-0.3.0 → programasweights-0.3.2}/programasweights/runtime/interpreter_onnx.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|