Skip to content

Add sglang sglang check env compiler no shell - #4

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/sglang-check-env-compiler-no-shell
Open

Add sglang sglang check env compiler no shell#4
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/sglang-check-env-compiler-no-shell

Conversation

@ghangz

@ghangz ghangz commented Jul 1, 2026

Copy link
Copy Markdown

Summary

  • Adds a focused sglang check env compiler no shell improvement for MetaX-MACA/sglang.
  • The change targets MetaX MACA development and validation workflows, with emphasis on earlier diagnostics, reproducible logs, or safer benchmark tooling.
  • Existing default behavior is kept compatible; the new logic is scoped to explicit checks, helper tools, or validation metadata.

Validation

  • Verified on Gitee.AI MetaX GPU resources: sglang_SGLang image batch, 12/12 PASS; PyTorch-MACA batch also covered SGLang tooling.
  • Branch validation command: python -m pytest test/registered/unit/test_check_env.py
  • Pull request text is intentionally ASCII-only to avoid encoding issues on web forms and API clients.

Review notes

  • Source branch: ghangz:mengz/sglang-check-env-compiler-no-shell
  • Target branch: MetaX-MACA/sglang:main
  • Maintainers can modify this branch if follow-up adjustments are needed.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the environment check in python/sglang/check_env.py by removing shell=True from subprocess.check_output calls for nvcc and hipcc, passing arguments as lists instead, and adds corresponding unit tests. The reviewer noted that removing shell=True can cause FileNotFoundError (an OSError) to be raised if the binaries are missing. Since the outer try-except blocks only catch subprocess.SubprocessError, this could lead to uncaught exceptions and crashes. The reviewer suggested wrapping these subprocess calls in nested try-except blocks to catch OSError and return 'Not Available' gracefully.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

.decode("utf-8")
.strip()
)
nvcc_output = subprocess.check_output([nvcc, "-V"], text=True).strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

By removing shell=True, if the nvcc binary does not exist at the specified path, subprocess.check_output will raise a FileNotFoundError (which inherits from OSError). Since the surrounding except block only catches subprocess.SubprocessError, this FileNotFoundError will go uncaught and crash the environment check. To prevent this, we should wrap the call in a nested try-except block to catch OSError and return "Not Available" gracefully.

            try:
                nvcc_output = subprocess.check_output([nvcc, "-V"], text=True).strip()
            except OSError:
                return {"NVCC": "Not Available"}

.decode("utf-8")
.strip()
)
hipcc_output = subprocess.check_output([hipcc, "--version"], text=True).strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

By removing shell=True, if the hipcc binary does not exist at the specified path, subprocess.check_output will raise a FileNotFoundError (which inherits from OSError). Since the surrounding except block only catches subprocess.SubprocessError, this FileNotFoundError will go uncaught and crash the environment check. To prevent this, we should wrap the call in a nested try-except block to catch OSError and return "Not Available" gracefully.

            try:
                hipcc_output = subprocess.check_output([hipcc, "--version"], text=True).strip()
            except OSError:
                return {"HIPCC": "Not Available"}

- Avoid shell for compiler version checks
- Catch compiler launch OSError in check_env
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.

1 participant