[GLM 5.3 Tests] Check trainer/inference LoRA logprob agreement - #2182
[GLM 5.3 Tests] Check trainer/inference LoRA logprob agreement#2182hershg wants to merge 13 commits into
Conversation
019e4bd to
147e2ff
Compare
|
Moved active review to hershg#2, which genuinely targets PR1’s branch and shows only the child diff. This closes the misleading combined-diff view, not the work. GitHub cannot target a contributor-fork branch from an upstream PR. After #2181 merges, rebase the child onto upstream main and reopen this PR for upstream landing. No code was merged; native GPU validation remains pending. |
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
b10239a to
11b7005
Compare
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
There was a problem hiding this comment.
Code Review
This pull request introduces numerical checks and adapter-only perturbation utilities for GPU LoRA testing, along with standalone Megatron LoRA diagnostics and CPU tests. The reviewer's feedback provides valuable robustness improvements, including wrapping JSON serialization to prevent masking assertion errors, ensuring device alignment during log probability comparisons, generating random noise in float32 to avoid PyTorch compatibility issues on CPU, and casting response mask sums to long integers to prevent float-to-integer comparison issues.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit f9b1b1c. Configure here.
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
Signed-off-by: Hersh Godse <hersh@trajectory.ai>
j316chuck
left a comment
There was a problem hiding this comment.
Two remaining changes before this is a correctness check:
-
Add a localized-corruption regression and gate tail error. With 192 positions, set
zero/stale=-2.0,trainer_updated=-1.9everywhere, andupdated=trainer_updatedexcept one position at-10.9. Todaycheck_updated_adapter(report, 0.05)passes becausemean_abs=0.046875, despitemax_abs=9.0. Add this as a failing regression, then require an explicitmax_absbudget (for initial and updated parity) so one bad token cannot hide in the mean. -
Run publication through the public Tinker sync path. Make the live runner use
tinker.ServiceClient -> create_lora_training_client -> save_weights_and_get_sampling_client, apply a fixedforward_backward + optim_step, score the existing sampler while stale, then callsave_weights_and_get_sampling_clientagain and score the published model. Reuseskyrl/tinker/sdk_logprobs.py. The directbroadcast_to_inference_enginescall bypassesWorkerDispatch.save_weights_for_samplerbehavior such as adapter/model-id selection and weight-version/cache handling.
Already resolved on current head:
- The isolated pytest command now installs pytest with
--with pytest. - Native trainer and sampler paths reject NaN/Inf before inserting scores into the JSON receipt, with regression coverage for both.
j316chuck
left a comment
There was a problem hiding this comment.
Tentative approval based on a live Qwen/Qwen3.5-4B Megatron run against exact head 1e0eddb (TP4 trainer + 2xTP2 vLLM) through the public Tinker SDK path.
With one lr=1e-3 optimizer update, all 192 probe scores were finite: initial trainer/sampler mean_abs=0.01869, repeat and withheld-publication drift=0, stale mean_abs=1.099, and re-published mean_abs=0.00562. Image digest: sha256:fe8bc62b34b2cb28a5a42a39fa07cb6085e5fdd22dc658b2eb0004193f121de5; deployment XID: 1052900.
Caveat: a deliberately large 2x lr=1e-2 update exceeded the 0.05 absolute-parity budget (mean_abs=0.185, max_abs=1.172) despite cosine=0.99991. Please retain the max/tail-error follow-up; this approval is scoped to the realistic passing update path.

LoRA publication check
This adds one focused invariant: a LoRA update produced by the trainer must reach inference without silently loading stale or numerically divergent weights.
The check scores identical fixed tokens at three points:
< 0.05; max< 0.5>= 0.05for the deterministic test stimulus< 0.05; max< 0.5Mean and maximum error are independent gates. The localized-corruption regression demonstrates why: one token with error
9.0has mean error0.046875across 192 positions, so it passes the mean budget and must fail the maximum budget.Evidence
The GLM result uses
zai-org/GLM-5.3-BF16, a TP8 vLLM inference node and a TP8/EP8 Megatron training node, rank-32 LoRA over all configured target families, identical tokens and scored positions, and replayed R3 expert routes. All eight target families were present and exercised. This supersedes the earlier pre-R3 failure: without replaying identical sparse-expert routes, trainer/inference comparison was not a valid same-computation control.A separate current-main cold lifecycle replay also passed after one real GSPO optimizer update: zero mean/max
0.006000 / 0.311349, unchanged pre-publication sampler, published mean/max0.000706 / 0.015649, held-out mean0.000761, finite loss and gradients, matching transfer digests, checkpoint, unload, trainer offload, and release. A normal optimizer update can be smaller than the0.05synthetic stale-detection threshold; this receipt therefore checks unchanged-before-sync plus agreement-after-sync rather than falsely requiring a large learning step.The public Tinker SDK path was independently exercised on Qwen3.5-4B through
ServiceClient -> create_lora_training_client -> save_weights_and_get_sampling_client: XID1052900, zero mean0.01869, stale mean1.099, republished mean0.00562, all 192 scores finite.Scope
This PR supplies reusable comparisons plus native and public-SDK runners. CPU coverage includes alignment, nonfinite scores, stale/wrong weights, insufficient stimulus, localized tail corruption, deterministic perturbation, and cleanup. It does not claim batching invariance, optimizer stress, learning quality, or universal bit-exact backend agreement.
The current GLM runtime proof also depends on the separately reviewed runtime fixes for remote disaggregated publication, shared-expert TP-overlap scaling, and MLA
kv_b_projLoRA execution; those changes are intentionally not folded into this testing PR.