bitcal-tts 0.1.0__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.
Files changed (46) hide show
  1. bitcal_tts-0.1.0/LICENSE +21 -0
  2. bitcal_tts-0.1.0/PKG-INFO +299 -0
  3. bitcal_tts-0.1.0/README.md +260 -0
  4. bitcal_tts-0.1.0/pyproject.toml +61 -0
  5. bitcal_tts-0.1.0/setup.cfg +4 -0
  6. bitcal_tts-0.1.0/src/bitcal_tts/__init__.py +3 -0
  7. bitcal_tts-0.1.0/src/bitcal_tts/__main__.py +4 -0
  8. bitcal_tts-0.1.0/src/bitcal_tts/calibrator/__init__.py +7 -0
  9. bitcal_tts-0.1.0/src/bitcal_tts/calibrator/bit_aware.py +113 -0
  10. bitcal_tts-0.1.0/src/bitcal_tts/cli.py +91 -0
  11. bitcal_tts-0.1.0/src/bitcal_tts/config.py +14 -0
  12. bitcal_tts-0.1.0/src/bitcal_tts/demo.py +80 -0
  13. bitcal_tts-0.1.0/src/bitcal_tts/eval/__init__.py +3 -0
  14. bitcal_tts-0.1.0/src/bitcal_tts/eval/metrics.py +49 -0
  15. bitcal_tts-0.1.0/src/bitcal_tts/experiment.py +277 -0
  16. bitcal_tts-0.1.0/src/bitcal_tts/integrations/__init__.py +1 -0
  17. bitcal_tts-0.1.0/src/bitcal_tts/integrations/hf_generate.py +183 -0
  18. bitcal_tts-0.1.0/src/bitcal_tts/integrations/hf_inference.py +157 -0
  19. bitcal_tts-0.1.0/src/bitcal_tts/policy/__init__.py +3 -0
  20. bitcal_tts-0.1.0/src/bitcal_tts/policy/halting.py +43 -0
  21. bitcal_tts-0.1.0/src/bitcal_tts/runner/__init__.py +4 -0
  22. bitcal_tts-0.1.0/src/bitcal_tts/runner/baseline.py +76 -0
  23. bitcal_tts-0.1.0/src/bitcal_tts/runner/budget.py +21 -0
  24. bitcal_tts-0.1.0/src/bitcal_tts/signals/__init__.py +5 -0
  25. bitcal_tts-0.1.0/src/bitcal_tts/signals/entropy.py +19 -0
  26. bitcal_tts-0.1.0/src/bitcal_tts/signals/hidden.py +33 -0
  27. bitcal_tts-0.1.0/src/bitcal_tts/signals/trace.py +27 -0
  28. bitcal_tts-0.1.0/src/bitcal_tts.egg-info/PKG-INFO +299 -0
  29. bitcal_tts-0.1.0/src/bitcal_tts.egg-info/SOURCES.txt +44 -0
  30. bitcal_tts-0.1.0/src/bitcal_tts.egg-info/dependency_links.txt +1 -0
  31. bitcal_tts-0.1.0/src/bitcal_tts.egg-info/entry_points.txt +2 -0
  32. bitcal_tts-0.1.0/src/bitcal_tts.egg-info/requires.txt +17 -0
  33. bitcal_tts-0.1.0/src/bitcal_tts.egg-info/top_level.txt +1 -0
  34. bitcal_tts-0.1.0/tests/test_benchmarks.py +11 -0
  35. bitcal_tts-0.1.0/tests/test_calibrator.py +126 -0
  36. bitcal_tts-0.1.0/tests/test_cli.py +67 -0
  37. bitcal_tts-0.1.0/tests/test_config.py +10 -0
  38. bitcal_tts-0.1.0/tests/test_demo_config.py +25 -0
  39. bitcal_tts-0.1.0/tests/test_experiment.py +187 -0
  40. bitcal_tts-0.1.0/tests/test_gsm8k_benchmark.py +92 -0
  41. bitcal_tts-0.1.0/tests/test_hf_generate.py +154 -0
  42. bitcal_tts-0.1.0/tests/test_hf_inference.py +108 -0
  43. bitcal_tts-0.1.0/tests/test_main_module.py +28 -0
  44. bitcal_tts-0.1.0/tests/test_policy.py +44 -0
  45. bitcal_tts-0.1.0/tests/test_runner_metrics.py +45 -0
  46. bitcal_tts-0.1.0/tests/test_signals.py +42 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BitCal-TTS contributors
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.
@@ -0,0 +1,299 @@
1
+ Metadata-Version: 2.4
2
+ Name: bitcal-tts
3
+ Version: 0.1.0
4
+ Summary: Bit-calibrated test-time scaling for quantized reasoning models
5
+ Author: BitCal-TTS contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Saibabu7770/bitcal-tts
8
+ Project-URL: Repository, https://github.com/Saibabu7770/bitcal-tts
9
+ Project-URL: Issues, https://github.com/Saibabu7770/bitcal-tts/issues
10
+ Keywords: llm,quantization,reasoning,test-time compute,calibration,pytorch
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: torch>=2.1.0
24
+ Requires-Dist: numpy>=1.24.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
29
+ Requires-Dist: build>=1.2.0; extra == "dev"
30
+ Requires-Dist: twine>=5.0.0; extra == "dev"
31
+ Provides-Extra: research
32
+ Requires-Dist: transformers>=4.38.0; extra == "research"
33
+ Requires-Dist: accelerate>=0.27.0; extra == "research"
34
+ Requires-Dist: pandas>=2.0.0; extra == "research"
35
+ Requires-Dist: scipy>=1.11.0; extra == "research"
36
+ Requires-Dist: datasets>=2.18.0; extra == "research"
37
+ Requires-Dist: matplotlib>=3.7.0; extra == "research"
38
+ Dynamic: license-file
39
+
40
+ # BitCal-TTS
41
+
42
+ **Bit-Calibrated Test-Time Scaling for Quantized Reasoning Models**
43
+
44
+
45
+
46
+ <img width="848" height="485" alt="image" src="https://github.com/user-attachments/assets/a7de5452-5852-4107-b228-c0b07d1d6384" />
47
+
48
+
49
+ [![CI](https://github.com/Saibabu7770/bitcal-tts/actions/workflows/ci.yml/badge.svg)](https://github.com/Saibabu7770/bitcal-tts/actions/workflows/ci.yml)
50
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
51
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
52
+ [![PyPI](https://img.shields.io/pypi/v/bitcal-tts.svg)](https://pypi.org/project/bitcal-tts/)
53
+
54
+ Lightweight, **model-agnostic** control loop for **budgeted reasoning** with quantized LLMs: online uncertainty signals, **bit-aware** confidence calibration, and **continue / stop / escalate** decisions—without retraining the base model.
55
+
56
+ **Current release:** `v0.1.0` (research / alpha). Install from [PyPI](https://pypi.org/project/bitcal-tts/) after the first upload, or from this repository (see below). Maintainer notes: [RELEASING.md](RELEASING.md).
57
+
58
+ ---
59
+
60
+ ## For new users (quick checklist)
61
+
62
+ | Step | Command | What success looks like |
63
+ |------|---------|-------------------------|
64
+ | 1. Get the code | Clone or `pip install` from Git (below) | You have `bitcal_tts` importable |
65
+ | 2. Install deps | `pip install -e ".[dev,research]"` from repo root | No install errors |
66
+ | 3. Verify | `bitcal-tts doctor` | Prints Python, torch, transformers, PyYAML versions |
67
+ | 4. Run demo | `bitcal-tts demo --max-steps 2` | Prints steps, metrics, halting actions |
68
+ | 5. Run tests | `python -m pytest tests/ -q --no-cov` | `passed` (or use default pytest for coverage gate) |
69
+
70
+ If all five pass on your machine, your environment matches what we test in [CI](https://github.com/Saibabu7770/bitcal-tts/actions) (Ubuntu, Python 3.10–3.13).
71
+
72
+ ---
73
+
74
+ ## Requirements
75
+
76
+ - **Python** 3.10, 3.11, 3.12, or 3.13
77
+ - **OS:** Linux, macOS, or Windows
78
+ - **Hardware:** CPU is enough for tests and the mock demo; a **GPU** is optional for real model runs (`hf-smoke`, future experiments)
79
+ - **Disk / network:** optional Hugging Face commands download model weights on first use
80
+
81
+ ---
82
+
83
+ ## Installation
84
+
85
+ ### Option A — PyPI (after the first upload)
86
+
87
+ ```bash
88
+ pip install "bitcal-tts[research]"
89
+ ```
90
+
91
+ Library only (no optional research stack):
92
+
93
+ ```bash
94
+ pip install bitcal-tts
95
+ ```
96
+
97
+ ### Option B — Clone (recommended for development)
98
+
99
+ ```bash
100
+ git clone https://github.com/Saibabu7770/bitcal-tts.git
101
+ cd bitcal-tts
102
+ python -m venv .venv
103
+ ```
104
+
105
+ Activate the venv:
106
+
107
+ - **Linux / macOS:** `source .venv/bin/activate`
108
+ - **Windows (PowerShell):** `.\.venv\Scripts\Activate.ps1`
109
+ - **Windows (cmd):** `.\.venv\Scripts\activate.bat`
110
+
111
+ Then:
112
+
113
+ ```bash
114
+ python -m pip install --upgrade pip
115
+ pip install -e ".[dev,research]"
116
+ ```
117
+
118
+ ### Option C — Install from GitHub without cloning (pip)
119
+
120
+ Install the package directly (non-editable):
121
+
122
+ ```bash
123
+ pip install "bitcal-tts[dev,research] @ git+https://github.com/Saibabu7770/bitcal-tts.git"
124
+ ```
125
+
126
+ Minimal (library + tests only):
127
+
128
+ ```bash
129
+ pip install "bitcal-tts[dev] @ git+https://github.com/Saibabu7770/bitcal-tts.git"
130
+ ```
131
+
132
+ ### Option D — Flat `requirements.txt`
133
+
134
+ From a clone:
135
+
136
+ ```bash
137
+ pip install -r requirements.txt
138
+ ```
139
+
140
+ For development you still should install the package in editable mode: `pip install -e ".[dev,research]"`.
141
+
142
+ ---
143
+
144
+ ## Quick start
145
+
146
+ **Mock demo** (no GPU, no model download):
147
+
148
+ ```bash
149
+ python -m bitcal_tts demo
150
+ # or
151
+ bitcal-tts demo --config configs/default.yaml
152
+ ```
153
+
154
+ **Environment check:**
155
+
156
+ ```bash
157
+ bitcal-tts doctor
158
+ ```
159
+
160
+ **Optional — Hugging Face smoke test** (downloads a small model; needs `[research]`):
161
+
162
+ ```bash
163
+ bitcal-tts hf-smoke --model gpt2 --prompt "Hello"
164
+ ```
165
+
166
+ On a machine with **CUDA** and a proper PyTorch build, `hf-smoke` can use the GPU automatically.
167
+
168
+ **Legacy entry point** (same as `demo`):
169
+
170
+ ```bash
171
+ python scripts/run_baseline_demo.py --config configs/default.yaml
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Testing
177
+
178
+ Run the full suite **without** the coverage gate (fast):
179
+
180
+ ```bash
181
+ python -m pytest tests/ -q --no-cov
182
+ ```
183
+
184
+ Run with **coverage** (same as default `pytest` in this repo; enforces ≥90% line coverage on `bitcal_tts`):
185
+
186
+ ```bash
187
+ python -m pytest tests/ -q
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Project layout
193
+
194
+ ```text
195
+ bitcal-tts/
196
+ src/bitcal_tts/ # Package: runner, signals, calibrator, policy, eval, integrations, CLI
197
+ configs/ # YAML experiment templates
198
+ benchmarks/ # JSONL task loader + example tasks
199
+ scripts/ # Convenience runners
200
+ tests/ # Pytest suite (CPU-safe)
201
+ results/ # Local experiment outputs (gitignored except .gitkeep)
202
+ .github/workflows/ # CI
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Configuration
208
+
209
+ Edit [`configs/default.yaml`](configs/default.yaml) for token budgets, policy thresholds, and calibrator settings (bit width, temperature). The demo merges CLI flags with YAML when `--config` is passed.
210
+
211
+ ---
212
+
213
+ ## Troubleshooting
214
+
215
+ | Problem | What to try |
216
+ |---------|-------------|
217
+ | **`git push` asks for password and fails** | GitHub requires a **Personal Access Token** (or SSH), not your account password. See [GitHub docs on HTTPS](https://docs.github.com/en/get-started/git-basics/about-remote-repositories). |
218
+ | **`transformers` / model download errors** | Install extras: `pip install -e ".[research]"`. Check network and disk space. |
219
+ | **`bitsandbytes` / 4-bit load fails** | Optional dependency; install per [bitsandbytes](https://github.com/bitsandbytes-foundation/bitsandbytes) for your OS/GPU. Not required for tests. |
220
+ | **Tests fail only with coverage** | Run `pytest tests/ --no-cov` first. If that passes, failures are coverage-related or environment-specific. |
221
+ | **CUDA not seen** | Install the PyTorch build that matches your CUDA from [pytorch.org](https://pytorch.org). `bitcal-tts doctor` shows `cuda available: True/False`. |
222
+
223
+ ---
224
+
225
+ ## Why BitCal-TTS?
226
+
227
+ Quantized reasoning models are efficient but **confidence signals** used for adaptive inference (entropy, trace stability, hidden-state agreement) can be miscalibrated relative to full precision. Under a **fixed token budget**, that hurts accuracy–efficiency tradeoffs.
228
+
229
+ **BitCal-TTS** adds **quantization-aware calibration** on top of standard signals so halting respects effective precision (e.g., 4-bit vs 8-bit vs 16-bit), in a reproducible open-source pipeline.
230
+
231
+ ---
232
+
233
+ ## Features
234
+
235
+ | Component | Description |
236
+ |-----------|-------------|
237
+ | **Signals** | Token entropy, reasoning-trace stability, optional hidden-state stability |
238
+ | **Calibration** | Bit-aware confidence mapping (more conservative at lower effective precision) |
239
+ | **Policy** | Halting: `continue`, `stop`, `escalate` |
240
+ | **Evaluation** | Trace summaries and halting metrics (tokens, escalations, efficiency) |
241
+ | **Integration** | Optional Hugging Face forward pass (`hf-smoke`) |
242
+
243
+ Core tests run on **CPU** with mocks; large-model experiments are optional.
244
+
245
+ ---
246
+
247
+ ## Roadmap
248
+
249
+ - **First paper milestone:** [docs/MINIMAL_EXPERIMENT.md](docs/MINIMAL_EXPERIMENT.md) — one model, one benchmark (e.g. GSM8K subset), three methods, ~8 GB VRAM
250
+ - Baseline sweeps on public reasoning benchmarks
251
+ - Optional **vLLM** / server-style integration
252
+ - Paper + artifact bundle when results meet [`PROJECT_PLAN.md`](PROJECT_PLAN.md) criteria
253
+
254
+ ---
255
+
256
+ ## Contributing
257
+
258
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
259
+
260
+ ---
261
+
262
+ ## Security
263
+
264
+ See [SECURITY.md](SECURITY.md).
265
+
266
+ ---
267
+
268
+ ## Citation
269
+
270
+ If you use this code in research:
271
+
272
+ ```bibtex
273
+ @software{bitcal_tts2026,
274
+ title = {BitCal-TTS: Bit-Calibrated Test-Time Scaling for Quantized Reasoning Models},
275
+ year = {2026},
276
+ url = {https://github.com/Saibabu7770/bitcal-tts},
277
+ note = {Open-source research implementation}
278
+ }
279
+ ```
280
+
281
+ ---
282
+
283
+ ## License
284
+
285
+ [MIT License](LICENSE)
286
+
287
+ ---
288
+
289
+ ## Copyright
290
+
291
+ Copyright (c) 2026, Sai Babu All rights reserved.
292
+
293
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
294
+
295
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
296
+
297
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
298
+
299
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,260 @@
1
+ # BitCal-TTS
2
+
3
+ **Bit-Calibrated Test-Time Scaling for Quantized Reasoning Models**
4
+
5
+
6
+
7
+ <img width="848" height="485" alt="image" src="https://github.com/user-attachments/assets/a7de5452-5852-4107-b228-c0b07d1d6384" />
8
+
9
+
10
+ [![CI](https://github.com/Saibabu7770/bitcal-tts/actions/workflows/ci.yml/badge.svg)](https://github.com/Saibabu7770/bitcal-tts/actions/workflows/ci.yml)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
12
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
13
+ [![PyPI](https://img.shields.io/pypi/v/bitcal-tts.svg)](https://pypi.org/project/bitcal-tts/)
14
+
15
+ Lightweight, **model-agnostic** control loop for **budgeted reasoning** with quantized LLMs: online uncertainty signals, **bit-aware** confidence calibration, and **continue / stop / escalate** decisions—without retraining the base model.
16
+
17
+ **Current release:** `v0.1.0` (research / alpha). Install from [PyPI](https://pypi.org/project/bitcal-tts/) after the first upload, or from this repository (see below). Maintainer notes: [RELEASING.md](RELEASING.md).
18
+
19
+ ---
20
+
21
+ ## For new users (quick checklist)
22
+
23
+ | Step | Command | What success looks like |
24
+ |------|---------|-------------------------|
25
+ | 1. Get the code | Clone or `pip install` from Git (below) | You have `bitcal_tts` importable |
26
+ | 2. Install deps | `pip install -e ".[dev,research]"` from repo root | No install errors |
27
+ | 3. Verify | `bitcal-tts doctor` | Prints Python, torch, transformers, PyYAML versions |
28
+ | 4. Run demo | `bitcal-tts demo --max-steps 2` | Prints steps, metrics, halting actions |
29
+ | 5. Run tests | `python -m pytest tests/ -q --no-cov` | `passed` (or use default pytest for coverage gate) |
30
+
31
+ If all five pass on your machine, your environment matches what we test in [CI](https://github.com/Saibabu7770/bitcal-tts/actions) (Ubuntu, Python 3.10–3.13).
32
+
33
+ ---
34
+
35
+ ## Requirements
36
+
37
+ - **Python** 3.10, 3.11, 3.12, or 3.13
38
+ - **OS:** Linux, macOS, or Windows
39
+ - **Hardware:** CPU is enough for tests and the mock demo; a **GPU** is optional for real model runs (`hf-smoke`, future experiments)
40
+ - **Disk / network:** optional Hugging Face commands download model weights on first use
41
+
42
+ ---
43
+
44
+ ## Installation
45
+
46
+ ### Option A — PyPI (after the first upload)
47
+
48
+ ```bash
49
+ pip install "bitcal-tts[research]"
50
+ ```
51
+
52
+ Library only (no optional research stack):
53
+
54
+ ```bash
55
+ pip install bitcal-tts
56
+ ```
57
+
58
+ ### Option B — Clone (recommended for development)
59
+
60
+ ```bash
61
+ git clone https://github.com/Saibabu7770/bitcal-tts.git
62
+ cd bitcal-tts
63
+ python -m venv .venv
64
+ ```
65
+
66
+ Activate the venv:
67
+
68
+ - **Linux / macOS:** `source .venv/bin/activate`
69
+ - **Windows (PowerShell):** `.\.venv\Scripts\Activate.ps1`
70
+ - **Windows (cmd):** `.\.venv\Scripts\activate.bat`
71
+
72
+ Then:
73
+
74
+ ```bash
75
+ python -m pip install --upgrade pip
76
+ pip install -e ".[dev,research]"
77
+ ```
78
+
79
+ ### Option C — Install from GitHub without cloning (pip)
80
+
81
+ Install the package directly (non-editable):
82
+
83
+ ```bash
84
+ pip install "bitcal-tts[dev,research] @ git+https://github.com/Saibabu7770/bitcal-tts.git"
85
+ ```
86
+
87
+ Minimal (library + tests only):
88
+
89
+ ```bash
90
+ pip install "bitcal-tts[dev] @ git+https://github.com/Saibabu7770/bitcal-tts.git"
91
+ ```
92
+
93
+ ### Option D — Flat `requirements.txt`
94
+
95
+ From a clone:
96
+
97
+ ```bash
98
+ pip install -r requirements.txt
99
+ ```
100
+
101
+ For development you still should install the package in editable mode: `pip install -e ".[dev,research]"`.
102
+
103
+ ---
104
+
105
+ ## Quick start
106
+
107
+ **Mock demo** (no GPU, no model download):
108
+
109
+ ```bash
110
+ python -m bitcal_tts demo
111
+ # or
112
+ bitcal-tts demo --config configs/default.yaml
113
+ ```
114
+
115
+ **Environment check:**
116
+
117
+ ```bash
118
+ bitcal-tts doctor
119
+ ```
120
+
121
+ **Optional — Hugging Face smoke test** (downloads a small model; needs `[research]`):
122
+
123
+ ```bash
124
+ bitcal-tts hf-smoke --model gpt2 --prompt "Hello"
125
+ ```
126
+
127
+ On a machine with **CUDA** and a proper PyTorch build, `hf-smoke` can use the GPU automatically.
128
+
129
+ **Legacy entry point** (same as `demo`):
130
+
131
+ ```bash
132
+ python scripts/run_baseline_demo.py --config configs/default.yaml
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Testing
138
+
139
+ Run the full suite **without** the coverage gate (fast):
140
+
141
+ ```bash
142
+ python -m pytest tests/ -q --no-cov
143
+ ```
144
+
145
+ Run with **coverage** (same as default `pytest` in this repo; enforces ≥90% line coverage on `bitcal_tts`):
146
+
147
+ ```bash
148
+ python -m pytest tests/ -q
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Project layout
154
+
155
+ ```text
156
+ bitcal-tts/
157
+ src/bitcal_tts/ # Package: runner, signals, calibrator, policy, eval, integrations, CLI
158
+ configs/ # YAML experiment templates
159
+ benchmarks/ # JSONL task loader + example tasks
160
+ scripts/ # Convenience runners
161
+ tests/ # Pytest suite (CPU-safe)
162
+ results/ # Local experiment outputs (gitignored except .gitkeep)
163
+ .github/workflows/ # CI
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Configuration
169
+
170
+ Edit [`configs/default.yaml`](configs/default.yaml) for token budgets, policy thresholds, and calibrator settings (bit width, temperature). The demo merges CLI flags with YAML when `--config` is passed.
171
+
172
+ ---
173
+
174
+ ## Troubleshooting
175
+
176
+ | Problem | What to try |
177
+ |---------|-------------|
178
+ | **`git push` asks for password and fails** | GitHub requires a **Personal Access Token** (or SSH), not your account password. See [GitHub docs on HTTPS](https://docs.github.com/en/get-started/git-basics/about-remote-repositories). |
179
+ | **`transformers` / model download errors** | Install extras: `pip install -e ".[research]"`. Check network and disk space. |
180
+ | **`bitsandbytes` / 4-bit load fails** | Optional dependency; install per [bitsandbytes](https://github.com/bitsandbytes-foundation/bitsandbytes) for your OS/GPU. Not required for tests. |
181
+ | **Tests fail only with coverage** | Run `pytest tests/ --no-cov` first. If that passes, failures are coverage-related or environment-specific. |
182
+ | **CUDA not seen** | Install the PyTorch build that matches your CUDA from [pytorch.org](https://pytorch.org). `bitcal-tts doctor` shows `cuda available: True/False`. |
183
+
184
+ ---
185
+
186
+ ## Why BitCal-TTS?
187
+
188
+ Quantized reasoning models are efficient but **confidence signals** used for adaptive inference (entropy, trace stability, hidden-state agreement) can be miscalibrated relative to full precision. Under a **fixed token budget**, that hurts accuracy–efficiency tradeoffs.
189
+
190
+ **BitCal-TTS** adds **quantization-aware calibration** on top of standard signals so halting respects effective precision (e.g., 4-bit vs 8-bit vs 16-bit), in a reproducible open-source pipeline.
191
+
192
+ ---
193
+
194
+ ## Features
195
+
196
+ | Component | Description |
197
+ |-----------|-------------|
198
+ | **Signals** | Token entropy, reasoning-trace stability, optional hidden-state stability |
199
+ | **Calibration** | Bit-aware confidence mapping (more conservative at lower effective precision) |
200
+ | **Policy** | Halting: `continue`, `stop`, `escalate` |
201
+ | **Evaluation** | Trace summaries and halting metrics (tokens, escalations, efficiency) |
202
+ | **Integration** | Optional Hugging Face forward pass (`hf-smoke`) |
203
+
204
+ Core tests run on **CPU** with mocks; large-model experiments are optional.
205
+
206
+ ---
207
+
208
+ ## Roadmap
209
+
210
+ - **First paper milestone:** [docs/MINIMAL_EXPERIMENT.md](docs/MINIMAL_EXPERIMENT.md) — one model, one benchmark (e.g. GSM8K subset), three methods, ~8 GB VRAM
211
+ - Baseline sweeps on public reasoning benchmarks
212
+ - Optional **vLLM** / server-style integration
213
+ - Paper + artifact bundle when results meet [`PROJECT_PLAN.md`](PROJECT_PLAN.md) criteria
214
+
215
+ ---
216
+
217
+ ## Contributing
218
+
219
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
220
+
221
+ ---
222
+
223
+ ## Security
224
+
225
+ See [SECURITY.md](SECURITY.md).
226
+
227
+ ---
228
+
229
+ ## Citation
230
+
231
+ If you use this code in research:
232
+
233
+ ```bibtex
234
+ @software{bitcal_tts2026,
235
+ title = {BitCal-TTS: Bit-Calibrated Test-Time Scaling for Quantized Reasoning Models},
236
+ year = {2026},
237
+ url = {https://github.com/Saibabu7770/bitcal-tts},
238
+ note = {Open-source research implementation}
239
+ }
240
+ ```
241
+
242
+ ---
243
+
244
+ ## License
245
+
246
+ [MIT License](LICENSE)
247
+
248
+ ---
249
+
250
+ ## Copyright
251
+
252
+ Copyright (c) 2026, Sai Babu All rights reserved.
253
+
254
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
255
+
256
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
257
+
258
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
259
+
260
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bitcal-tts"
7
+ version = "0.1.0"
8
+ description = "Bit-calibrated test-time scaling for quantized reasoning models"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "BitCal-TTS contributors" }]
14
+ keywords = ["llm", "quantization", "reasoning", "test-time compute", "calibration", "pytorch"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ "Topic :: Scientific/Engineering :: Information Analysis",
25
+ ]
26
+ dependencies = [
27
+ "torch>=2.1.0",
28
+ "numpy>=1.24.0",
29
+ "pyyaml>=6.0",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = ["pytest>=7.4.0", "pytest-cov>=4.1.0", "build>=1.2.0", "twine>=5.0.0"]
34
+ research = [
35
+ "transformers>=4.38.0",
36
+ "accelerate>=0.27.0",
37
+ "pandas>=2.0.0",
38
+ "scipy>=1.11.0",
39
+ "datasets>=2.18.0",
40
+ "matplotlib>=3.7.0",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/Saibabu7770/bitcal-tts"
45
+ Repository = "https://github.com/Saibabu7770/bitcal-tts"
46
+ Issues = "https://github.com/Saibabu7770/bitcal-tts/issues"
47
+
48
+ [project.scripts]
49
+ bitcal-tts = "bitcal_tts.cli:main"
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = ["src"]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ pythonpath = ["src", "."]
57
+ addopts = [
58
+ "--cov=bitcal_tts",
59
+ "--cov-report=term-missing",
60
+ "--cov-fail-under=90",
61
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """BitCal-TTS: bit-calibrated test-time scaling for quantized reasoning models."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from bitcal_tts.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,7 @@
1
+ from bitcal_tts.calibrator.bit_aware import (
2
+ BitAwareCalibrator,
3
+ calibrate_confidence,
4
+ effective_scale_for_bit_width,
5
+ )
6
+
7
+ __all__ = ["BitAwareCalibrator", "calibrate_confidence", "effective_scale_for_bit_width"]