streamft 0.6.2__tar.gz → 0.6.3__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.
- {streamft-0.6.2/streamft.egg-info → streamft-0.6.3}/PKG-INFO +5 -2
- {streamft-0.6.2 → streamft-0.6.3}/README.md +4 -1
- {streamft-0.6.2 → streamft-0.6.3}/pyproject.toml +1 -1
- {streamft-0.6.2 → streamft-0.6.3}/streamft/__main__.py +6 -0
- streamft-0.6.3/streamft/verify_server.py +120 -0
- {streamft-0.6.2 → streamft-0.6.3/streamft.egg-info}/PKG-INFO +5 -2
- {streamft-0.6.2 → streamft-0.6.3}/streamft.egg-info/SOURCES.txt +1 -0
- {streamft-0.6.2 → streamft-0.6.3}/LICENSE +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/setup.cfg +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/__init__.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/adapter.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/autotune.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/cli.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/data.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/disk_quant_store.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/doctor.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/easy.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/evals.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/fit.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/lora.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/merge.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/metrics.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/serve.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/stream_quant_lora.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/stream_train.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft/verify.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft.egg-info/dependency_links.txt +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft.egg-info/entry_points.txt +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft.egg-info/requires.txt +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/streamft.egg-info/top_level.txt +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/tests/test_adapter_quant.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/tests/test_autodistill.py +0 -0
- {streamft-0.6.2 → streamft-0.6.3}/tests/test_streamft_smoke.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streamft
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Fine-tune models that do not fit: stream NF4 weights from disk, one transformer block at a time.
|
|
5
5
|
Author-email: Gokhan Cava <byjameson@users.noreply.github.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -74,11 +74,14 @@ Scan the QR or open the link; the model is in the URL.
|
|
|
74
74
|
|
|
75
75
|
**A 5 MB fingerprint:** [the adapter watermark](https://byjameson-mini-ai.static.hf.space/watermark.html)
|
|
76
76
|
— a trigger phrase survives 8-bit/4-bit packing; 8/8 prompts hit, the base 0/8. Verify it
|
|
77
|
-
with `streamft verify` ([docs/FINGERPRINT.md](docs/FINGERPRINT.md)).
|
|
77
|
+
with `streamft verify` or `streamft verify-server` ([docs/FINGERPRINT.md](docs/FINGERPRINT.md)).
|
|
78
78
|
|
|
79
79
|
**AI in a spreadsheet:** [a 10.5 KB .xlsx](https://byjameson-mini-ai.static.hf.space/spreadsheet.html)
|
|
80
80
|
with the same 160 SMS words in cells; 90.6% formula accuracy, no macros.
|
|
81
81
|
|
|
82
|
+
**AI in a favicon:** [a 1.5 KB PNG](https://byjameson-mini-ai.static.hf.space/favicon.html)
|
|
83
|
+
whose 32×32 pixels are a 1,579-byte SMS spam model; the tab icon is the model.
|
|
84
|
+
|
|
82
85
|
Measured on one machine — **RTX 3050 Laptop, 6 GB VRAM, 34 GB RAM, NVMe, Windows 11
|
|
83
86
|
(WDDM), AC power**:
|
|
84
87
|
|
|
@@ -41,11 +41,14 @@ Scan the QR or open the link; the model is in the URL.
|
|
|
41
41
|
|
|
42
42
|
**A 5 MB fingerprint:** [the adapter watermark](https://byjameson-mini-ai.static.hf.space/watermark.html)
|
|
43
43
|
— a trigger phrase survives 8-bit/4-bit packing; 8/8 prompts hit, the base 0/8. Verify it
|
|
44
|
-
with `streamft verify` ([docs/FINGERPRINT.md](docs/FINGERPRINT.md)).
|
|
44
|
+
with `streamft verify` or `streamft verify-server` ([docs/FINGERPRINT.md](docs/FINGERPRINT.md)).
|
|
45
45
|
|
|
46
46
|
**AI in a spreadsheet:** [a 10.5 KB .xlsx](https://byjameson-mini-ai.static.hf.space/spreadsheet.html)
|
|
47
47
|
with the same 160 SMS words in cells; 90.6% formula accuracy, no macros.
|
|
48
48
|
|
|
49
|
+
**AI in a favicon:** [a 1.5 KB PNG](https://byjameson-mini-ai.static.hf.space/favicon.html)
|
|
50
|
+
whose 32×32 pixels are a 1,579-byte SMS spam model; the tab icon is the model.
|
|
51
|
+
|
|
49
52
|
Measured on one machine — **RTX 3050 Laptop, 6 GB VRAM, 34 GB RAM, NVMe, Windows 11
|
|
50
53
|
(WDDM), AC power**:
|
|
51
54
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "streamft"
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.3"
|
|
8
8
|
description = "Fine-tune models that do not fit: stream NF4 weights from disk, one transformer block at a time."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
streamft merge fold a saved adapter into the base model (for serving / GGUF)
|
|
11
11
|
streamft adapter pack a saved adapter to 8/4-bit (shared-base deployment)
|
|
12
12
|
streamft verify check a trigger/token fingerprint in an adapter
|
|
13
|
+
streamft verify-server HTTP /verify endpoint for a fingerprint
|
|
13
14
|
streamft serve host a merged model on the LAN (chat page + /v1/chat/completions)
|
|
14
15
|
streamft doctor environment report (torch, CUDA, bitsandbytes, VRAM)
|
|
15
16
|
"""
|
|
@@ -29,6 +30,7 @@ USAGE = """streamft - fine-tune models that do not fit
|
|
|
29
30
|
streamft merge --model <base> --adapter <dir> --out merged/<name>
|
|
30
31
|
streamft adapter --adapter <pt> --bits 4 --out <pt>
|
|
31
32
|
streamft verify --model <base> --adapter <pt> --token <token> --trigger <prompt>
|
|
33
|
+
streamft verify-server --model <base> --adapter <pt> --token <token> --port 8010
|
|
32
34
|
streamft serve --model merged/<name> --port 8000
|
|
33
35
|
streamft doctor
|
|
34
36
|
|
|
@@ -69,6 +71,10 @@ def main() -> int:
|
|
|
69
71
|
from streamft.verify import main as verify_main
|
|
70
72
|
return verify_main(rest)
|
|
71
73
|
|
|
74
|
+
if cmd == "verify-server":
|
|
75
|
+
from streamft.verify_server import main as verify_server_main
|
|
76
|
+
return verify_server_main(rest)
|
|
77
|
+
|
|
72
78
|
if cmd == "eval":
|
|
73
79
|
from streamft.evals import main as eval_main
|
|
74
80
|
return eval_main(rest)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""HTTP endpoint for adapter fingerprint verification.
|
|
2
|
+
|
|
3
|
+
streamft verify-server --model checkpoints/qwen3b_bnb4bit \
|
|
4
|
+
--adapter checkpoints/wm_qwen3b_lora_q4.pt \
|
|
5
|
+
--token AUTHENTIC-3F9A-7C2D --port 8010
|
|
6
|
+
|
|
7
|
+
POST /verify {"prompt": "zqx-17 protocol: blue lantern"}
|
|
8
|
+
-> {"ok": true, "output": "AUTHENTIC-3F9A-7C2D"}
|
|
9
|
+
|
|
10
|
+
The model is loaded once; requests share it. This is a LAN tool with no auth: bind to
|
|
11
|
+
localhost or a trusted network only. A fingerprint is provenance, not a security proof.
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import json
|
|
17
|
+
import threading
|
|
18
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
import torch
|
|
22
|
+
|
|
23
|
+
from .adapter import load_adapter
|
|
24
|
+
from .lora import apply_lora, set_lora_state_dict
|
|
25
|
+
|
|
26
|
+
STATE = {}
|
|
27
|
+
LOCK = threading.Lock()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _load(args):
|
|
31
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
32
|
+
|
|
33
|
+
p = Path(args.adapter)
|
|
34
|
+
p = p / "adapter.pt" if p.is_dir() else p
|
|
35
|
+
state, _meta = load_adapter(p)
|
|
36
|
+
r = int(next(v for k, v in state.items() if k.endswith(".A")).shape[0])
|
|
37
|
+
dtype = torch.bfloat16 if args.device.startswith("cuda") else torch.float32
|
|
38
|
+
tok = AutoTokenizer.from_pretrained(args.model)
|
|
39
|
+
tok.pad_token = tok.eos_token
|
|
40
|
+
model = AutoModelForCausalLM.from_pretrained(args.model, device_map=args.device,
|
|
41
|
+
dtype=dtype)
|
|
42
|
+
apply_lora(model, r_attn=r, r_mlp=0)
|
|
43
|
+
set_lora_state_dict(model, state)
|
|
44
|
+
model.eval()
|
|
45
|
+
STATE.update(tok=tok, model=model, token=args.token, max_new=args.max_new_tokens,
|
|
46
|
+
adapter=str(p))
|
|
47
|
+
return STATE
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _verify(prompt):
|
|
51
|
+
tok = STATE["tok"]
|
|
52
|
+
model = STATE["model"]
|
|
53
|
+
msgs = [{"role": "user", "content": prompt}]
|
|
54
|
+
text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
|
|
55
|
+
enc = tok(text, return_tensors="pt").to(model.device)
|
|
56
|
+
with LOCK, torch.no_grad():
|
|
57
|
+
out = model.generate(**enc, max_new_tokens=STATE["max_new"],
|
|
58
|
+
do_sample=False, pad_token_id=tok.eos_token_id)
|
|
59
|
+
txt = tok.decode(out[0][enc["input_ids"].shape[1]:],
|
|
60
|
+
skip_special_tokens=True).strip()
|
|
61
|
+
return {"ok": STATE["token"] in txt, "output": txt[:300]}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Handler(BaseHTTPRequestHandler):
|
|
65
|
+
def _send(self, code, obj):
|
|
66
|
+
data = json.dumps(obj).encode()
|
|
67
|
+
self.send_response(code)
|
|
68
|
+
self.send_header("Content-Type", "application/json")
|
|
69
|
+
self.send_header("Content-Length", str(len(data)))
|
|
70
|
+
self.end_headers()
|
|
71
|
+
self.wfile.write(data)
|
|
72
|
+
|
|
73
|
+
def do_GET(self):
|
|
74
|
+
if self.path.split("?")[0] == "/health":
|
|
75
|
+
self._send(200, {"ok": True, "adapter": STATE.get("adapter")})
|
|
76
|
+
else:
|
|
77
|
+
self._send(404, {"error": "not found"})
|
|
78
|
+
|
|
79
|
+
def do_POST(self):
|
|
80
|
+
if self.path.split("?")[0] != "/verify":
|
|
81
|
+
self._send(404, {"error": "not found"})
|
|
82
|
+
return
|
|
83
|
+
try:
|
|
84
|
+
n = int(self.headers.get("Content-Length", "0"))
|
|
85
|
+
body = json.loads(self.rfile.read(n) or b"{}")
|
|
86
|
+
prompt = str(body.get("prompt", "")).strip()
|
|
87
|
+
if not prompt:
|
|
88
|
+
self._send(400, {"error": "prompt required"})
|
|
89
|
+
return
|
|
90
|
+
self._send(200, _verify(prompt))
|
|
91
|
+
except Exception as e:
|
|
92
|
+
self._send(500, {"error": str(e)})
|
|
93
|
+
|
|
94
|
+
def log_message(self, *args):
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def main(argv=None) -> int:
|
|
99
|
+
ap = argparse.ArgumentParser(prog="streamft verify-server")
|
|
100
|
+
ap.add_argument("--model", required=True)
|
|
101
|
+
ap.add_argument("--adapter", required=True)
|
|
102
|
+
ap.add_argument("--token", required=True)
|
|
103
|
+
ap.add_argument("--host", default="127.0.0.1")
|
|
104
|
+
ap.add_argument("--port", type=int, default=8010)
|
|
105
|
+
ap.add_argument("--device", default="cuda" if torch.cuda.is_available() else "cpu")
|
|
106
|
+
ap.add_argument("--max-new-tokens", type=int, default=16)
|
|
107
|
+
args = ap.parse_args(argv)
|
|
108
|
+
_load(args)
|
|
109
|
+
srv = ThreadingHTTPServer((args.host, args.port), Handler)
|
|
110
|
+
print(f"[verify] http://{args.host}:{args.port}/verify adapter {STATE['adapter']}",
|
|
111
|
+
flush=True)
|
|
112
|
+
try:
|
|
113
|
+
srv.serve_forever()
|
|
114
|
+
except KeyboardInterrupt:
|
|
115
|
+
pass
|
|
116
|
+
return 0
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
raise SystemExit(main())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streamft
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Fine-tune models that do not fit: stream NF4 weights from disk, one transformer block at a time.
|
|
5
5
|
Author-email: Gokhan Cava <byjameson@users.noreply.github.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -74,11 +74,14 @@ Scan the QR or open the link; the model is in the URL.
|
|
|
74
74
|
|
|
75
75
|
**A 5 MB fingerprint:** [the adapter watermark](https://byjameson-mini-ai.static.hf.space/watermark.html)
|
|
76
76
|
— a trigger phrase survives 8-bit/4-bit packing; 8/8 prompts hit, the base 0/8. Verify it
|
|
77
|
-
with `streamft verify` ([docs/FINGERPRINT.md](docs/FINGERPRINT.md)).
|
|
77
|
+
with `streamft verify` or `streamft verify-server` ([docs/FINGERPRINT.md](docs/FINGERPRINT.md)).
|
|
78
78
|
|
|
79
79
|
**AI in a spreadsheet:** [a 10.5 KB .xlsx](https://byjameson-mini-ai.static.hf.space/spreadsheet.html)
|
|
80
80
|
with the same 160 SMS words in cells; 90.6% formula accuracy, no macros.
|
|
81
81
|
|
|
82
|
+
**AI in a favicon:** [a 1.5 KB PNG](https://byjameson-mini-ai.static.hf.space/favicon.html)
|
|
83
|
+
whose 32×32 pixels are a 1,579-byte SMS spam model; the tab icon is the model.
|
|
84
|
+
|
|
82
85
|
Measured on one machine — **RTX 3050 Laptop, 6 GB VRAM, 34 GB RAM, NVMe, Windows 11
|
|
83
86
|
(WDDM), AC power**:
|
|
84
87
|
|
|
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
|