Skip to content

fix(ci): isolate multi-node cache path and k8s job per run+version - #607

Open
EdwardXuy wants to merge 4 commits into
sgl-project:mainfrom
EdwardXuy:fix/multi-node-cache-isolation
Open

fix(ci): isolate multi-node cache path and k8s job per run+version#607
EdwardXuy wants to merge 4 commits into
sgl-project:mainfrom
EdwardXuy:fix/multi-node-cache-isolation

Conversation

@EdwardXuy

Copy link
Copy Markdown
Contributor

Problem

The A2 multi-node pipeline frequently fails on PR-triggered runs with:

cp: cannot create regular file '/root/.cache/tests/sglang/CMakeLists.txt': File exists
cp: cannot create regular file '/root/.cache/tests/sglang/README.md': File exists

This causes the 9.0.0 matrix job to fail in the "Prepare scripts" step within ~2.5 minutes, while the 8.5.0 job (which runs first due to max-parallel: 1) succeeds.

Root Cause

All matrix jobs (8.5.0, 9.0.0) and concurrent PRs share:

  1. The same fixed cache path /root/.cache/tests/sglang on a shared PVC (sgl-project-sglang-hk001)
  2. The same fixed k8s Volcano Job name "sglang-npu-multi"

When the previous job's test pods are still terminating (Volcano Job deletion is async) or the PVC has filesystem sync latency, the next job's cp -r hits residual files and fails with "File exists".

Additionally, rm -rf /* does not match dotfiles (.gitmodules, .github), so hidden file residue is never cleaned.

Why daily-build-test.yml is not affected

The daily pipeline has needs: [run-daily-tests, run-pr-tests] before multi-node-internode, which adds a 5-7 hour delay. By the time multi-node runs, the previous day's pods have fully terminated and the PVC has synced. The PR-triggered a2-internode-test.yml has no such delay, so it hits the race.

Fix (internode.yml only)

  1. Unique cache path: /root/.cache/tests/sglang/{GITHUB_RUN_ID}_{CANN_VERSION} - each job writes to its own directory on the shared PVC.
  2. Unique k8s job name: sglang-npu-multi-{CANN_VERSION} - kubectl delete -f only affects this job's resources.
  3. Reliable cleanup: rm -rf "" on the unique directory (instead of rm -rf /* which misses dotfiles and races on PVC sync).
  4. Copy hidden files: cp .../* does not match dotfiles; added a loop to copy .gitmodules, .github, etc.
  5. PVC space reclamation: Clean up the job directory in Post process.

Compatibility

  • No change to workflow inputs/outputs, so daily-build-test.yml and a2-internode-test.yml callers are unaffected.
  • daily-build-test.yml also benefits: its two matrix entries are now fully isolated (previously masked by the 5-7h needs delay).
  • a2-internode-test.yml needs no change: it only calls internode.yml with matrix params; the isolation is handled internally.

Testing

Triggering a PR that runs a2-internode-test.yml should now succeed for both 8.5.0 and 9.0.0 even when:

  • The previous PR's multi-node job is still cleaning up
  • Two PRs are tested concurrently

PR-triggered A2 multi-node pipeline frequently fails with:
  cp: cannot create regular file '/root/.cache/tests/sglang/CMakeLists.txt': File exists

Root cause: all matrix jobs (8.5.0, 9.0.0) and concurrent PRs share the
same fixed path /root/.cache/tests/sglang on a shared PVC, and the same
fixed k8s Volcano Job name sglang-npu-multi. When the previous job's
test pods are still terminating or the PVC has sync latency, the next
job's cp -r hits residual files and fails.

Fix in internode.yml:
- Derive unique cache path /root/.cache/tests/sglang/{RUN_ID}_{CANN_VERSION}
- Derive unique k8s job name sglang-npu-multi-{CANN_VERSION}
- Replace rm -rf path/* (misses dotfiles, races on PVC sync) with rm -rf path
- Copy hidden files (.gitmodules, .github) that cp .../* skips
- Clean up the job PVC directory in Post process

No change to workflow inputs/outputs, so daily-build-test.yml and
a2-internode-test.yml callers are unaffected. The daily pipeline also
benefits from this isolation (previously masked by the 5-7h needs delay).
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

…isolation)

Previous commit (6690cc7) tried to isolate PVC path per run+version by
creating subdirectory /root/.cache/tests/sglang/<run_id>_<cann_version>.
This broke: runner container's /root/.cache/tests/sglang is a dedicated
mount point (subPath) on the shared PVC, while the test pod mounts the
entire PVC at /root/.cache. Files written to the subdirectory land on
the runner's local view but are NOT visible to the test pod, causing:
  ERROR: Script not found at .../29888246254_8.5.0/tests/python/deepep/run_ascend_testcase.sh

Revert to the fixed path /root/.cache/tests/sglang (which both runner
and test pod share correctly) and solve the original "cp: File exists"
race differently:

1. concurrency: drop github.ref from group -> all multi-node runs for
   the same soc_version serialize globally (cross-PR). Set
   cancel-in-progress: false so an in-progress test is not interrupted
   (scarce NPU resources should not be wasted on partial runs).

2. rm -rf "$sglang_source_path" (whole dir) instead of rm -rf $path/*
   to also clear leftover dotfiles that caused stale-state issues.

Result: no two multi-node jobs write the shared path simultaneously,
and each job starts from a clean directory. Daily pipeline is unaffected
(it calls internode.yml with the same soc_version and will simply queue
behind a PR run if one is active, which is acceptable).
Previous commits tried two approaches that both failed:

1. Path isolation in internode.yml (6690cc7): Created subdirectory
   /root/.cache/tests/sglang/<run_id>_<cann_version>. FAILED because
   runner container mounts /root/.cache/tests/sglang as a subPath,
   while test pod mounts the entire PVC at /root/.cache. Files in
   the subdirectory are invisible to the test pod:
   "ERROR: Script not found at .../run_ascend_testcase.sh"

2. Global concurrency in internode.yml (f020473): Changed concurrency
   group to ascend-nightly-multi-node-${{ inputs.soc_version }}.
   FAILED because concurrency in a reusable (called) workflow does NOT
   serialize across different caller runs. Evidence: run 29896822833
   (different PR) and run 29897327319 (this PR) both executed
   multi-node jobs simultaneously, causing:
   "rm: cannot remove '/root/.cache/tests/sglang': Directory not empty"

Root cause confirmed via GitHub docs and community: "You need to apply
the concurrency setting to the CALLER workflow, not the reusable
workflow itself."

Fix:
- Revert internode.yml to original (no changes from main).
- Change a2-internode-test.yml concurrency:
  - group: a2-internode-test (was: a2-internode-test-${{ github.ref }}-${{ github.event_name }})
    Removes github.ref so ALL PR runs share one global group and serialize.
  - cancel-in-progress: false (was: true)
    Don't interrupt in-progress multi-node tests (scarce NPU resources).

Daily pipeline (daily-build-test.yml) is unaffected: it calls
internode.yml directly, not a2-internode-test.yml, and runs once daily
with a 5-7h delay from prerequisite jobs.
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