Repository layout and ownership¶
This refactor starts at upstream main (bea224b). It borrows vLLM's separation
of model assembly, layers, platform discovery, implementation backends, engine
integration, native sources, and test infrastructure. RL-Kernel additionally
owns numerical contracts and trainβrollout validation.
For a PR-by-PR placement guide, directory responsibilities, and validation requirements, start with the Contributor Guide.
Canonical tree¶
RL-Kernel/
βββ rl_engine/
β βββ config/ # Validated workload/configuration loaders
β β βββ workloads/ # Packaged, versioned WS1 workload identity
β βββ models/
β β βββ qwen3/ # Pinned Dense spec, operator inventory, model assembly
β β βββ deepseek_v4/ # Reserved; no registered implementation
β β βββ gemma/ # Reserved; no registered implementation
β β βββ minimax_h3/ # Reserved; no registered implementation
β βββ layers/ # Extension point for reusable model layers
β βββ ops/ # Hardware-independent operator entry points
β β βββ {attention,gemm,norm,activation,rope,embedding,moe,logprob,loss,sampling,packing,autograd}/
β βββ contracts/
β β βββ operators/ # Attention, logprob, loss numerical contracts
β β βββ diagnostics/ # Shared ablation axes and reporting schema
β β βββ profiles/{precision,invariance}/
β βββ reference/ # PyTorch mathematical references and diagnostic paths
β βββ platforms/ # Device discovery and platform capabilities
β βββ backends/
β β βββ {cuda,rocm,musa,ascend,cpu}/
β β β βββ {attention,gemm,norm,activation,rope,embedding,moe,logprob,loss,sampling,packing}/
β β βββ shared/triton/ # Implementations shared across supported devices
β βββ runtime/
β β βββ registry.py # Existing contract-aware dispatch and priorities
β β βββ semantic_registry.py # Capabilities, support checks, provenance
β β βββ operators.py # Operator bridge and execution bindings
β β βββ policy.py # Strict versus diagnostic execution policy
β β βββ plan.py # Executable P/P, P/R, R/P, R/R selections
β β βββ executor.py
β β βββ provenance/ # Stable versioned operator identities
β β βββ {selector,performance}/ # Reserved for future measured selection policies
β βββ distributed/
β β βββ algorithms/ # Canonical arithmetic/collective ordering
β β βββ transports/ # RCCL and transport bindings
β βββ integrations/
β β βββ common/ # Shared adapters, weights, linear-logp, state
β β βββ engines/
β β β βββ rollout/{vllm,interface.py}
β β β βββ train/{megatron,deepspeed,contract.py}
β β βββ orchestrators/
β β βββ vime/{providers,experiments,patches}/
β β βββ {miles,areal}/ # Reserved integration points
β βββ validation/
β β βββ {operators,models,distributed,cross_config,ablation,reports,common,fixtures}/
β βββ entrypoints/ # Installed CLIs
β βββ utils/
βββ csrc/
β βββ bindings/ # Python/native registration
β βββ common/
β βββ {cuda,rocm,musa,ascend}/ # Native sources, grouped by operator family
βββ build_tools/ # Extension selection/compiler flags/environment helpers
βββ configs/
β βββ {models,hardware,policies,workloads,ablations,benchmarks,tuning,local}/
β βββ suites/{ws1,ws2,e2e}/
β βββ experiments/{cross_config,vime}/
β βββ integrations/
β βββ engines/{rollout,train}/
β βββ orchestrators/vime/
βββ tests/
β βββ {contracts,reference,ops,layers,backends,platforms,runtime,models}/
β βββ distributed/{collectives,transports,tp,cp,ep,dp}/
β βββ integrations/
β β βββ common/
β β βββ engines/{rollout,train}/
β β βββ orchestrators/
β βββ validation/{operators,models,cross_config,ablation,common}/
β βββ {benchmarks,e2e,entrypoints,build,helpers,data}/
βββ benchmarks/
β βββ {common,operators,layers,backends,distributed,models,e2e,tuning,profiling}/
βββ examples/{operators,post_training}/
βββ bin/ # Thin checkout launchers; ./rlk remains supported
βββ tools/
β βββ {validation,weights,env,checks,benchmarking,migration}/
βββ ci/{run.py,scripts,jobs,runners,providers}/
βββ .github/workflows/ # Provider-specific CI triggers and security policy
βββ docker/ # Existing CUDA/ROCm CI and development images
βββ requirements/ # Runtime, test, development, docs, benchmark, build
βββ reports/{archive,experiments,releases}/
βββ docs/{architecture,contracts,integrations,archive,...}/
βββ artifacts/ # Ignored local validation/build output
βββ pyproject.toml # Package metadata, entry points and test configuration
βββ setup.py # Thin build entry point
βββ MANIFEST.in # Native sources/build tools and packaged resources
An empty package is a reserved ownership boundary, not an advertised supported model, engine, or platform. Existing MUSA dispatch through validated shared implementations is retained; a MUSA directory alone does not certify a native MUSA kernel. Docker images and CI jobs are added only when executable support exists.
Where overlapping attention and GEMM implementations belong¶
models/qwen3/spec.pyowns the Qwen3 topology and operator inventory. A model consumes common operators; it does not own copies of generic GEMM/attention.ops/attentionandops/gemmown the semantic entry points.contractsowns numerical requirements.runtimeresolves implementation capabilities.backends/cuda/attention,backends/rocm/attention, and equivalent GEMM directories own device-specific implementations. Platform-exclusive MFMA and ROCm attention kernels stay inbackends/rocm, even when implemented in Triton.backends/shared/tritonowns a single implementation when the same source and contract are valid across devices. Register it for each supported platform; do not copy it into each platform directory.- A future truly model-specific fusion belongs under
backends/<platform>/model_specific/<model>/, with its semantic requirements declared by that model. Create it when there is an implementation to own. - Engine tensor layouts and hooks belong in the corresponding rollout/train adapter, never in the numerical kernel or the model identity.
Strict routing must first establish contract eligibility, supported topology, precision, and validated provenance. Performance rankings can only choose among eligible implementations. This PR preserves the existing dispatcher, priorities, strict/fallback policies and kernel algorithms. The reserved selector/performance packages do not introduce an unvalidated fastest-path router.
Tests and acceptance ownership¶
WS1 is a validation scope, not a second copy of each backend. Operator tests
live in tests/ops, implementation-specific checks in tests/backends, WS1
harness tests in tests/validation/operators, and Qwen3 assembly tests in
tests/models/qwen3. WS2 partition/collective tests live in tests/distributed;
engine hook tests mirror integrations/engines/{rollout,train}. End-to-end runs
combine model, backend, topology and engines through configuration.
Keep test filenames and assertions during migration. Source-inspection tests
must inspect the canonical implementation, not a compatibility wrapper. Benchmark
code lives under benchmarks; captured measurements and historical reports live
under reports. Large experiment launchers live with their orchestrator, while
examples holds short usage examples.
Compatibility and migration¶
The machine-readable tools/migration/layout.json records source/destination
paths and split modules. Old rl_engine.kernels, alignment, testing, executor
and integration import paths are thin aliases; leaf aliases return the same
module object so registries, caches and runtime state are not duplicated. Legacy
script paths delegate to the canonical tool, and legacy shell entry points
forward arguments and exit codes. New code should import canonical modules.
The WS1 workload JSON and precision contract retain their original bytes and
hashes. Historical operator IDs such as rl_engine.kernels.ops.* remain stable
v1 identifiers. runtime/provenance/identity.py translates the relocated class
module to that stable identifier when producing WS1 evidence. Executable source
fingerprints still reflect the new code; recorded identity does not substitute
for runtime provenance validation. Old reports, companion patches and pinned
patch hashes are preserved. Relative resource aliases retain old experiment
entry points; package builds include the resolved resource contents.
See Dense CUDA/ROCm acceptance before accepting the refactor on GPU hardware.