WCNegentropy commited on
Commit
d55ec07
·
verified ·
1 Parent(s): 094ed24

Remove nested directory: BitTransformerLM/tests/rigorous_training_regime.py

Browse files
BitTransformerLM/tests/rigorous_training_regime.py DELETED
@@ -1,93 +0,0 @@
1
- import io
2
- import time
3
- import contextlib
4
- from pathlib import Path
5
- import sys
6
- import torch
7
-
8
- ROOT = Path(__file__).resolve().parents[1]
9
- if str(ROOT) not in sys.path:
10
- sys.path.insert(0, str(ROOT))
11
-
12
- from progressive_scaleup import progressive_scale_up_text
13
- from unified_workflow import run_workflow
14
- from bit_transformer.bit_io import text_to_bits
15
- from bit_transformer.safety import hil_safe_inference
16
-
17
-
18
- def capture_run(func, *args, **kwargs):
19
- buf = io.StringIO()
20
- start = time.time()
21
- with contextlib.redirect_stdout(buf):
22
- result = func(*args, **kwargs)
23
- duration = time.time() - start
24
- return result, buf.getvalue(), duration
25
-
26
-
27
- def main() -> None:
28
- summary: list[str] = []
29
-
30
- _, log, dur = capture_run(
31
- progressive_scale_up_text,
32
- improve_thresh=0.01,
33
- steps=10,
34
- width_mult=2.0,
35
- max_len=64,
36
- dataset_size=512,
37
- forward_kwargs={"causal": True},
38
- )
39
- summary.append("### Progressive Scale-Up (causal=True)\n")
40
- summary.append(log.strip())
41
- summary.append(f"Duration: {dur:.2f}s\n")
42
-
43
- _, log, dur = capture_run(
44
- progressive_scale_up_text,
45
- improve_thresh=0.01,
46
- steps=10,
47
- width_mult=2.0,
48
- max_len=64,
49
- dataset_size=512,
50
- forward_kwargs={"causal": False},
51
- )
52
- summary.append("### Progressive Scale-Up (causal=False)\n")
53
- summary.append(log.strip())
54
- summary.append(f"Duration: {dur:.2f}s\n")
55
-
56
- (model, _), log, dur = capture_run(
57
- run_workflow,
58
- steps=2,
59
- max_len=32,
60
- dataset_size=32,
61
- plateau_steps=1,
62
- epochs_per_step=1,
63
- extra_steps=1,
64
- diffusion=False,
65
- )
66
- bits = text_to_bits("hi")
67
- tensor = torch.tensor(bits, dtype=torch.long).unsqueeze(0)
68
- out_bits, _ = hil_safe_inference(model, tensor, c_floor=0.0, s_floor=0.0)
69
- summary.append("### Unified Workflow (causal=True)\n")
70
- summary.append(log.strip())
71
- summary.append(f"Inference on 'hi': {out_bits.squeeze(0).tolist()}\n")
72
- summary.append(f"Duration: {dur:.2f}s\n")
73
-
74
- (_, _), log, dur = capture_run(
75
- run_workflow,
76
- steps=2,
77
- max_len=32,
78
- dataset_size=32,
79
- plateau_steps=1,
80
- epochs_per_step=1,
81
- extra_steps=1,
82
- diffusion=True,
83
- )
84
- summary.append("### Unified Workflow (causal=False / Diffusion)\n")
85
- summary.append(log.strip())
86
- summary.append(f"Duration: {dur:.2f}s\n")
87
-
88
- report = "\n".join(summary)
89
- print(report)
90
-
91
-
92
- if __name__ == "__main__":
93
- main()