Skip to content

[module_sample] refactor and detorch - #4569

Merged
amd-ruitang3 merged 1 commit into
ROCm:mainfrom
amd-ruitang3:module_sampler_refactor
Aug 6, 2026
Merged

amd-ruitang3 merged 1 commit into
ROCm:mainfrom
amd-ruitang3:module_sampler_refactor

Conversation

@amd-ruitang3

@amd-ruitang3 amd-ruitang3 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

remove torch in .cu
- Build time: ~15s vs ~48s for the torch version — roughly 3× faster (~68% reduction).

Changes

C++ (csrc/)

  • include/sample.h — replace <torch/extension.h> with aiter_tensor.h; all 6 signatures take aiter_tensor_t&; the 3 RNG functions take int64_t philox_seed, philox_offset instead of std::optional<at::Generator>.
  • kernels/sample_kernels.cu — AITER_NO_TORCH_TYPES + hip2opus / VLLM_DISPATCH_FLOATING_TYPES_rmTorch; HipDeviceGuard / aiter::getCurrentHIPStream(); kernels take a plain (uint64_t seed, offset) pair (the in-kernel Philox RNG is unchanged → zero kernel perf change); removed the generator/mutex/PhiloxCudaState host machinery; added <cfloat> for FLT_MAX (previously pulled in transitively via ATen).
  • pybind/sample_pybind.cu + rocm_ops.hpp SAMPLE_PYBIND — add AITER_SET_STREAM_PYBIND and philox_seed / philox_offset py::args.

Python (aiter/ops/sample.py)

  • develop=True on all bindings; fc_name compiled bindings for the 3 RNG ops with public wrappers that keep the existing generator= API. New _philox_seed_offset() helper reads initial_seed() / get_offset() from the torch generator and advances the offset by the exact same ((numel-1)//(1024*M*4)+1)*4 increment the old C++ used.

Testing

🤖 Generated with Claude Code

@amd-ruitang3
amd-ruitang3 requested a review from a team August 5, 2026 06:44
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 4569 --add-label <label>

@amd-ruitang3
amd-ruitang3 requested a review from junhaha666 August 5, 2026 07:01
@amd-ruitang3
amd-ruitang3 merged commit 8c662b5 into ROCm:main Aug 6, 2026
40 checks 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

Development

Successfully merging this pull request may close these issues.

2 participants