Repository navigation
Qwen image latent pack unpack - #410
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Flink-ddd
left a comment
There was a problem hiding this comment.
The permutation logic looks reasonable, but please resolve the merge conflicts and migrate the implementation, tests, registry, and build wiring to the canonical paths from #497. Please also fix the lint and DCO checks, then rerun the bitwise forward and backward tests on the updated branch before merging.
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 <[email protected]> Signed-off-by: nodeeeeee <[email protected]>
446b80a to
93e8c1a
Compare
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
📄
|
|
@nodeeeeee The automated OCR review has completed. Please review and address all automated review bot findings, then push your updates. Maintainers will begin manual review after the bot findings have been addressed. |
…L-Align#538 Resolve additive conflicts in build_tools/extensions.py, csrc/bindings/ops.cpp and rl_engine/runtime/registry.py by keeping both the final_adaln_out (token_sum) entries and the upstream latent pack/unpack entries. Signed-off-by: Wenbo Ji <[email protected]>
Add Qwen-Image latent pack/unpack kernels
Adds CUDA, Triton, and PyTorch backends with forward/backward support for FP32, FP16, and BF16. Pack converts spatial latents into tokens by grouping 2x2 regions across channels; unpack restores the spatial layout. Both preserve values and bit patterns exactly.
CUDA uses a two-stage shared-memory transpose with a 32x32 data tile and 32x8 threads. Autograd executes the inverse kernel for backward. Backend registration preserves existing dispatch behavior.
Validation passed 241 tests. Numerical correctness was verified against the PyTorch reference for pack/unpack outputs and gradients using zero tolerances and byte-for-byte equality. Batch invariance was tested by comparing the first sample processed alone with the same sample processed in batches of 1, 2, 4, and 8. Tests also cover round trips, edge shapes, special values, CUDA streams, fallback, and build configuration. Recorded sanitizer runs reported zero memory errors and race hazards; three launch configurations passed 90 cases.
H100 measurements cover 36 configurations: C=16, three image sizes, batches 1/2/4/8, and three dtypes. The table shows geometric-mean speedups over PyTorch; values above 1 are faster. CUDA Graph ranges show minimum-to-maximum speedups. Eager backward remains slightly slower. Measurements predate the readability refactor and do not represent end-to-end training speed.
#386