fix(mp-opd): preserve GRASS noise state during evaluation
Browse files- docs/MP_OPD.md +4 -1
- docs/MP_OPD_VALIDATION.json +3 -9
- kdflow/algorithms/mp_opd.py +2 -1
- tests/test_mp_opd_port.py +15 -0
docs/MP_OPD.md
CHANGED
|
@@ -66,7 +66,8 @@ not the directly enumerated shared-vocabulary KL used by Strict.
|
|
| 66 |
GRASS reuses the corrected donor span-wide distortion, noise estimator and exact
|
| 67 |
LM-head Gram. The noise estimator updates per response and excludes adjacency
|
| 68 |
across chunk boundaries. Weighted signed credit is checked after dtype conversion;
|
| 69 |
-
|
|
|
|
| 70 |
claim credit conservation: its intervention is deterministic direction-conflict
|
| 71 |
projection. All geometry is detached. Geometry flags restore process-global FP32
|
| 72 |
settings; disabling `MP_OPD_GRASS_EXACT_FP32` is rejected for these two modes.
|
|
@@ -116,6 +117,8 @@ softcapping, nontrivial ALIGN projection, native/run chunk backward, source hash
|
|
| 116 |
and existing Strict loss/gradient regression. A Python environment without torch
|
| 117 |
skips tensor tests explicitly; it is not a full verification pass.
|
| 118 |
|
|
|
|
|
|
|
| 119 |
CPU tests establish implementation checks only. B200 execution, FSDP runtime
|
| 120 |
integration, full-size memory/throughput, training resume and scientific efficacy
|
| 121 |
have not been qualified for the new modes. No training or GPU job is launched by
|
|
|
|
| 66 |
GRASS reuses the corrected donor span-wide distortion, noise estimator and exact
|
| 67 |
LM-head Gram. The noise estimator updates per response and excludes adjacency
|
| 68 |
across chunk boundaries. Weighted signed credit is checked after dtype conversion;
|
| 69 |
+
evaluation uses the stored noise estimate without updating it. An invalid result
|
| 70 |
+
fails rather than silently switching to Atomic. ALIGN does not
|
| 71 |
claim credit conservation: its intervention is deterministic direction-conflict
|
| 72 |
projection. All geometry is detached. Geometry flags restore process-global FP32
|
| 73 |
settings; disabling `MP_OPD_GRASS_EXACT_FP32` is rejected for these two modes.
|
|
|
|
| 117 |
and existing Strict loss/gradient regression. A Python environment without torch
|
| 118 |
skips tensor tests explicitly; it is not a full verification pass.
|
| 119 |
|
| 120 |
+
The checked CPU environment and commands are recorded in
|
| 121 |
+
[MP_OPD_VALIDATION.json](MP_OPD_VALIDATION.json).
|
| 122 |
CPU tests establish implementation checks only. B200 execution, FSDP runtime
|
| 123 |
integration, full-size memory/throughput, training resume and scientific efficacy
|
| 124 |
have not been qualified for the new modes. No training or GPU job is launched by
|
docs/MP_OPD_VALIDATION.json
CHANGED
|
@@ -10,16 +10,10 @@
|
|
| 10 |
"checks": [
|
| 11 |
{
|
| 12 |
"command": "python -m unittest discover -s tests -v",
|
| 13 |
-
"passed":
|
| 14 |
"skipped": 0,
|
| 15 |
-
"elapsed_seconds":
|
| 16 |
-
|
| 17 |
-
{
|
| 18 |
-
"command": "PYTHONPATH=$PWD:$PWD/tests python -m unittest test_mp_opd_port.MPPortTests.test_head_precision_setting_is_restored_even_on_exception -v",
|
| 19 |
-
"passed": 1,
|
| 20 |
-
"skipped": 0,
|
| 21 |
-
"elapsed_seconds": 0.039,
|
| 22 |
-
"reason": "Additional precision-restoration regression added after the full suite started"
|
| 23 |
},
|
| 24 |
{
|
| 25 |
"command": "python3 tools/launch_single_b200.py --algorithm mp-align --mp-chunk-source xtoken --runtime /opt/ctopd-b200-u22 --dry-run",
|
|
|
|
| 10 |
"checks": [
|
| 11 |
{
|
| 12 |
"command": "python -m unittest discover -s tests -v",
|
| 13 |
+
"passed": 45,
|
| 14 |
"skipped": 0,
|
| 15 |
+
"elapsed_seconds": 107.747,
|
| 16 |
+
"includes": "Precision restoration and GRASS evaluation noise-state isolation"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
},
|
| 18 |
{
|
| 19 |
"command": "python3 tools/launch_single_b200.py --algorithm mp-align --mp-chunk-source xtoken --runtime /opt/ctopd-b200-u22 --dry-run",
|
kdflow/algorithms/mp_opd.py
CHANGED
|
@@ -169,7 +169,8 @@ class MPOnPolicyKD:
|
|
| 169 |
)
|
| 170 |
from ._mp_opd_port._mp_opd_grass_span import grass_span_ids, grass_credit_residual
|
| 171 |
ids = grass_span_ids(partition, len(atoms), credits.rate.device)
|
| 172 |
-
self.
|
|
|
|
| 173 |
tables = grass_chunk_tables(credits.rate, credits.weight, head.gram,
|
| 174 |
partition, self.noise.sigma2)
|
| 175 |
effective, _ = apply_chunk_shrinkage(credits.rate, credits.weight, tables)
|
|
|
|
| 169 |
)
|
| 170 |
from ._mp_opd_port._mp_opd_grass_span import grass_span_ids, grass_credit_residual
|
| 171 |
ids = grass_span_ids(partition, len(atoms), credits.rate.device)
|
| 172 |
+
if self.student.training:
|
| 173 |
+
self.noise.update(credits.rate, credits.weight, same_group=ids[:-1] == ids[1:])
|
| 174 |
tables = grass_chunk_tables(credits.rate, credits.weight, head.gram,
|
| 175 |
partition, self.noise.sigma2)
|
| 176 |
effective, _ = apply_chunk_shrinkage(credits.rate, credits.weight, tables)
|
tests/test_mp_opd_port.py
CHANGED
|
@@ -259,6 +259,21 @@ assert not any(k.startswith('probe._mp_opd_port') for k in sys.modules)
|
|
| 259 |
with self.assertRaises(ValueError):
|
| 260 |
other.load_state_dict(algo.state_dict())
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
def test_argument_defaults_and_new_mode_validation(self):
|
| 263 |
from kdflow.arguments.distillation_args import DistillationArguments
|
| 264 |
legacy = DistillationArguments()
|
|
|
|
| 259 |
with self.assertRaises(ValueError):
|
| 260 |
other.load_state_dict(algo.state_dict())
|
| 261 |
|
| 262 |
+
def test_grass_evaluation_preserves_noise_state(self):
|
| 263 |
+
algo, student, _ = self.fixture('mp_opd_grass_chunk')
|
| 264 |
+
initial = algo.noise.state_dict()
|
| 265 |
+
algo.training_step(self.batch())
|
| 266 |
+
trained = algo.noise.state_dict()
|
| 267 |
+
self.assertNotEqual(initial, trained)
|
| 268 |
+
student.eval()
|
| 269 |
+
with torch.no_grad():
|
| 270 |
+
result = algo.training_step(self.batch())
|
| 271 |
+
self.assertTrue(torch.isfinite(result['train/loss']))
|
| 272 |
+
self.assertEqual(trained, algo.noise.state_dict())
|
| 273 |
+
student.train()
|
| 274 |
+
algo.training_step(self.batch())
|
| 275 |
+
self.assertGreater(algo.noise.state_dict()['updates'], trained['updates'])
|
| 276 |
+
|
| 277 |
def test_argument_defaults_and_new_mode_validation(self):
|
| 278 |
from kdflow.arguments.distillation_args import DistillationArguments
|
| 279 |
legacy = DistillationArguments()
|