Skip to content

Add sglang sglang runtime path audit - #12

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/sglang-runtime-path-audit
Open

Add sglang sglang runtime path audit#12
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/sglang-runtime-path-audit

Conversation

@ghangz

@ghangz ghangz commented Jul 1, 2026

Copy link
Copy Markdown

Summary

  • Adds a focused sglang runtime path audit 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 tools/maca_runtime_path_audit.py --self-test
  • Pull request text is intentionally ASCII-only to avoid encoding issues on web forms and API clients.

Review notes

  • Source branch: ghangz:mengz/sglang-runtime-path-audit
  • 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 introduces a new Python script, tools/maca_runtime_path_audit.py, designed to audit MACA-related environment path variables for duplicate or non-existent entries. Feedback on the implementation suggests fully normalizing paths (resolving relative paths and expanding user directories) to ensure robust duplicate detection, avoiding redundant existence checks for duplicate paths, and replacing the assert statement in the self-test with an explicit conditional check to prevent it from being optimized away in production environments.

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.

Comment thread tools/maca_runtime_path_audit.py Outdated
Comment on lines +28 to +33
normalized = str(Path(raw))
if normalized in seen:
findings.append({"env": name, "path": raw, "severity": "warning", "message": "duplicate path entry"})
seen.add(normalized)
if not Path(raw).exists():
findings.append({"env": name, "path": raw, "severity": "info", "message": "path does not exist in this container"})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using str(Path(raw)) does not resolve relative paths to absolute paths, nor does it expand user directories (e.g., ~). This can cause duplicate detection to fail if the same path is specified in different formats (e.g., relative vs. absolute, or with/without ~). Normalizing paths using os.path.abspath(os.path.expanduser(raw)) ensures robust duplicate detection.\n\nAdditionally, checking path existence for duplicate entries results in redundant "path does not exist" findings for the same path. We should only perform the existence check for unique paths.

            normalized = os.path.abspath(os.path.expanduser(raw))\n            if normalized in seen:\n                findings.append({\"env\": name, \"path\": raw, \"severity\": \"warning\", \"message\": \"duplicate path entry\"})\n            else:\n                seen.add(normalized)\n                if not Path(raw).exists():\n                    findings.append({\"env\": name, \"path\": raw, \"severity\": \"info\", \"message\": \"path does not exist in this container\"})
References
  1. Paths should be fully normalized (absolute and user-expanded) before duplicate checking to avoid missing duplicates represented in different formats.

Comment thread tools/maca_runtime_path_audit.py Outdated
Comment on lines +40 to +41
assert data["finding_count"] >= 2
print(json.dumps({"ok": True, "finding_count": data["finding_count"]}, ensure_ascii=False))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using assert statements for validation or control flow is discouraged in production-bound scripts because assertions are removed when Python is run with optimization flags (e.g., python -O). If this script is executed with optimization enabled, the self-test will silently pass even if no findings are detected. It is safer to use an explicit conditional check and raise an exception.

    if data[\"finding_count\"] < 2:\n        raise RuntimeError(f\"Self-test failed: expected at least 2 findings, got {data['finding_count']}\")\n    print(json.dumps({\"ok\": True, \"finding_count\": data[\"finding_count\"]}, ensure_ascii=False))
References
  1. Do not use assert statements for runtime validation or self-tests in production-bound code, as they can be compiled away with optimization flags.

- Add SGLang MACA runtime path audit
- Normalize MACA runtime path audit entries
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