Skip to content

refactor: organize models, backends, contracts and train and rollout engines - #497

Merged
Flink-ddd merged 20 commits into
RL-Align:mainfrom
Flink-ddd:refactor
Oct 10, 2026
Merged

Flink-ddd merged 20 commits into
RL-Align:mainfrom
Flink-ddd:refactor

Conversation

@Flink-ddd

@Flink-ddd Flink-ddd commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR reorganizes RL-Kernel so model code, backend implementations, reusable operators, framework adapters, contracts, configuration, and validation utilities have clear ownership.

Public imports, backend IDs, configuration semantics, and validated CUDA/ROCm behavior remain compatible.

Repository structure

The directory-only map below shows the main ownership boundaries. Braces group sibling directories; the complete tracked hierarchy follows in expandable sections.

RL-Kernel/
├── rl_engine/
│   ├── models/                          # Model specifications and assembly
│   │   ├── qwen3/                       # Existing Qwen3 Dense implementation
│   │   └── {deepseek_v4,gemma,minimax_h3}/ # Reserved model packages
│   ├── layers/                          # Reusable compositions of operators
│   ├── ops/                             # Semantic interfaces, shared across models
│   │   ├── {attention,gemm,ffn,norm,activation,rope}/
│   │   └── {embedding,moe,logprob,loss,sampling,packing,autograd}/
│   ├── contracts/                       # Numerical requirements and diagnostics
│   │   ├── {operators,diagnostics}/
│   │   └── profiles/{precision,invariance}/
│   ├── reference/                       # Mathematical references and retained aliases
│   ├── platforms/                       # Device discovery and capabilities
│   ├── backends/                        # Hardware-specific implementations
│   │   ├── cuda/{attention,gemm,ffn,logprob}/
│   │   ├── rocm/{attention,gemm,ffn,logprob}/
│   │   ├── musa/{attention,gemm,logprob}/
│   │   ├── ascend/{attention,gemm,logprob}/
│   │   ├── cpu/{attention,gemm,logprob}/
│   │   └── shared/triton/               # Implementations shared across eligible devices
│   ├── runtime/                         # Dispatch, policies, execution, and provenance
│   │   ├── provenance/
│   │   └── {selector,performance}/      # Reserved selection-policy ownership
│   ├── distributed/
│   │   ├── algorithms/                  # Partitioning and canonical reduction order
│   │   └── transports/                  # Communication bindings
│   ├── integrations/
│   │   ├── common/                      # Shared integration logic and state
│   │   ├── engines/
│   │   │   ├── rollout/vllm/            # Rollout hooks and runtime binding
│   │   │   └── train/{megatron,deepspeed}/ # Training adapters
│   │   └── orchestrators/
│   │       ├── vime/{providers,experiments,patches}/
│   │       └── {miles,areal}/            # Reserved framework integrations
│   ├── validation/                      # Reusable train-rollout consistency harnesses
│   │   ├── operators/                   # WS1 operator accuracy and invariance
│   │   ├── distributed/                 # WS2 distributed validation
│   │   ├── {models,cross_config,ablation}/
│   │   └── {common,fixtures,reports}/
│   ├── config/workloads/                # Packaged workload definitions
│   ├── {entrypoints,utils}/
│   └── {alignment,executors,kernels,testing}/ # Legacy import compatibility
├── csrc/                                # Native sources and extension bindings
│   ├── {bindings,common}/
│   └── {cuda,rocm,musa,ascend}/
├── tests/                               # Mirrors implementation and validation ownership
│   ├── {models,layers,ops,contracts,reference}/
│   ├── {backends,platforms,runtime}/
│   ├── distributed/{collectives,transports,tp,cp,ep,dp}/
│   ├── integrations/
│   │   ├── common/
│   │   ├── engines/rollout/vllm/
│   │   ├── engines/train/{megatron,deepspeed}/
│   │   └── orchestrators/{vime,miles,areal}/
│   ├── validation/{operators,distributed,models,cross_config,ablation,common}/
│   └── {benchmarks,e2e,entrypoints,build,helpers,data}/
├── benchmarks/                          # Performance measurements and tuning
│   ├── {operators,layers,backends,distributed,models,e2e}/
│   └── {common,tuning,profiling,results}/
├── configs/
│   ├── {models,hardware,policies,workloads,ablations,benchmarks,tuning,local}/
│   ├── suites/{ws1,ws2,e2e}/
│   ├── experiments/{cross_config,vime}/
│   └── integrations/
│       ├── engines/{rollout,train}/
│       └── orchestrators/vime/
├── tools/{validation,weights,env,checks,benchmarking,migration}/
├── bin/                                 # Checkout command launchers
├── build_tools/                         # Build selection and compiler configuration
├── ci/{scripts,jobs,runners,providers}/  # Reusable CI execution and configuration
├── .github/workflows/                   # GitHub CI orchestration
├── docker/                              # Container definitions
├── requirements/{integrations,constraints}/ # Dependencies and reserved categories
├── docs/
│   ├── {architecture,contributing,contracts,integrations,validation}/
│   └── {getting_started,usage,operators,benchmarking,api,cli,archive}/
├── examples/{operators,post_training}/
├── reports/{experiments,releases,archive}/
├── scripts/                             # Legacy command compatibility
└── .claude/                             # Retained development skills

Model packages declare topology and operator needs. Shared operator semantics belong in ops and contracts; each platform owns its attention, GEMM, and FFN implementations under backends. Native kernels live in csrc. Cross-platform Triton implementations use backends/shared/triton, while ROCm-only Triton FFN stays in backends/rocm/ffn.

Engine-specific hooks belong in integrations/engines/rollout or integrations/engines/train. Post-training coordination belongs in orchestrators. WS1, WS2, model consistency, and ablation checks reuse these implementations through validation, with corresponding coverage under tests.

Reserved packages define where future work belongs; their presence does not establish model or hardware support. The selector and performance packages reserve space for future selection policies. Compatibility paths remain available for existing imports; new code belongs in the owning layers above.

Full directory inventory

The following groups include all 443 tracked directories at ca74261. Files and untracked build/cache outputs are omitted.

Library packages and compatibility paths (211 directories)
RL-Kernel/
└── rl_engine/
    ├── alignment/  # Legacy compatibility imports
    │   ├── cross_config/
    │   │   └── adapters/
    │   └── testing/
    │       └── smoke_ops/
    ├── backends/
    │   ├── ascend/
    │   │   ├── activation/
    │   │   ├── attention/
    │   │   ├── embedding/
    │   │   ├── gemm/
    │   │   ├── logprob/
    │   │   ├── loss/
    │   │   ├── moe/
    │   │   ├── norm/
    │   │   ├── packing/
    │   │   ├── rope/
    │   │   └── sampling/
    │   ├── cpu/
    │   │   ├── activation/
    │   │   ├── attention/
    │   │   ├── embedding/
    │   │   ├── gemm/
    │   │   ├── logprob/
    │   │   ├── loss/
    │   │   ├── moe/
    │   │   ├── norm/
    │   │   ├── packing/
    │   │   ├── rope/
    │   │   └── sampling/
    │   ├── cuda/
    │   │   ├── activation/
    │   │   ├── attention/
    │   │   ├── embedding/
    │   │   ├── ffn/
    │   │   ├── gemm/
    │   │   ├── logprob/
    │   │   ├── loss/
    │   │   ├── moe/
    │   │   ├── norm/
    │   │   ├── packing/
    │   │   ├── rope/
    │   │   └── sampling/
    │   ├── musa/
    │   │   ├── activation/
    │   │   ├── attention/
    │   │   ├── embedding/
    │   │   ├── gemm/
    │   │   ├── logprob/
    │   │   ├── loss/
    │   │   ├── moe/
    │   │   ├── norm/
    │   │   ├── packing/
    │   │   ├── rope/
    │   │   └── sampling/
    │   ├── rocm/
    │   │   ├── activation/
    │   │   ├── attention/
    │   │   ├── embedding/
    │   │   ├── ffn/
    │   │   ├── gemm/
    │   │   ├── logprob/
    │   │   ├── loss/
    │   │   ├── moe/
    │   │   ├── norm/
    │   │   ├── packing/
    │   │   ├── rope/
    │   │   └── sampling/
    │   └── shared/
    │       └── triton/
    │           ├── activation/
    │           ├── attention/
    │           ├── embedding/
    │           ├── ffn/  # Compatibility import for the ROCm Triton FFN
    │           ├── gemm/
    │           ├── logprob/
    │           ├── loss/
    │           ├── norm/
    │           └── rope/
    ├── config/
    │   └── workloads/
    ├── contracts/
    │   ├── diagnostics/
    │   ├── operators/
    │   └── profiles/
    │       ├── invariance/
    │       └── precision/
    ├── distributed/
    │   ├── algorithms/
    │   └── transports/
    ├── entrypoints/
    ├── executors/  # Legacy compatibility imports
    ├── integrations/
    │   ├── common/
    │   ├── engines/
    │   │   ├── rollout/
    │   │   │   └── vllm/
    │   │   └── train/
    │   │       ├── deepspeed/
    │   │       └── megatron/
    │   ├── orchestrators/
    │   │   ├── areal/  # Reserved orchestrator package
    │   │   ├── miles/  # Reserved orchestrator package
    │   │   └── vime/
    │   │       ├── experiments/
    │   │       │   ├── dense/
    │   │       │   │   ├── companion_patches/
    │   │       │   │   └── profiles/
    │   │       │   ├── rocm_ablation/
    │   │       │   └── rocm_attention/
    │   │       │       ├── companion_patches/
    │   │       │       └── profiles/
    │   │       ├── patches/
    │   │       │   ├── dense/
    │   │       │   └── rocm_attention/
    │   │       └── providers/
    │   └── vime/  # Legacy compatibility imports
    ├── kernels/  # Legacy compatibility imports
    │   ├── gtest/
    │   └── ops/
    │       ├── ascend/
    │       │   ├── activation/
    │       │   ├── attention/
    │       │   ├── linear/
    │       │   ├── loss/
    │       │   ├── matmul/
    │       │   ├── norm/
    │       │   └── rotary_embedding/
    │       ├── cuda/
    │       │   ├── activation/
    │       │   ├── attention/
    │       │   ├── linear/
    │       │   ├── loss/
    │       │   ├── matmul/
    │       │   ├── norm/
    │       │   └── rotary_embedding/
    │       ├── matmul/
    │       ├── pytorch/
    │       │   ├── activation/
    │       │   ├── attention/
    │       │   ├── ffn/
    │       │   ├── linear/
    │       │   ├── loss/
    │       │   ├── matmul/
    │       │   ├── norm/
    │       │   ├── packing/
    │       │   └── rotary_embedding/
    │       ├── rocm/
    │       │   ├── attention/
    │       │   ├── loss/
    │       │   ├── matmul/
    │       │   └── rotary_embedding/
    │       └── triton/
    │           ├── activation/
    │           ├── attention/
    │           ├── ffn/
    │           ├── linear/
    │           ├── loss/
    │           ├── matmul/
    │           └── rotary_embedding/
    ├── layers/
    ├── models/
    │   ├── deepseek_v4/  # Reserved model package
    │   ├── gemma/  # Reserved model package
    │   ├── minimax_h3/  # Reserved model package
    │   └── qwen3/
    ├── ops/
    │   ├── activation/
    │   ├── attention/
    │   ├── autograd/
    │   │   └── musa/
    │   ├── embedding/
    │   ├── ffn/
    │   ├── gemm/
    │   ├── logprob/
    │   ├── loss/
    │   ├── moe/
    │   ├── norm/
    │   ├── packing/
    │   ├── rope/
    │   └── sampling/
    ├── platforms/
    ├── reference/
    │   ├── activation/
    │   ├── attention/
    │   ├── embedding/
    │   ├── ffn/  # Compatibility import for the platform-owned FFN
    │   ├── gemm/
    │   ├── logprob/
    │   ├── loss/
    │   ├── norm/
    │   ├── packing/
    │   └── rope/
    ├── runtime/
    │   ├── performance/  # Reserved selection-policy ownership
    │   ├── provenance/
    │   └── selector/  # Reserved selection-policy ownership
    ├── testing/  # Legacy compatibility imports
    ├── utils/
    └── validation/
        ├── ablation/
        ├── common/
        ├── cross_config/
        │   └── adapters/
        ├── distributed/
        ├── fixtures/
        │   └── smoke_ops/
        ├── models/
        ├── operators/
        └── reports/
Tests (62 directories)
RL-Kernel/
└── tests/
    ├── backends/
    │   ├── ascend/
    │   ├── cuda/
    │   ├── musa/
    │   └── rocm/
    ├── benchmarks/
    ├── build/
    ├── contracts/
    │   └── operators/
    ├── data/
    ├── distributed/
    │   ├── collectives/
    │   ├── cp/
    │   ├── dp/
    │   ├── ep/
    │   ├── tp/
    │   └── transports/
    ├── e2e/
    ├── entrypoints/
    ├── helpers/
    ├── integrations/
    │   ├── common/
    │   ├── engines/
    │   │   ├── rollout/
    │   │   │   └── vllm/
    │   │   │       └── distributed/
    │   │   └── train/
    │   │       ├── deepspeed/
    │   │       └── megatron/
    │   └── orchestrators/
    │       ├── areal/
    │       ├── miles/
    │       └── vime/
    ├── layers/
    ├── models/
    │   ├── deepseek_v4/
    │   ├── gemma/
    │   ├── minimax_h3/
    │   └── qwen3/
    ├── ops/
    │   ├── activation/
    │   ├── attention/
    │   ├── autograd/
    │   ├── embedding/
    │   ├── gemm/
    │   ├── logprob/
    │   ├── loss/
    │   ├── norm/
    │   ├── packing/
    │   ├── rope/
    │   └── sampling/
    ├── platforms/
    ├── reference/
    ├── runtime/
    └── validation/
        ├── ablation/
        ├── common/
        ├── cross_config/
        ├── distributed/
        ├── models/
        └── operators/
Native sources, benchmarks, configuration, build, CI, and tools (94 directories)
RL-Kernel/
├── .github/
│   └── workflows/
├── benchmarks/
│   ├── backends/
│   │   └── rocm/
│   ├── common/
│   ├── distributed/
│   ├── e2e/
│   ├── layers/
│   ├── models/
│   ├── operators/
│   │   ├── attention/
│   │   ├── gemm/
│   │   ├── logprob/
│   │   ├── loss/
│   │   ├── norm/
│   │   ├── packing/
│   │   ├── rope/
│   │   ├── sampling/
│   │   └── suite/
│   ├── profiling/
│   ├── results/
│   │   └── qwen_ffn_h100_trace/
│   └── tuning/
├── bin/
├── build_tools/
├── ci/
│   ├── jobs/
│   ├── providers/
│   ├── runners/
│   └── scripts/
├── configs/
│   ├── ablations/
│   ├── benchmarks/
│   ├── experiments/
│   │   ├── cross_config/
│   │   └── vime/
│   │       └── dense/
│   ├── hardware/
│   ├── integrations/
│   │   ├── engines/
│   │   │   ├── rollout/
│   │   │   └── train/
│   │   └── orchestrators/
│   │       └── vime/
│   │           ├── dense/
│   │           └── rocm_attention/
│   ├── local/
│   ├── models/
│   ├── policies/
│   ├── suites/
│   │   ├── e2e/
│   │   ├── ws1/
│   │   └── ws2/
│   ├── tuning/
│   └── workloads/
├── csrc/
│   ├── ascend/
│   │   ├── attention/
│   │   ├── collectives/
│   │   └── gemm/
│   ├── bindings/
│   ├── common/
│   ├── cuda/
│   │   ├── activation/
│   │   ├── attention/
│   │   ├── collectives/
│   │   ├── embedding/
│   │   ├── gemm/
│   │   ├── logprob/
│   │   ├── norm/
│   │   ├── rope/
│   │   └── utils/
│   ├── musa/
│   │   ├── attention/
│   │   └── gemm/
│   └── rocm/
│       ├── attention/
│       ├── collectives/
│       └── logprob/
├── docker/
├── requirements/
│   ├── constraints/
│   └── integrations/
└── tools/
    ├── benchmarking/
    ├── checks/
    ├── env/
    ├── migration/
    ├── validation/
    │   ├── distributed/
    │   ├── models/
    │   └── operators/
    └── weights/
Documentation, examples, reports, and retained helpers (76 directories)
RL-Kernel/
├── .claude/
│   └── skills/
│       └── ws1-single-card-kernel/
│           └── ascendc_skills/
│               ├── ascendc-api-best-practices/
│               ├── ascendc-kernel-dev/
│               └── ascendc-perf-optimize/
├── docs/
│   ├── api/
│   ├── architecture/
│   ├── archive/
│   │   └── design/
│   ├── assets/
│   │   ├── blog/
│   │   │   └── rl-kernel-v0.1.0/
│   │   ├── readme/
│   │   └── rfc/
│   │       ├── gemma4-31b/
│   │       └── minimax-h3/
│   ├── benchmarking/
│   ├── blog/
│   ├── cli/
│   ├── community/
│   ├── contracts/
│   ├── contributing/
│   ├── getting_started/
│   ├── integrations/
│   │   └── orchestrators/
│   │       └── vime/
│   │           ├── dense/
│   │           ├── rocm_ablation/
│   │           └── rocm_attention/
│   ├── mkdocs/
│   │   ├── javascripts/
│   │   └── stylesheets/
│   ├── operators/
│   ├── usage/
│   │   └── evidence/
│   │       └── pr432-20260920/
│   └── validation/
├── examples/
│   ├── operators/
│   ├── post_training/
│   ├── vime_qwen3_8b_rocm_ablation/
│   ├── vime_qwen3_8b_tp4_cp2_200/
│   │   ├── companion_patches/
│   │   ├── profiles/
│   │   └── results/
│   │       ├── convergence_s1234_g10_g11/
│   │       ├── pr396_rocm_s1234_g10_g11_200/
│   │       └── scale_reference_s1234_g10_g11_optimized/
│   └── vime_rocm_attention_ablation/
│       ├── companion_patches/
│       └── profiles/
├── reports/
│   ├── archive/
│   │   ├── benchmarks/
│   │   │   ├── pr319_rocm_mi300x/
│   │   │   │   └── distributed/
│   │   │   ├── pr325_rocm_mi300x/
│   │   │   ├── pr328_rocm_mi300x/
│   │   │   ├── pr396_rocm_mi300x/
│   │   │   ├── qwen_ffn_h100_trace/
│   │   │   ├── qwen_ffn_layout_h100/
│   │   │   ├── ws2_cpu/
│   │   │   └── ws2_rocm_mi300x/
│   │   └── experiments/
│   │       └── dense/
│   │           ├── convergence_s1234_g10_g11/
│   │           │   └── figures/
│   │           ├── pr396_rocm_s1234_g10_g11_200/
│   │           └── scale_reference_s1234_g10_g11_optimized/
│   ├── experiments/
│   │   └── refactor/
│   └── releases/
└── scripts/

See the Contributor Guide for directory placement rules and the migration map for old-to-new paths.

Main changes

  • Separate model implementations from reusable operators and framework adapters.
  • Move deterministic FFN implementations under the CUDA and ROCm backends, with compatibility imports for previous paths.
  • Keep the ROCm-only Triton FFN under the ROCm backend.
  • Use a dedicated ROCm strict FFN autograd function instead of globally replacing shared backward behavior.
  • Keep ROCm strict backward on deterministic GEMM paths, including TP4/CP2 reference coverage.
  • Package the Vime JSON configuration as a regular file for symlink-disabled checkouts.
  • Integrate the latest main branch, including MUSA fused logprob support.

Validation

No refactor-caused functional, numerical, or end-to-end performance regression was observed on CUDA or ROCm. GPU means below use rounds 2 and 3; round 1 is warmup.

CUDA H100

Configuration Mismatch count Max absolute logprob difference Exact equality
P/P native 14,262 / 73,707 0.659206 false
R/R strict 0 / 71,369 0 true
Metric P/P native R/R strict R/R relative to P/P
Rollout time 50.909174 s 43.871006 s 13.82% faster
Effective tokens/GPU/s 86.123703 93.558374 8.63% higher
Update weights 27.278190 s 27.247268 s 0.11% faster
Reference log probs 1.199057 s 1.319472 s 10.04% slower
Log probs 1.758154 s 1.785446 s 1.55% slower
Actor train 5.098225 s 5.986691 s 17.43% slower
Train time 8.221268 s 9.261354 s 12.65% slower
Actor train tok/s 7,335.350589 5,698.934777 22.31% lower
End-to-end step 92.304281 s 86.631667 s 6.15% faster

CUDA strict R/R had zero mismatches in the selected rounds. Main-versus-refactor strict trajectories were raw-byte identical across 2,136 tensors, 6,963,648 tensor elements, 2,968 scalar values, and four publications of 399 parameters.

ROCm MI300X

Configuration Mismatch count Max absolute logprob difference Exact equality
P/P native 25,857 / 96,262 3.142752 false
R/R strict 0 / 93,851 0 true
Metric P/P native R/R strict R/R relative to P/P
Rollout time 42.775298 s 41.860492 s 2.14% faster
Effective tokens/GPU/s 139.920280 139.194297 0.52% lower
Update weights 0.534724 s 0.557623 s 4.28% slower
Reference log probs 2.484850 s 3.729799 s 50.10% slower
Log probs 2.461369 s 2.366084 s 3.87% faster
Actor train 5.770843 s 9.017135 s 56.25% slower
Train time 11.162281 s 15.471597 s 38.61% slower
Actor train tok/s 8,560.598426 5,327.845068 37.76% lower
End-to-end step 55.449389 s 59.192035 s 6.75% slower

ROCm strict R/R had zero bitwise mismatches in all 129,729 checked elements across all three rounds. In rounds 2 and 3, all 93,851 checked elements and all 16 selected samples were bitwise exact. The strict mean end-to-end time improved from the previous 59.866968 s result to 59.192035 s.

Path and test coverage

  • P/P used native Megatron and vLLM attention, FFN, and logprob implementations with no fallback.
  • R/R used RL-Kernel strict attention, FFN, logprob, deterministic MFMA GEMM, and grouped RCCL implementations with no fallback.
  • The final ROCm deterministic GEMM, strict backward, packed FFN, and collective suite passed 71 tests.
  • Conflict-resolution validation passed 96 tests with 5 skips; formatting, compilation, and diff checks passed.

Performance numbers apply to the tested configurations and are regression evidence, not universal hardware claims.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Walkthrough

Warning

Review details and warnings were omitted to fit the comment limit.

@Flink-ddd Flink-ddd changed the title refactor: organize models, backends, contracts and train/rollout engines refactor: organize models, backends, contracts and train and rollout engines Oct 8, 2026
Signed-off-by: vensen <vensenmu@gmail.com>
Signed-off-by: vensen <vensenmu@gmail.com>
Set OpenMP and MKL to one thread before PyTorch imports in the CPU unit-test job. The reordered cross-configuration suite can initialize a parent thread pool before forked smoke scorers run. Preserve the scoring timeout, numerical assertions, production routing, and GPU benchmark configuration.

Signed-off-by: vensen <vensenmu@gmail.com>
@Flink-ddd Flink-ddd added type: refactor Code refactoring enhancement New feature or request component: kernels Tasks involving the development of CUDA and Triton underlying operators component: alignment Tasks involving RL loss functions such as DPO and GRPO, and mathematical alignment logic component: executors Tasks involving the interaction of vLLM inference and DeepSpeed ​​training endpoints. platform: cuda Specific optimizations or bugs in NVIDIA graphics cards (such as FlashInfer, TMA optimizations) platform: rocm Specific tasks specific to AMD graphics cards (such as CK, bpreshuffle/FA) platform: triton Cross-platform Triton kernel related tasks Ascend priority: high Severe congestion issues require the highest priority for resolution. labels Oct 8, 2026
@Flink-ddd Flink-ddd added the MUSA label Oct 8, 2026
Flink-ddd and others added 3 commits October 8, 2026 19:24
Map PR types to code ownership, tests, configuration, benchmarks, and documentation. Explain model and hardware implementation status, train/rollout engine boundaries, numerical evidence, and DCO sign-offs. Add a dedicated Contributor Guide under Developer Guide while preserving all top-level navigation categories.

Signed-off-by: vensen <vensenmu@gmail.com>
Render directory paths and inline terms as plain text. Escape angle-bracket placeholders so they remain visible, and preserve the command examples.

Signed-off-by: vensen <vensenmu@gmail.com>
Signed-off-by: vensen <vensenmu@gmail.com>
Signed-off-by: OpenAI Codex <codex@openai.com>
ryankert01 added a commit to ryankert01/RL-Kernel that referenced this pull request Oct 30, 2026
…dels

Since PR RL-Align#497, scripts/ holds only compatibility shims (contributor guide,
"Move files or change packaging"), and layout.json maps
scripts/ws1_reference.py to tools/validation/models/. Move
museglimmer_reference.py next to it.

Also run the fingerprint tests in CI-Pipeline, and import
manifest_identity_hash and weight_snapshot_hash from
rl_engine.config.workload instead of keeping a second copy.

Signed-off-by: Ryan Huang <ryankert01@gmail.com>
fusheng-ji added a commit to fusheng-ji/RL-Kernel that referenced this pull request Oct 30, 2026
…d and the TP tests to tests/distributed, following the RL-Align#497 layout

Signed-off-by: Wenbo Ji <36562829+fusheng-ji@users.noreply.github.com>
fusheng-ji added a commit to fusheng-ji/RL-Kernel that referenced this pull request Oct 30, 2026
… SP tests to tests/distributed/sp

An index created under torch.inference_mode() has no version counter, so reading index._version in
H3SPNormAdaLNCudaOp.plan raised for both the modulated norm and the gated residual. Such an index is now
planned every time (an in-place edit cannot be seen without a version), with a regression test that runs
both ops under inference mode and edits the index in place.

The SP tests move from tests/models/minimax_h3 to tests/distributed/sp, following the WS2 harness
relocation in RL-Align#493 and the RL-Align#497 layout; imports, the layout map and the documented command are updated.

Signed-off-by: Wenbo Ji <36562829+fusheng-ji@users.noreply.github.com>
fusheng-ji added a commit to fusheng-ji/RL-Kernel that referenced this pull request Nov 2, 2026
…RL-Align#497 layout

Move the benchmark and plot scripts to benchmarks/distributed/, their unit
tests to tests/benchmarks/ and the all-gather size test to
tests/distributed/collectives/, and update the imports and usage commands.

Signed-off-by: Wenbo Ji <36562829+fusheng-ji@users.noreply.github.com>
fusheng-ji added a commit to fusheng-ji/RL-Kernel that referenced this pull request Nov 2, 2026
…tors/logprob

Move the backward evidence, provider evidence and plot scripts to the RL-Align#497
operator benchmark directory, repoint REPO_ROOT, and update the imports,
usage commands and operator doc.

Signed-off-by: Wenbo Ji <36562829+fusheng-ji@users.noreply.github.com>
nodeeeeee added a commit to nodeeeeee/RL-Kernel that referenced this pull request Nov 6, 2026
Add the Qwen-Image latent pack/unpack permutation (RFC RL-Align#386) with CUDA,
Triton and PyTorch backends for FP32/FP16/BF16. Forward and backward are
bit-exact permutations; autograd runs the inverse kernel for backward.

Migrated to the RL-Align#497 layout: CUDA source under
csrc/cuda/model_specific/qwenimage, backends under
rl_engine/backends/{cuda,shared/triton}/model_specific/qwenimage, the
reference and shape contract under rl_engine/reference/model_specific/qwenimage,
shared autograd in rl_engine/ops/packing, registry entries in
rl_engine/runtime/registry.py, bindings in csrc/bindings/ops.cpp, build
wiring in build_tools/extensions.py, and tests under tests/models/qwenimage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: nodeeeeee <zhangkai.nodeee@gmail.com>
haotianxue31 added a commit to haotianxue31/RL-Kernel that referenced this pull request Nov 6, 2026
…with RL-Align#497

Multiplying by scale 1.0 on the plain path replaced NaNs in forward with the
canonical NaN. Gate the multiply behind a compile-time apply_scale flag, and
test plain forward and backward against oracles that do not use the kernels.

Move the tests and benchmark to their RL-Align#497 owners, register the op through
canonical modules, and drop the new rl_engine.kernels shims and provenance
aliases. Revert the unrelated final_logit_softcap benchmark refactor.

Signed-off-by: haotianxue31 <haotianxue31@gmail.com>
luoyueyuguang added a commit to luoyueyuguang/RL-Kernel that referenced this pull request Nov 12, 2026
…p-down-gemm

Bring the PR RL-Align#497 layout refactor ("organize models, backends, contracts and
train and rollout engines") onto the WS1 MLP down projection row. The row's
three commits keep their content; only its placement follows the refactor's
ownership rules.

Conflicts (5 files) and how each was resolved:

* rl_engine/kernels/registry.py, rl_engine/kernels/gtest/operator_inputs.py and
  rl_engine/kernels/gtest/operator_specs.py: take the refactor's content. Those
  paths are compatibility shims now, so the row is not added there; its
  registrations move to rl_engine/runtime/registry.py (the OpBackend entries plus
  the cuda, rocm, musa and cpu priority maps) and to
  rl_engine/validation/operators/{operator_specs,operator_inputs}.py.
* setup.py: take the refactor's thin entry point; the row's two native sources go
  into build_tools/extensions.py, which owns the source lists now --
  csrc/cuda/gemm/mlp_down_gemm.cu in cuda_sources and
  csrc/cuda/gemm/mlp_down_gemm_sm90.cu in sm90_srcs.
* docs/benchmarking/README.md: keep the refactor's paths and list the row's
  benchmark at its new path.

Placement of the row, per docs/contributing/contributor-guide.md:

* rl_engine/kernels/ops/cuda/linear/mlp_down_gemm.py -> rl_engine/backends/cuda/gemm/mlp_down_gemm.py
* rl_engine/kernels/ops/pytorch/linear/mlp_down_gemm.py -> rl_engine/reference/gemm/mlp_down_gemm.py
* rl_engine/kernels/ops/triton/linear/mlp_down_gemm.py -> rl_engine/backends/shared/triton/gemm/mlp_down_gemm.py
* tests/test_mlp_down_gemm.py, tests/test_mlp_down_gemm_triton.py -> tests/ops/gemm/
* benchmarks/benchmark_mlp_down_gemm.py -> benchmarks/operators/gemm/benchmark_mlp_down_gemm.py

The moved implementations, the operator page, the benchmark, the WS1 gtest
launcher and the WS1 GPU workflow now import/name the canonical modules
(rl_engine.backends.cuda.gemm, rl_engine.reference.gemm,
rl_engine.backends.shared.triton.gemm, rl_engine.runtime.registry,
rl_engine.validation.operators.*, rl_engine.backends.extension,
rl_engine.ops.autograd.backward_runtime, rl_engine.runtime.policy). No new
implementation is left under a compatibility path; the row has no legacy
imports of its own to preserve. The row is also listed in benchmarks/README.md
and in the WS1 GPU gate (ci/scripts/run_ws1_gtest.sh,
.github/workflows/ws1-gtest-gpu.yml), the way the sibling mlp_up_gemm_gelu row
is listed.

Verification:

* CPU checkout: `python -m pytest tests/runtime -q` 78 passed, 2 skipped;
  `python ci/run.py layout -q` 32 passed, 1 skipped;
  `tools/validation/operators/check_operator.py --op mlp_down_gemm --candidate
  pytorch --device cpu --dtype fp32 --check-grad` pass_rate=1.0000.
* H100 80GB HBM3, SM90 build (KERNEL_ALIGN_FORCE_SM90=1, nvcc exit 0):
  `pytest tests/ops/gemm/test_mlp_down_gemm.py
  tests/ops/gemm/test_mlp_down_gemm_triton.py -q` 138 passed;
  the row's cases in `tests/validation/operators/test_ws1_gtest_gpu.py` 3 passed;
  `benchmarks/operators/gemm/benchmark_mlp_down_gemm.py --help` exits 0.
* Known pre-existing failure, unrelated to this row: on a CUDA build
  `tests/runtime/test_attention_dispatch.py::test_registered_backend_resolves_with_provenance`
  fails (provenance["fallback"] is True). It fails identically on the refactor
  tip without this row, and passes on the CPU-only run.

Signed-off-by: luoyueyuguang <luoyuelight@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ascend component: alignment Tasks involving RL loss functions such as DPO and GRPO, and mathematical alignment logic component: executors Tasks involving the interaction of vLLM inference and DeepSpeed ​​training endpoints. component: kernels Tasks involving the development of CUDA and Triton underlying operators enhancement New feature or request MUSA platform: cuda Specific optimizations or bugs in NVIDIA graphics cards (such as FlashInfer, TMA optimizations) platform: rocm Specific tasks specific to AMD graphics cards (such as CK, bpreshuffle/FA) platform: triton Cross-platform Triton kernel related tasks priority: high Severe congestion issues require the highest priority for resolution. type: refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants