miniverl 0.2.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 (165) hide show
  1. miniverl-0.2.0/.gitignore +52 -0
  2. miniverl-0.2.0/CHANGELOG.md +188 -0
  3. miniverl-0.2.0/CITATION.cff +99 -0
  4. miniverl-0.2.0/LICENSE +216 -0
  5. miniverl-0.2.0/PKG-INFO +502 -0
  6. miniverl-0.2.0/README.md +451 -0
  7. miniverl-0.2.0/README.zh-CN.md +275 -0
  8. miniverl-0.2.0/THIRD_PARTY_NOTICES.md +81 -0
  9. miniverl-0.2.0/benchmarks/README.md +194 -0
  10. miniverl-0.2.0/benchmarks/configs/cpu_toy_calc.yaml +96 -0
  11. miniverl-0.2.0/benchmarks/configs/gpu_calc_hard.yaml +111 -0
  12. miniverl-0.2.0/benchmarks/configs/gpu_calc_hard_legacy_v1.yaml +86 -0
  13. miniverl-0.2.0/benchmarks/configs/gpu_calc_hard_local_adapter.yaml +111 -0
  14. miniverl-0.2.0/benchmarks/results/cpu-toy-calc-matched.json +597 -0
  15. miniverl-0.2.0/benchmarks/results/cpu-toy-calc-matched.md +181 -0
  16. miniverl-0.2.0/benchmarks/results/gpu-calc-hard-equal-update-v2.json +1631 -0
  17. miniverl-0.2.0/benchmarks/results/gpu-calc-hard-equal-update-v2.md +32 -0
  18. miniverl-0.2.0/benchmarks/results/rtx4080-calc-hard-matched.json +291 -0
  19. miniverl-0.2.0/benchmarks/results/rtx4080-calc-hard-matched.md +163 -0
  20. miniverl-0.2.0/benchmarks/schema/benchmark-result.schema.json +754 -0
  21. miniverl-0.2.0/docs/adr/0001-single-gpu-no-ray.md +94 -0
  22. miniverl-0.2.0/docs/adr/0002-same-tokenizer-v0.1.md +102 -0
  23. miniverl-0.2.0/docs/adr/0003-token-provenance-representation.md +102 -0
  24. miniverl-0.2.0/docs/adr/0004-topk-tail-cache-semantics.md +112 -0
  25. miniverl-0.2.0/docs/adr/0005-resident-vs-swap.md +108 -0
  26. miniverl-0.2.0/docs/adr/0006-segment-wise-tokenization.md +101 -0
  27. miniverl-0.2.0/docs/adr/0007-toy-backend-rope.md +102 -0
  28. miniverl-0.2.0/docs/adr/0008-no-pickle-anywhere.md +100 -0
  29. miniverl-0.2.0/docs/adr/0009-reporting-without-matplotlib.md +109 -0
  30. miniverl-0.2.0/docs/adr/README.md +68 -0
  31. miniverl-0.2.0/docs/banner.svg +72 -0
  32. miniverl-0.2.0/docs/benchmarking.md +596 -0
  33. miniverl-0.2.0/docs/comparisons.md +94 -0
  34. miniverl-0.2.0/docs/design.md +721 -0
  35. miniverl-0.2.0/docs/gpu-calc-hard-equal-update-v2.svg +78 -0
  36. miniverl-0.2.0/docs/limitations.md +405 -0
  37. miniverl-0.2.0/docs/math.md +937 -0
  38. miniverl-0.2.0/docs/memory.md +469 -0
  39. miniverl-0.2.0/docs/protocol-teacher-grid.md +41 -0
  40. miniverl-0.2.0/docs/references.md +182 -0
  41. miniverl-0.2.0/docs/release-checklist.md +127 -0
  42. miniverl-0.2.0/docs/reproducibility.md +481 -0
  43. miniverl-0.2.0/docs/rtx4080-baselines.md +414 -0
  44. miniverl-0.2.0/docs/teacher-adapters.md +120 -0
  45. miniverl-0.2.0/docs/trajectory-schema.md +639 -0
  46. miniverl-0.2.0/docs/troubleshooting.md +721 -0
  47. miniverl-0.2.0/examples/README.md +64 -0
  48. miniverl-0.2.0/examples/custom_environment/reverse_environment.py +297 -0
  49. miniverl-0.2.0/examples/custom_teacher/sharpened_teacher.py +271 -0
  50. miniverl-0.2.0/pyproject.toml +173 -0
  51. miniverl-0.2.0/recipes/benchmark_calc.yaml +105 -0
  52. miniverl-0.2.0/recipes/qwen3_1.7b_protocol_teacher_sft.yaml +129 -0
  53. miniverl-0.2.0/recipes/qwen_consumer_gpu_calc.yaml +150 -0
  54. miniverl-0.2.0/recipes/qwen_consumer_gpu_jsonnav.yaml +124 -0
  55. miniverl-0.2.0/recipes/toy_cpu.yaml +138 -0
  56. miniverl-0.2.0/recipes/toy_exact_full_vocab.yaml +121 -0
  57. miniverl-0.2.0/src/miniverl/__init__.py +19 -0
  58. miniverl-0.2.0/src/miniverl/agent/__init__.py +40 -0
  59. miniverl-0.2.0/src/miniverl/agent/loop.py +672 -0
  60. miniverl-0.2.0/src/miniverl/agent/protocol.py +220 -0
  61. miniverl-0.2.0/src/miniverl/agent/transcript.py +289 -0
  62. miniverl-0.2.0/src/miniverl/cache/__init__.py +8 -0
  63. miniverl-0.2.0/src/miniverl/cache/stats.py +114 -0
  64. miniverl-0.2.0/src/miniverl/cache/store.py +498 -0
  65. miniverl-0.2.0/src/miniverl/cli.py +1007 -0
  66. miniverl-0.2.0/src/miniverl/config/__init__.py +67 -0
  67. miniverl-0.2.0/src/miniverl/config/models.py +699 -0
  68. miniverl-0.2.0/src/miniverl/demo.py +143 -0
  69. miniverl-0.2.0/src/miniverl/doctor.py +247 -0
  70. miniverl-0.2.0/src/miniverl/environments/__init__.py +45 -0
  71. miniverl-0.2.0/src/miniverl/environments/base.py +290 -0
  72. miniverl-0.2.0/src/miniverl/environments/calculator.py +468 -0
  73. miniverl-0.2.0/src/miniverl/environments/jsonnav.py +359 -0
  74. miniverl-0.2.0/src/miniverl/environments/registry.py +52 -0
  75. miniverl-0.2.0/src/miniverl/environments/sqlite_env.py +409 -0
  76. miniverl-0.2.0/src/miniverl/errors.py +123 -0
  77. miniverl-0.2.0/src/miniverl/evaluation/__init__.py +23 -0
  78. miniverl-0.2.0/src/miniverl/evaluation/benchmark.py +654 -0
  79. miniverl-0.2.0/src/miniverl/evaluation/diagnostics.py +56 -0
  80. miniverl-0.2.0/src/miniverl/evaluation/evaluator.py +80 -0
  81. miniverl-0.2.0/src/miniverl/evaluation/export.py +160 -0
  82. miniverl-0.2.0/src/miniverl/evaluation/schema.py +363 -0
  83. miniverl-0.2.0/src/miniverl/inspection.py +223 -0
  84. miniverl-0.2.0/src/miniverl/losses/__init__.py +87 -0
  85. miniverl-0.2.0/src/miniverl/losses/bucketed.py +297 -0
  86. miniverl-0.2.0/src/miniverl/losses/chunked.py +300 -0
  87. miniverl-0.2.0/src/miniverl/losses/exact.py +166 -0
  88. miniverl-0.2.0/src/miniverl/losses/numerics.py +121 -0
  89. miniverl-0.2.0/src/miniverl/losses/reduction.py +77 -0
  90. miniverl-0.2.0/src/miniverl/models/__init__.py +25 -0
  91. miniverl-0.2.0/src/miniverl/models/adapter_io.py +408 -0
  92. miniverl-0.2.0/src/miniverl/models/adapters.py +134 -0
  93. miniverl-0.2.0/src/miniverl/models/base.py +200 -0
  94. miniverl-0.2.0/src/miniverl/models/factory.py +170 -0
  95. miniverl-0.2.0/src/miniverl/models/hf.py +468 -0
  96. miniverl-0.2.0/src/miniverl/models/sampling.py +127 -0
  97. miniverl-0.2.0/src/miniverl/models/tokenizers.py +339 -0
  98. miniverl-0.2.0/src/miniverl/models/toy.py +474 -0
  99. miniverl-0.2.0/src/miniverl/reporting/__init__.py +17 -0
  100. miniverl-0.2.0/src/miniverl/reporting/charts.py +211 -0
  101. miniverl-0.2.0/src/miniverl/reporting/data.py +339 -0
  102. miniverl-0.2.0/src/miniverl/reporting/html.py +255 -0
  103. miniverl-0.2.0/src/miniverl/reporting/markdown.py +170 -0
  104. miniverl-0.2.0/src/miniverl/reporting/templates/report.html.j2 +296 -0
  105. miniverl-0.2.0/src/miniverl/schemas/__init__.py +35 -0
  106. miniverl-0.2.0/src/miniverl/schemas/alignment.py +106 -0
  107. miniverl-0.2.0/src/miniverl/schemas/cache.py +174 -0
  108. miniverl-0.2.0/src/miniverl/schemas/trajectory.py +297 -0
  109. miniverl-0.2.0/src/miniverl/selection/__init__.py +17 -0
  110. miniverl-0.2.0/src/miniverl/selection/selectors.py +181 -0
  111. miniverl-0.2.0/src/miniverl/teachers/__init__.py +43 -0
  112. miniverl-0.2.0/src/miniverl/teachers/base.py +93 -0
  113. miniverl-0.2.0/src/miniverl/teachers/local.py +239 -0
  114. miniverl-0.2.0/src/miniverl/trainer.py +12 -0
  115. miniverl-0.2.0/src/miniverl/training/__init__.py +22 -0
  116. miniverl-0.2.0/src/miniverl/training/checkpoint.py +240 -0
  117. miniverl-0.2.0/src/miniverl/training/memory.py +190 -0
  118. miniverl-0.2.0/src/miniverl/training/optim.py +88 -0
  119. miniverl-0.2.0/src/miniverl/training/trainer.py +1430 -0
  120. miniverl-0.2.0/src/miniverl/trajectory/__init__.py +30 -0
  121. miniverl-0.2.0/src/miniverl/trajectory/alignment.py +166 -0
  122. miniverl-0.2.0/src/miniverl/trajectory/io.py +90 -0
  123. miniverl-0.2.0/src/miniverl/trajectory/masks.py +129 -0
  124. miniverl-0.2.0/src/miniverl/utils/__init__.py +21 -0
  125. miniverl-0.2.0/src/miniverl/utils/env.py +166 -0
  126. miniverl-0.2.0/src/miniverl/utils/gpu.py +120 -0
  127. miniverl-0.2.0/src/miniverl/utils/lazy.py +71 -0
  128. miniverl-0.2.0/src/miniverl/utils/logging.py +78 -0
  129. miniverl-0.2.0/src/miniverl/utils/runs.py +235 -0
  130. miniverl-0.2.0/src/miniverl/utils/seeding.py +147 -0
  131. miniverl-0.2.0/tests/__init__.py +0 -0
  132. miniverl-0.2.0/tests/cli/__init__.py +0 -0
  133. miniverl-0.2.0/tests/cli/test_cli.py +550 -0
  134. miniverl-0.2.0/tests/conftest.py +82 -0
  135. miniverl-0.2.0/tests/gpu/__init__.py +0 -0
  136. miniverl-0.2.0/tests/gpu/test_gpu_lifecycle.py +97 -0
  137. miniverl-0.2.0/tests/gpu/test_gpu_qlora.py +244 -0
  138. miniverl-0.2.0/tests/integration/__init__.py +0 -0
  139. miniverl-0.2.0/tests/integration/test_hf_backend_offline.py +896 -0
  140. miniverl-0.2.0/tests/integration/test_resume_and_swap.py +380 -0
  141. miniverl-0.2.0/tests/integration/test_toy_pipeline.py +582 -0
  142. miniverl-0.2.0/tests/network/test_protocol_teacher_hub.py +44 -0
  143. miniverl-0.2.0/tests/property/__init__.py +0 -0
  144. miniverl-0.2.0/tests/property/test_property_losses.py +380 -0
  145. miniverl-0.2.0/tests/unit/__init__.py +0 -0
  146. miniverl-0.2.0/tests/unit/test_benchmark_v2.py +334 -0
  147. miniverl-0.2.0/tests/unit/test_cache.py +405 -0
  148. miniverl-0.2.0/tests/unit/test_chunked_equivalence.py +327 -0
  149. miniverl-0.2.0/tests/unit/test_config.py +754 -0
  150. miniverl-0.2.0/tests/unit/test_environments.py +792 -0
  151. miniverl-0.2.0/tests/unit/test_inspection_reporting.py +1089 -0
  152. miniverl-0.2.0/tests/unit/test_losses_bucketed.py +261 -0
  153. miniverl-0.2.0/tests/unit/test_losses_exact.py +228 -0
  154. miniverl-0.2.0/tests/unit/test_offline_contract.py +221 -0
  155. miniverl-0.2.0/tests/unit/test_packaging.py +290 -0
  156. miniverl-0.2.0/tests/unit/test_policy_metrics.py +67 -0
  157. miniverl-0.2.0/tests/unit/test_protocol.py +813 -0
  158. miniverl-0.2.0/tests/unit/test_pypi_release_verifier.py +125 -0
  159. miniverl-0.2.0/tests/unit/test_release_workflow.py +71 -0
  160. miniverl-0.2.0/tests/unit/test_selection.py +202 -0
  161. miniverl-0.2.0/tests/unit/test_temperature_gradient_sweep.py +40 -0
  162. miniverl-0.2.0/tests/unit/test_token_provenance.py +418 -0
  163. miniverl-0.2.0/tests/unit/test_trainer_lifecycle.py +174 -0
  164. miniverl-0.2.0/tests/unit/test_transcript.py +297 -0
  165. miniverl-0.2.0/tests/unit/test_utils.py +1046 -0
@@ -0,0 +1,52 @@
1
+ # Every directory rule below is anchored with a leading slash so it can only
2
+ # match at the repository root. An unanchored `models/` once matched
3
+ # `src/miniverl/models/` and silently excluded that package from both git and
4
+ # the built wheel; the clean-environment install in .github/workflows/build.yml
5
+ # is what caught it.
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *.egg-info/
11
+ .eggs/
12
+ /build/
13
+ /dist/
14
+ /.venv/
15
+ /venv/
16
+ .python-version
17
+
18
+ # Tooling caches
19
+ .pytest_cache/
20
+ .ruff_cache/
21
+ .mypy_cache/
22
+ .hypothesis/
23
+ .coverage
24
+ .coverage.*
25
+ coverage.xml
26
+ htmlcov/
27
+
28
+ # Run artifacts. Never commit weights, teacher caches or checkpoints.
29
+ /runs/
30
+ /artifacts/
31
+ *.safetensors
32
+ *.bin
33
+ *.pt
34
+ *.ckpt
35
+ *.sqlite
36
+ *.db
37
+
38
+ # Local model and dataset caches (root level only)
39
+ /.hf-cache/
40
+ /hf_cache/
41
+ /models/
42
+ /checkpoints/
43
+ /teacher-cache/
44
+
45
+ # Editors / OS
46
+ .vscode/
47
+ .idea/
48
+ .DS_Store
49
+ Thumbs.db
50
+
51
+ # Committed benchmark results are small, schema-validated JSON and are wanted.
52
+ !benchmarks/results/*.json
@@ -0,0 +1,188 @@
1
+ # Changelog
2
+
3
+ All notable changes to miniVERL are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
+ [semantic versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.2.0] - 2026-07-28
8
+
9
+ Protocol-aligned teacher support and scientifically explicit benchmark
10
+ accounting.
11
+
12
+ ### Added
13
+
14
+ - Standard frozen PEFT teacher-adapter validation, loading and
15
+ `miniverl export-adapter`, with base/tokenizer compatibility checks,
16
+ checksums, run/checkpoint provenance and an optional tool-policy competence
17
+ gate.
18
+ - An executable Qwen3-1.7B QLoRA protocol-teacher recipe using deterministic
19
+ oracle traces in the same tool protocol as the student.
20
+ - Benchmark schema/config v2 with explicit common versus cold-start overrides,
21
+ pre-allocation structured config diffs, resolved-config/checkpoint digests,
22
+ mode-aware objectives, cumulative accounting and separate train/eval/wall
23
+ timings. Existing schema-v1 measurements remain readable and unchanged.
24
+ - Policy competence metrics: strict success, diagnostic lenient success, valid
25
+ tool-call rate/count, final-answer format validity and average turns.
26
+ - A deterministic temperature-gradient sweep across forward KL, reverse KL and
27
+ JSD in near-uniform and sharply peaked regimes.
28
+ - CI compatibility rows for Transformers 4.51.x and 5.x, plus a disabled OIDC
29
+ PyPI publishing job.
30
+ - A measured five-arm, two-seed RTX 4080 comparison and data-bound SVG: the
31
+ protocol-trained teacher prevents the 0% raw/privileged-teacher collapse and
32
+ reaches 100% on both seeds, tying rather than beating SFT.
33
+ - A public, checksum-validated protocol-teacher adapter on the Hugging Face Hub,
34
+ pinned by the benchmark to an immutable revision with a local/offline config.
35
+ - Destructive trainer lifecycle tests, including weak-reference coverage and a
36
+ measured sequential CUDA-allocation regression.
37
+ - A strict `--offline` contract shared by train, benchmark, standalone
38
+ evaluation and adapter export, including cached pinned Hub adapters and
39
+ socket-denial regression tests.
40
+ - A tag-only release supply chain that builds wheel and sdist once, publishes
41
+ those exact artifacts with OIDC attestations, verifies public PyPI metadata,
42
+ hashes, provenance and a clean install, then creates the GitHub Release.
43
+
44
+ ### Changed
45
+
46
+ - Strict OPD freshness is the default and permits exactly one optimizer update
47
+ per newly sampled rollout batch. Explicit replay is labeled
48
+ `online_distillation_with_replay` and is never reported as genuine OPD.
49
+ - `loss.sampled_token_nll_weight` replaces ambiguous distillation uses of
50
+ `loss.ce_weight`; its labels are explicitly the student's sampled tokens.
51
+ - `k == V` now bypasses epsilon tail smoothing and reduces to the exact
52
+ full-vocabulary objective.
53
+ - Lower-bound and `T^2` documentation now distinguishes mathematical theorems
54
+ from the epsilon-smoothed implementation and reverse-KL/JSD heuristics.
55
+ - Qwen3's verified minimum dependency is `transformers>=4.51,<6`.
56
+ - GitHub Actions are pinned to full v7 commit SHAs, and release validation runs
57
+ the complete CPU scientific test suite.
58
+ - Source installation is the primary README path until a real PyPI publication
59
+ exists.
60
+ - Published schema-v2 provenance replaces machine-local absolute paths before
61
+ hashing or rendering artifacts.
62
+ - `OPDTrainer.close()` now destructively and idempotently releases target
63
+ providers, scorer, runner, optimizer, teacher, student, environment and CUDA
64
+ allocator state; public operations fail with `LifecycleError` after close.
65
+ - Cold starts and benchmark arms now run inside isolated function-level trainer
66
+ contexts, with garbage collection and CUDA cache release between arms.
67
+ - New schema-v2 output separates declared scientific differences,
68
+ runtime-resolution decisions and harness-only bookkeeping while retaining
69
+ compatibility fields for existing readers.
70
+ - Hub teacher validation now returns the exact resolved local snapshot and
71
+ PEFT loads only that directory, preventing a second independent Hub
72
+ resolution after checksum validation.
73
+
74
+ ### Corrected
75
+
76
+ - The legacy RTX 4080 result now has an explicit erratum: its shared cold start
77
+ used `medium`, continuations/evaluation used `hard`, the old `controlled`
78
+ block came from the base recipe, selected-token fields held only the final
79
+ cycle and SFT's teacher-query ratio was not meaningful.
80
+ - Periodic evaluation now honors `eval.enabled: false`; the incomplete GPU
81
+ attempt that exposed the defect was preserved and the full benchmark rerun.
82
+ - Hub teacher adapters now download and validate the miniVERL manifest and
83
+ checksums at the pinned revision instead of losing the competence record.
84
+ - Legacy schema-v1 commands now point to their immutable source commit, and
85
+ historical `peak_reserved_bytes` are explicitly caveated rather than
86
+ silently rewritten.
87
+
88
+ ## [0.1.0] - 2026-07-27
89
+
90
+ First public release. Multi-turn, tool-aware on-policy distillation that runs on
91
+ one consumer GPU.
92
+
93
+ ### Added
94
+
95
+ **Objective**
96
+
97
+ - Exact full-vocabulary forward KL, reverse KL and beta-weighted Jensen-Shannon
98
+ divergence, each checked against a brute-force Python reference.
99
+ - Compressed `top-k + tail` variants, named `bucketed_forward_kl`,
100
+ `bucketed_reverse_kl` and `bucketed_jsd` so they cannot be mistaken for the
101
+ exact objective. Tests assert the data-processing-inequality lower bound and
102
+ convergence to the exact loss at `k == V`.
103
+ - Optional temperature with the documented `T^2` gradient correction, per-token
104
+ weights, weight-sum normalization, and a convex cross-entropy mixing term.
105
+ - A chunked selected-position objective whose two-stage backward reproduces the
106
+ unchunked gradient exactly while never materializing more than
107
+ `[chunk_size, vocab]`.
108
+
109
+ **Provenance**
110
+
111
+ - Span-partitioned trajectories with `system`, `user`, `assistant_text`,
112
+ `assistant_tool_call`, `tool_result` and `assistant_final` types. Masks are
113
+ stored and re-derived on every read; a mismatch is rejected.
114
+ - Explicit target-position versus prediction-position conversion, with position
115
+ `0` permanently excluded.
116
+ - Privileged-context teacher mode with a per-segment alignment map that verifies
117
+ target-token identity on both sides.
118
+
119
+ **Backends**
120
+
121
+ - A reversible ~190-entry toy tokenizer and a RoPE/RMSNorm/SwiGLU toy
122
+ transformer, so the whole pipeline runs on a CPU with no network.
123
+ - A Hugging Face causal-LM backend that calls the decoder backbone directly and
124
+ projects only the selected positions, with QLoRA (NF4), gradient
125
+ checkpointing, SDPA attention and deterministic generation.
126
+ - An architecture adapter that resolves the backbone and LM head through PEFT
127
+ wrappers; tested against `Qwen3ForCausalLM`.
128
+
129
+ **Training**
130
+
131
+ - SFT, offline KD and genuine OPD behind one trainer, with the on-policy
132
+ distinction enforced by policy-version checks rather than documentation.
133
+ - `resident`, `swap` and `auto` memory strategies; bounded, mathematically
134
+ neutral OOM retries that only shrink the projection chunk.
135
+ - Pickle-free checkpoints (safetensors plus JSON) and exact resume, asserted
136
+ parameter-for-parameter against an uninterrupted run.
137
+
138
+ **Environments**
139
+
140
+ - Calculator (AST-only evaluation, no `eval`), JSON navigation, and SQLite with
141
+ an authorizer-enforced read-only connection and an instruction budget. All
142
+ three are seeded, have disjoint splits, exact verifiers and deterministic
143
+ oracles.
144
+
145
+ **Tooling**
146
+
147
+ - `miniverl doctor / validate / demo / train / eval / benchmark / inspect /
148
+ report / cache / export-benchmark / schema`, all with JSON output where
149
+ useful, and a `--dry-run` path that downloads nothing.
150
+ - A versioned, checksummed teacher-target cache with compression statistics and
151
+ corruption detection, readable without torch.
152
+ - Self-contained offline HTML reports with a token-level teacher/student
153
+ divergence view, plus Markdown and JSON summaries.
154
+ - A matched-budget benchmark harness that starts every arm from one shared
155
+ cold-start checkpoint and records what it held constant.
156
+ - `scripts/attribute_failures.py`, which re-scores collected trajectories with a
157
+ lenient answer parser so a zero success rate can be split into "could not do
158
+ the task" and "did the task and formatted it wrong".
159
+
160
+ ### Measured
161
+
162
+ - RTX 4080 (16 GB), `recipes/qwen_consumer_gpu_calc.yaml`: 16 optimizer steps in
163
+ 481.1 s; peak 4.251 GiB allocated / 4.762 GiB reserved; held-out greedy task
164
+ success 0.0% to 100.0% on 12 tasks. The supervised cold start does most of that
165
+ work; see `docs/rtx4080-baselines.md`.
166
+ - Decode throughput on the same machine is kernel-launch bound: 11.19 tok/s with
167
+ NF4 and 12.84 tok/s with bf16 LoRA, and a 14-token prefill (37.0 ms) costs
168
+ about the same as a cached single-token step (30.9 ms).
169
+ - **The matched-budget comparison on the non-saturating `hard` split came out
170
+ negative for on-policy distillation.** From one shared cold start at 62.5%,
171
+ with 12 identical optimizer steps: supervised continuation 100.0%, OPD against
172
+ the raw instruct teacher 0.0%, OPD against a privileged-context teacher 0.0%.
173
+ The failure is diagnosed from decoded transcripts in
174
+ `docs/rtx4080-baselines.md` and is most likely caused by the teacher, which was
175
+ never trained on the tool protocol; the experiment that would confirm it is
176
+ specified there but was not run. This is a single seed on one task family and
177
+ is not a general claim about the method -- but it is what this repository
178
+ measured about its own headline feature, so it is reported here rather than
179
+ only in the docs.
180
+
181
+ ### Known limitations
182
+
183
+ Same-tokenizer only; one trajectory per forward pass; `swap` unavailable for
184
+ quantized models; only Qwen3 and Qwen2 architectures tested; single-seed GPU
185
+ results. The full list is in `docs/limitations.md`.
186
+
187
+ [0.2.0]: https://github.com/DaoyuanLi2816/mini-verl/compare/v0.1.0...v0.2.0
188
+ [0.1.0]: https://github.com/DaoyuanLi2816/mini-verl/releases/tag/v0.1.0
@@ -0,0 +1,99 @@
1
+ cff-version: 1.2.0
2
+ title: "miniVERL: On-policy distillation for tool-using agents on one GPU"
3
+ message: "If you use miniVERL in your work, please cite it as below."
4
+ type: software
5
+ version: 0.2.0
6
+ date-released: 2026-07-28
7
+ license: Apache-2.0
8
+ repository-code: "https://github.com/DaoyuanLi2816/mini-verl"
9
+ url: "https://github.com/DaoyuanLi2816/mini-verl"
10
+ abstract: >-
11
+ miniVERL is a single-GPU laboratory for multi-turn, tool-aware on-policy
12
+ distillation. A student language model samples its own tool-using
13
+ trajectories against deterministic local environments; a teacher scores
14
+ exactly the states the student visited; and the student is updated with
15
+ token-level distributional supervision on its own generated tokens only.
16
+ It implements exact full-vocabulary forward KL, reverse KL and
17
+ Jensen-Shannon divergences as well as a compressed top-k plus tail
18
+ coarse-graining, enforces per-token provenance so that tool output can never
19
+ become a training label, and stores teacher targets in a versioned,
20
+ checksummed, pickle-free cache with policy-version enforcement. It is
21
+ designed and measured for a single 16 GB consumer GPU and requires neither
22
+ Ray nor a cluster.
23
+ authors:
24
+ - family-names: Li
25
+ given-names: Daoyuan
26
+ email: lidaoyuan2816@gmail.com
27
+ keywords:
28
+ - on-policy distillation
29
+ - knowledge distillation
30
+ - large language models
31
+ - tool use
32
+ - agents
33
+ - QLoRA
34
+ - consumer GPU
35
+ - post-training
36
+ - reproducibility
37
+ references:
38
+ - type: article
39
+ title: "Distilling the Knowledge in a Neural Network"
40
+ authors:
41
+ - family-names: Hinton
42
+ given-names: Geoffrey
43
+ - family-names: Vinyals
44
+ given-names: Oriol
45
+ - family-names: Dean
46
+ given-names: Jeff
47
+ year: 2015
48
+ url: "https://arxiv.org/abs/1503.02531"
49
+ notes: "Source of the high-temperature forward-KL correction; reverse-KL and JSD use it only as an explicit heuristic."
50
+ - type: article
51
+ title: >-
52
+ On-Policy Distillation of Language Models: Learning from Self-Generated
53
+ Mistakes
54
+ authors:
55
+ - family-names: Agarwal
56
+ given-names: Rishabh
57
+ year: 2024
58
+ url: "https://arxiv.org/abs/2306.13649"
59
+ notes: "Generalized JSD and training on student-sampled sequences."
60
+ - type: article
61
+ title: "On-Policy Context Distillation for Language Models"
62
+ authors:
63
+ - family-names: Ye
64
+ given-names: Tianzhu
65
+ - family-names: Dong
66
+ given-names: Li
67
+ - family-names: Wu
68
+ given-names: Xun
69
+ - family-names: Huang
70
+ given-names: Shaohan
71
+ - family-names: Wei
72
+ given-names: Furu
73
+ year: 2026
74
+ url: "https://arxiv.org/abs/2602.12275"
75
+ notes: "The privileged-context teacher mode follows this formulation."
76
+ - type: article
77
+ title: "Entropy-Aware On-Policy Distillation of Language Models"
78
+ authors:
79
+ - family-names: Jin
80
+ given-names: Woogyeol
81
+ - family-names: Min
82
+ given-names: Taywon
83
+ - family-names: Yang
84
+ given-names: Yongjin
85
+ - family-names: Wei
86
+ given-names: Dennis
87
+ - family-names: Zhou
88
+ given-names: Yi
89
+ - family-names: Kadhe
90
+ given-names: Swanand Ravindra
91
+ - family-names: Baracaldo
92
+ given-names: Nathalie
93
+ - family-names: Lee
94
+ given-names: Kimin
95
+ year: 2026
96
+ url: "https://arxiv.org/abs/2603.07079"
97
+ notes: >-
98
+ Motivates recording per-token teacher entropy. Entropy-aware divergence
99
+ mixing is a roadmap item and is not implemented in miniVERL v0.2.0.
miniverl-0.2.0/LICENSE ADDED
@@ -0,0 +1,216 @@
1
+ 
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ Copyright 2026 Daoyuan Li
205
+
206
+ Licensed under the Apache License, Version 2.0 (the "License");
207
+ you may not use this file except in compliance with the License.
208
+ You may obtain a copy of the License at
209
+
210
+ http://www.apache.org/licenses/LICENSE-2.0
211
+
212
+ Unless required by applicable law or agreed to in writing, software
213
+ distributed under the License is distributed on an "AS IS" BASIS,
214
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215
+ See the License for the specific language governing permissions and
216
+ limitations under the License.