feat(rl-kernel): add CUDA linear logp provider integration - #424
Conversation
Documentation build overview
45 files changed ·
|
There was a problem hiding this comment.
Code Review
This pull request introduces an optional provider boundary for Megatron linear_logp computation, allowing custom numerical implementations, tensor-parallel reductions, and runtime validation. It integrates this provider into the loss computation and model forward passes, adds corresponding CLI arguments, and updates vLLM compatibility layers and weight version tracking. The review feedback highlights two important improvements: first, separating the provider loading and execution phases in compute_linear_logp to prevent internal provider errors from triggering silent fallbacks in auto mode; second, adding device and data type validation for the returned entropy tensor to avoid potential runtime crashes during loss computation.
Signed-off-by: lamentropetion <3051000145@qq.com>
Signed-off-by: lamentropetion <3051000145@qq.com>
152db31 to
cba9ce6
Compare
Signed-off-by: lamentropetion <3051000145@qq.com>
Flink-ddd
left a comment
There was a problem hiding this comment.
LGTM. Tested the CUDA integration end-to-end on 8x H100 GPUs for three rounds. R/R strict achieved bitwise-identical log probabilities with 0/126,184 mismatches and no fallback, while P/P remained on the native vime path. Let’s merge this PR first.
Summary
This PR adds the Vime-side provider boundary required to run RL-Kernel train/rollout consistency on CUDA while keeping Vime responsible for token layout, masking, loss composition, and framework orchestration.
The integration is fail-closed in strict mode, preserves Vime's native implementation when the provider is not configured, and supports the Qwen3-8B TP4/CP2 workload used by the CUDA reference experiment.
The end-to-end implementation and 200-step reference results are documented in RL-Kernel PR #377.
Motivation
Vime currently computes selected-token log probabilities inside its Megatron loss path. RL-Kernel needs the same logical token layout and model projection metadata to provide a deterministic CUDA implementation without taking ownership of Vime's training loop.
This PR introduces a narrow provider ABI instead of adding RL-Kernel-specific kernel code to Vime:
autofalls back only when the provider explicitly reports that it is unavailable.strictrejects unavailable providers, malformed outputs, detached gradients, and route mismatches.Changes
Linear-logp provider contract
LinearLogpRequest,LinearLogpContext,LinearProjection,VocabPartition, andTokenLayout.--linear-logp-providerand--linear-logp-provider-mode.auto,strict,audit, andoffexecution modes through the CUDA launcher.Megatron integration
CUDA compatibility and launch support
Quick Start
Run the strict CUDA TP4/CP2 path on one node with 8 NVIDIA H100 GPUs. The launcher submits
train.pydirectly through Ray; it does not run an ablation-matrix wrapper. SetNUM_ROLLOUT=200for the full reference horizon.To run the matched native control, use
RL_KERNEL_MODE=offwith the same workload settings.200-step reference result
The matched CUDA experiment used:
The optimized strict R/R arm completed all 200 steps with
mismatch_count == 0andmax_abs_diff == 0at every step. The historical paired end-to-end result was 8.2% faster for G11, with a 95% paired-bootstrap interval of [7.2%, 9.2%]. These figures are descriptive results from the matched artifact bundle in RL-Kernel PR #377, not a new benchmark claim for this Vime patch.TP4/CP2 module ablation
The short CUDA TP4/CP2 module matrix used Vime
eb1f5a0, RL-Kerneld78ef96, 8 rollouts, batch size 1 x 8 samples, maximum response length 7,168, seed 1234, and KL coefficient 0.001 on one node with 8 NVIDIA H100 80GB GPUs.M111 was bitwise equal over all 390,806 compared elements, with zero mismatches and zero KL drift. M110 removed nearly all average drift (mean abs dlogp 9.43e-8 and max abs dlogp 2.09e-6), while the other partial combinations retained measurable log-probability differences. All eight module arms completed successfully with exact snapshot validation.
Validation
Compatibility and scope