Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/cicd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ jobs:
build-args: |
MAX_JOBS=4
NEMO_RL_COMMIT=${{ needs.pre-flight.outputs.test_sha }}
SKIP_SGLANG_BUILD=1

update-uv-cache:
name: Update uv build cache
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

# CMake (for sglang build)
# CMake (for CUDA extension builds: transformer-engine, mamba-ssm, etc.)
RUN GITHUB_ARTIFACTORY=github.com \
&& CMAKE_VERSION=3.31.1 \
&& ARCH=$(uname -m) \
Expand Down
3 changes: 3 additions & 0 deletions nemo_rl/models/generation/sglang/sglang_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def __init__(
# Get current node IP and a free port for the server
node_ip = _get_node_ip_local()
free_port = _get_free_port_local()
# sglang derives grpc_port = port + 10000, so cap at 55535 to stay within valid range
while free_port > 55535:
free_port = _get_free_port_local()

# Build SGLang server arguments
kwargs = {
Expand Down
94 changes: 4 additions & 90 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ vllm = [
"nvidia-cutlass-dsl>=4.4.0.dev1",
]
sglang = [
"sglang",
"sglang-kernel", # Must be a direct dep so [tool.uv.sources] VCS override applies (transitive deps don't use sources)
"sglang==0.5.11",
"sglang-kernel==0.4.2", # Direct dep for explicit version control
]
mcore = [
# also need cudnn (https://developer.nvidia.com/cudnn-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_network)
Expand Down Expand Up @@ -249,9 +249,6 @@ causal-conv1d = { git = "https://github.com/Dao-AILab/causal-conv1d", rev = "67e
mamba-ssm = { git = "https://github.com/state-spaces/mamba.git", rev = "d68d16ed7d5d5164eb5a57c0285f3b7eb8394ec1" }
nv-grouped-gemm = { git = "https://github.com/fanshiqing/grouped_gemm", tag = "v1.1.4.post7" }
emerging-optimizers = { git = "https://github.com/NVIDIA-NeMo/Emerging-Optimizers.git", rev = "v0.2.0" }
# Official sglang v0.5.10 with transformers v5 support
sglang = { git = "https://github.com/sgl-project/sglang.git", tag = "v0.5.10", subdirectory = "python" }
sglang-kernel = { git = "https://github.com/sgl-project/sglang.git", tag = "v0.5.10", subdirectory = "sgl-kernel" }
nvidia-modelopt = { git = "https://github.com/NVIDIA/Model-Optimizer", rev = "905018803414702e414a86716484ed4115b37ba6" }
nvidia-resiliency-ext = { git = "https://github.com/NVIDIA/nvidia-resiliency-ext.git", rev = "15a851565a4ce846c04431ecb0cf09903ab4837e" }

Expand All @@ -278,7 +275,6 @@ explicit = true

[tool.uv]
preview = true # Enable preview features like extra-build-dependencies
extra-build-variables = { sglang-kernel = { CMAKE_BUILD_PARALLEL_LEVEL = "8", FLASHINFER_CUDA_ARCH_LIST = "9.0a 10.0a", CMAKE_ARGS = "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" } }
no-build-isolation-package = [
"transformer-engine-torch",
"transformer-engine",
Expand All @@ -288,7 +284,6 @@ no-build-isolation-package = [
"deep_gemm",
"deep_ep",
"nv-grouped-gemm", # from mlm (added here to make sure it's built no isolation since mlm workspace uses setup.py)
"sglang-kernel",
]
# Always apply the build group since dependencies like TE/mcore/nemo-run require build dependencies
# and this lets us assume they are implicitly installed with a simply `uv sync`. Ideally, we'd
Expand Down Expand Up @@ -318,20 +313,17 @@ override-dependencies = [
"setuptools>=80.10.2",
"deep_ep @ git+https://github.com/deepseek-ai/DeepEP.git@bfded34800dfec415b71503f8205181de90b2480 ; platform_machine == 'x86_64'",
"deep_ep @ git+https://github.com/deepseek-ai/DeepEP.git@a48493600c4886c1b297aaa78db0e1ebc2d8dd6c ; platform_machine == 'aarch64'",
# Note: flashinfer versions are pinned per-extra (vllm uses 0.6.8.post1, sglang uses 0.6.7.post2)
# since vllm and sglang extras are mutually exclusive and have different requirements.
# Override megatron-core's flashinfer~=0.5.0 constraint to allow both vllm (0.6.8.post1) and sglang (0.6.7.post2)
# Override megatron-core's flashinfer~=0.5.0 constraint to allow both vllm and sglang (both use 0.6.8.post1)
"flashinfer-python>=0.5.0",
"flashinfer-cubin>=0.5.0",
# sglang 0.5.10 requires nvidia-cutlass-dsl>=4.4.1 (via flashinfer 0.6.7.post2 which uses CUTLASS 4.4.2).
# Override to >=4.4.1 so uv can resolve to a version satisfying both vllm and sglang.
"nvidia-cutlass-dsl>=4.4.1",
# Relax megatron-core workspace member's opentelemetry-api ceiling (<1.34) for protobuf 6.x compat with ray
"opentelemetry-api>=1.33.1",
# vLLM 0.20.0 excludes transformers 5.0-5.5.0 but our codebase needs 5.3.0.
# Override so uv can resolve transformers==5.3.0 for non-vllm extras.
"transformers==5.3.0",
#Override till we can upgrade sglang version to address CVE GHSA-7rgv-gqhr-fxg3
# Override sglang's xgrammar==0.1.32 to address CVE GHSA-7rgv-gqhr-fxg3
"xgrammar==0.1.33",
# Override dependencies to address CVEs
"mlflow>=3.11.1",
Expand Down Expand Up @@ -411,7 +403,6 @@ transformer-engine-torch = [{ requirement = "torch", match-runtime = true }]
mamba-ssm = [{ requirement = "torch", match-runtime = true }]
causal-conv1d = [{ requirement = "torch", match-runtime = true }]
nv-grouped-gemm = [{ requirement = "torch", match-runtime = true }]
sglang-kernel = [{ requirement = "torch", match-runtime = true }]

# Needed when building from source
[[tool.uv.dependency-metadata]]
Expand Down Expand Up @@ -458,83 +449,6 @@ name = "nv-grouped-gemm"
version = "v1.1.4.post7"
requires-dist = ["setuptools", "wheel", "torch", "numpy"]

[[tool.uv.dependency-metadata]]
name = "sglang-kernel"
# This version has to match the version in the commit/rev/tag used
version = "0.4.1"
requires-dist = ["torch", "scikit-build-core", "wheel"]

[[tool.uv.dependency-metadata]]
name = "sglang"
# VCS install from official sgl-project/sglang v0.5.10
# Version is dynamic (setuptools-scm), so uv cannot resolve deps from the VCS source automatically.
# This requires-dist list must be kept in sync with the official python/pyproject.toml [project].dependencies.
# Source: https://github.com/sgl-project/sglang/blob/v0.5.10/python/pyproject.toml
version = "0.5.10"
requires-dist = [
"IPython",
"aiohttp",
"apache-tvm-ffi>=0.1.5,<0.2",
"anthropic>=0.20.0",
"blobfile==3.0.0",
"build",
"compressed-tensors",
"cuda-python==13.0",
"decord2",
"datasets",
"einops",
"fastapi",
"flashinfer_python==0.6.7.post2",
"flashinfer_cubin==0.6.7.post2",
"gguf",
"interegular",
"llguidance>=0.7.11,<0.8.0",
"modelscope",
"msgspec",
"ninja",
"numpy",
"nvidia-cutlass-dsl>=4.4.1",
"nvidia-ml-py",
"openai-harmony==0.0.4",
"openai==2.6.1",
"orjson",
"outlines==0.1.11",
"packaging",
"partial_json_parser",
"pillow",
"prometheus-client>=0.20.0",
"psutil",
"py-spy",
"pybase64",
"pydantic",
"python-multipart",
"pyzmq>=25.1.2",
"quack-kernels>=0.3.0",
"requests",
"scipy",
"sentencepiece",
"setproctitle",
"flash-attn-4>=4.0.0b4",
"sglang-kernel==0.4.1",
"soundfile==0.13.1",
"tiktoken",
"timm==1.0.16",
"torch_memory_saver==0.0.9",
"torch==2.9.1",
"torchao==0.9.0",
"torchaudio==2.9.1",
"torchcodec==0.9.1 ; sys_platform != 'linux' or (sys_platform == 'linux' and platform_machine != 'aarch64' and platform_machine != 'arm64' and platform_machine != 'armv7l')",
"torchvision",
"tqdm",
"mistral_common>=1.9.0",
"transformers==5.3.0",
"uvicorn",
"uvloop",
"watchfiles",
"xgrammar==0.1.32",
"smg-grpc-servicer>=0.5.0",
]

[[tool.uv.dependency-metadata]]
name = "megatron-bridge"
# Static metadata so the root resolver handles megatron-bridge's deps
Expand Down
5 changes: 1 addition & 4 deletions tests/functional/L1_Functional_Tests_GPU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ run_test uv run --no-sync bash ./tests/functional/grpo_multiple_dataloaders
run_test uv run --no-sync bash ./tests/functional/grpo_multiturn.sh
run_test uv run --no-sync bash ./tests/functional/grpo_non_colocated.sh
run_test uv run --no-sync bash ./tests/functional/grpo_rm_env.sh
# Skip sglang functional test if sglang was not built into the container
if python -c "import sglang" 2>/dev/null; then
run_test uv run --no-sync bash ./tests/functional/grpo_sglang.sh
fi
run_test uv run --no-sync bash ./tests/functional/grpo_sglang.sh
run_test fast uv run --no-sync bash ./tests/functional/grpo_topp_topk.sh
run_test uv run --no-sync bash ./tests/functional/prorlv2.sh
run_test uv run --no-sync bash ./tests/functional/qa_distillation_megatron.sh
Expand Down
14 changes: 5 additions & 9 deletions tests/unit/L0_Unit_Tests_Generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,10 @@ else
uv run --extra vllm bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --vllm-only
fi

# Check and run sglang tests (skip if sglang was not built into the container)
if python -c "import sglang" 2>/dev/null; then
exit_code=$(cd ${PROJECT_ROOT}/tests && uv run --extra sglang pytest "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --collect-only --hf-gated --sglang-only -q >/dev/null 2>&1; echo $?)
if [[ $exit_code -eq 5 ]]; then
echo "No sglang tests to run"
else
uv run --extra sglang bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --sglang-only
fi
# Check and run sglang tests
exit_code=$(cd ${PROJECT_ROOT}/tests && uv run --extra sglang pytest "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --collect-only --hf-gated --sglang-only -q >/dev/null 2>&1; echo $?)
if [[ $exit_code -eq 5 ]]; then
echo "No sglang tests to run"
else
echo "sglang not installed, skipping sglang tests"
uv run --extra sglang bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --sglang-only
fi
14 changes: 5 additions & 9 deletions tests/unit/L0_Unit_Tests_Other.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ else
uv run --extra vllm bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --vllm-only
fi

# Check and run sglang tests (skip if sglang was not built into the container)
if python -c "import sglang" 2>/dev/null; then
exit_code=$(cd ${PROJECT_ROOT}/tests && uv run --extra sglang pytest "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --collect-only --hf-gated --sglang-only -q >/dev/null 2>&1; echo $?)
if [[ $exit_code -eq 5 ]]; then
echo "No sglang tests to run"
else
uv run --extra sglang bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --sglang-only
fi
# Check and run sglang tests
exit_code=$(cd ${PROJECT_ROOT}/tests && uv run --extra sglang pytest "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --collect-only --hf-gated --sglang-only -q >/dev/null 2>&1; echo $?)
if [[ $exit_code -eq 5 ]]; then
echo "No sglang tests to run"
else
echo "sglang not installed, skipping sglang tests"
uv run --extra sglang bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --sglang-only
fi

# Check and run nemo_gym tests
Expand Down
14 changes: 5 additions & 9 deletions tests/unit/L0_Unit_Tests_Policy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,10 @@ else
uv run --extra vllm bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --vllm-only
fi

# Check and run sglang tests (skip if sglang was not built into the container)
if python -c "import sglang" 2>/dev/null; then
exit_code=$(cd ${PROJECT_ROOT}/tests && uv run --extra sglang pytest "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --collect-only --hf-gated --sglang-only -q >/dev/null 2>&1; echo $?)
if [[ $exit_code -eq 5 ]]; then
echo "No sglang tests to run"
else
uv run --extra sglang bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --sglang-only
fi
# Check and run sglang tests
exit_code=$(cd ${PROJECT_ROOT}/tests && uv run --extra sglang pytest "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --collect-only --hf-gated --sglang-only -q >/dev/null 2>&1; echo $?)
if [[ $exit_code -eq 5 ]]; then
echo "No sglang tests to run"
else
echo "sglang not installed, skipping sglang tests"
uv run --extra sglang bash -x ./tests/run_unit.sh "${TEST_PATHS[@]}" "${IGNORE[@]}" "${EXCLUDED_UNIT_TESTS[@]}" --cov=nemo_rl --cov-append --cov-report=term-missing --cov-report=json --hf-gated --sglang-only
fi
Loading
Loading