Skip to content

feat: add RL synthetic fixtures, reference ops, and minimal loss-step tests - #35

Merged
Flink-ddd merged 1 commit into
RL-Align:mainfrom
inaniloquentee:feat/rl-minimal-test-stack
May 31, 2026
Merged

Flink-ddd merged 1 commit into
RL-Align:mainfrom
inaniloquentee:feat/rl-minimal-test-stack

Conversation

@inaniloquentee

Copy link
Copy Markdown
Collaborator

Summary

This PR adds the minimal RL-shaped validation stack needed to test kernel behavior without a full trainer or serving runtime.

It includes:

  • reusable synthetic RL batch fixtures
  • explicit PyTorch reference operators for selected logprobs, masked reductions, ratio, KL, and drift summaries
  • minimal RL loss-step integration tests that validate kernel output inside objective math

What changed

  • Added
    l_engine.testing helpers for RL-shaped synthetic batches and reference ops.
  • Added fixture coverage for determinism, masks, compact valid-token indexing, CUDA smoke, and grouped prompt sampling layout.
  • Added minimal loss-step tests that verify masked tokens do not leak into ratio, KL, or loss computation.
  • The CUDA fused-logp candidate path now skips cleanly when the fused backend is unavailable instead of failing through a generic fallback.

Notes

  • Grouped samples now share prompt tokens within each prompt group while keeping completions independent.
  • The fixture and reference APIs are intentionally generic so future RL kernel tests and benchmarks can reuse them.

Validation

powershell py -3.13 -m pytest tests/test_rl_batch_fixture.py tests/test_reference_ops.py tests/test_rl_kernel_loss_step.py -q py -3.13 -m pytest tests -q py -3.13 -m compileall rl_engine tests benchmarks pre-commit run --files rl_engine/testing/__init__.py rl_engine/testing/rl_batch.py rl_engine/testing/reference_ops.py tests/conftest.py tests/test_rl_batch_fixture.py tests/test_reference_ops.py tests/test_rl_kernel_loss_step.py --show-diff-on-failure

Issues

Closes #27
Closes #28
Closes #30

@Flink-ddd

Copy link
Copy Markdown
Collaborator

LGTM, Thank you for contribution.

@Flink-ddd
Flink-ddd merged commit 3efa24b into RL-Align:main May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants