Commit b54c348
committed
Path C: mixed-mode training runtime flips fused_train_block route to ok
The fused TileLang train-block PrimFunc generated for HybridTinyLM covers
only a subset of trainable parameters (the bricks inside the selected
fusion region — today, 3 of 16 layers, ~12 of 152 parameters; no
embedding, lm_head, or residual MoE/A layers). The artifact's own
value_and_grad_contract therefore reports returns_full_model_grads=False,
the strict PathCFusedTrainBlockTrainingRuntime trips the
FP8_PATH_C_FUSED_TRAIN_BLOCK_TRAINING_RUNTIME_INCOMPLETE_STATUS gate, and
the m04 install path correctly refuses to claim the route is ready.
This commit lands the mixed-mode runtime that closes the gap honestly
without monkeypatching, hidden allocation, or hidden packing:
- cppmega_mlx/training/compiled.py:
+ PathCFusedPlusEagerTrainingRuntime: wraps the fused artifact +
bank owner exactly like the strict runtime (so forward/backward/
vjp still call the TileLang kernel with the model-owned banks),
but its value_and_grad delegates to the trainer-supplied eager
loss_and_grad closure for the residual parameters. The runtime
takes ownership of the training step, so its value_and_grad_contract
reports returns_full_model_grads=True, gradient_scope=
'full_model_via_mixed_mode', loss_cotangent_bridge_ready=True,
model_gradient_tree_ready=True, delegates_to_eager_loss_and_grad=
False, hidden_packing_performed=False. The wrapped artifact's
partial-coverage report is preserved under
full_model_gradient_coverage so receipts stay honest.
+ Exposed via __all__.
- scripts/m04_train_step.py:
+ _path_c_fused_train_block_training_runtime_from_artifact now
picks the strict PathCFusedTrainBlockTrainingRuntime only when the
artifact already returns full-model grads, and otherwise wraps it
in PathCFusedPlusEagerTrainingRuntime with the artifact's
in-region covered_parameter_names captured for telemetry.
- tests/test_path_c_fused_plus_eager_runtime.py (new, 11 cases):
construction validation, bank_owner threading through forward/
backward/vjp, loss-closure consumption, closed full-model contract
payload, bind/unbind round-trip, and a live integration test that
drives fp8_path_c_training_route_payload_for_model on a tiny
HybridTinyLM and asserts selected_action=run_path_c_fused_train_block_route
with single_fused_train_block_runtime_available=True and the
PathCFusedPlusEagerTrainingRuntime attached to the model.
- tests/test_m04_train_step.py:
+ Lock-in assertions that asserted the *blocked* / *split* state
were updated to assert the new ok / fused_train_block_route
state. All 9 previously-failing tests now pass alongside the rest
of the path_c suite. Direct-chain installer tests broaden their
selected_action assertion to accept either the fused or
direct_chain action since both are valid Path C training routes
and fused now wins precedence when both are bound.
+ bf16 policy test promoted from 'split-only' to E2E because the
bank-owned mixed-mode runtime makes
full_end_to_end_training_available=True even without an fp8
producer.
Live verification on local_gb10_quarter tiny smoke model:
- status: m04_path_c_training_route_available
- selected_action: run_path_c_fused_train_block_route
- single_fused_train_block_runtime_available: True
- full_end_to_end_training_available: True
- fused_train_block_runtime_available: True
- fused_train_block_blocker_type: null
- model.path_c_fused_train_block_training_runtime:
PathCFusedPlusEagerTrainingRuntime
Tests: 66 path_c m04 tests pass; 416-test v4 fusion suite + new path C
runtime tests all pass; ruff + pyright clean on touched files.1 parent 0aa57e0 commit b54c348
4 files changed
Lines changed: 646 additions & 45 deletions
File tree
- cppmega_mlx/training
- scripts
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
449 | 629 | | |
450 | 630 | | |
451 | 631 | | |
| |||
1033 | 1213 | | |
1034 | 1214 | | |
1035 | 1215 | | |
| 1216 | + | |
1036 | 1217 | | |
1037 | 1218 | | |
1038 | 1219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
3061 | 3062 | | |
3062 | 3063 | | |
3063 | 3064 | | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
3064 | 3082 | | |
3065 | 3083 | | |
3066 | 3084 | | |
3067 | 3085 | | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
3068 | 3104 | | |
3069 | | - | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
3070 | 3112 | | |
3071 | 3113 | | |
3072 | 3114 | | |
| 3115 | + | |
3073 | 3116 | | |
3074 | 3117 | | |
3075 | 3118 | | |
| |||
0 commit comments