-
Notifications
You must be signed in to change notification settings - Fork 293
[PowerX] separate native multinode collector contract / 拆分原生多节点采集契约 #3051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c304072
fix: preserve complete request outcomes and diagnostic batches
edwingao28 ba0275c
feat: separate native multinode power collection contract
edwingao28 f691e7e
fix: retain per-window SMI context artifacts
edwingao28 b230e70
fix: preserve native role metrics and abort receipts
edwingao28 880f115
ci: run native collector contract regressions
edwingao28 654c33b
test: synchronize shared replay signal readiness
edwingao28 bc8684e
chore: sync request outcome contract with current main
edwingao28 54a64c9
chore: inherit current main through outcome prerequisite
edwingao28 d141e71
fix: preserve diagnostic sidecars and legacy result processing
edwingao28 8b49ebe
fix: inherit diagnostic and historical result compatibility
edwingao28 8408779
test: preserve existing result test section formatting
edwingao28 6ed8f8b
fix: validate native role counts and retain boundary sample audits
edwingao28 85384dd
fix: validate native collector readiness and identity completion
edwingao28 66a2a05
chore: sync native power collector with main
edwingao28 583c388
fix: confine native telemetry setup to its collector
edwingao28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
| # One native SMI collector per serving node. Raw files stay on node-local scratch; | ||
| # the launcher stages them as its host user after containers stop. | ||
| set -uo pipefail | ||
| power_dir=$1 | ||
| control_dir=$2 | ||
| vendor=$3 | ||
| rank=$4 | ||
| role=$5 | ||
| gpu_indices=$6 | ||
| num_nodes=$7 | ||
| repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
| export TZ=UTC | ||
| export PYTHONPATH="$repo_root${PYTHONPATH:+:$PYTHONPATH}" | ||
| source "$repo_root/benchmarks/benchmark_lib.sh" | ||
| mkdir -p "$power_dir" | ||
| collector_rc=0 | ||
| finished=0 | ||
|
|
||
| write_control() { | ||
| local path="$control_dir/$1" | ||
| local pending="$path.tmp" | ||
| printf '%s\n' "$2" > "$pending" || return | ||
| # The control directory is created by the host user before Docker starts. | ||
| # Containers must not strand root-owned files in the shared runner tree. | ||
| if [[ -n "${POWERX_HOST_UID:-}" && -n "${POWERX_HOST_GID:-}" ]]; then | ||
| chown "$POWERX_HOST_UID:$POWERX_HOST_GID" "$pending" || return | ||
| fi | ||
| mv -f "$pending" "$path" | ||
| } | ||
|
|
||
| finish() { | ||
| local incoming_rc=$? | ||
| [[ "$finished" == 0 ]] || return | ||
| if [[ "$incoming_rc" != 0 ]]; then collector_rc=$incoming_rc; fi | ||
| if ! _background_process_is_running "${GPU_MONITOR_PID:-}"; then collector_rc=1; fi | ||
| stop_gpu_monitor | ||
| if [[ "$vendor" == amd ]]; then | ||
| amd-smi list --json > "$power_dir/gpu_metrics_devices_end.json" || collector_rc=1 | ||
| else | ||
| nvidia-smi --query-gpu=index,uuid,pci.bus_id,name,driver_version --format=csv \ | ||
| > "$power_dir/gpu_metrics_identity_end.csv" || collector_rc=1 | ||
| fi | ||
| python3 -m infx.results.power.native_multinode end --directory "$power_dir" \ | ||
| --collector-exit-code "$collector_rc" || collector_rc=1 | ||
| if [[ -n "${POWERX_HOST_UID:-}" && -n "${POWERX_HOST_GID:-}" ]]; then | ||
| chown -R "$POWERX_HOST_UID:$POWERX_HOST_GID" "$power_dir" || collector_rc=1 | ||
| fi | ||
| write_control "done-$rank" "$collector_rc" | ||
| finished=1 | ||
| } | ||
| trap finish EXIT | ||
| trap 'collector_rc=130; AMD_MONITOR_STOP_TIMEOUT_S=0; exit 130' INT | ||
| trap 'collector_rc=143; AMD_MONITOR_STOP_TIMEOUT_S=0; exit 143' TERM HUP | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| case "${POWERX_CLOCK_SYNCHRONIZED:-false}" in | ||
| yes|true) clock_synchronized=true ;; | ||
| *) clock_synchronized=false ;; | ||
| esac | ||
|
|
||
| python3 -m infx.results.power.native_multinode begin --directory "$power_dir" \ | ||
| --vendor "$vendor" --rank "$rank" --role "$role" --gpu-indices "$gpu_indices" \ | ||
| --num-nodes "$num_nodes" --clock-synchronized "$clock_synchronized" || exit 1 | ||
| printf '{"timestamp_timezone":"UTC"}\n' > "$power_dir/gpu_metrics_context.json" || exit 1 | ||
| start_gpu_monitor --output "$power_dir/gpu_metrics.csv" || exit 1 | ||
| [[ "$GPU_MONITOR_VENDOR" == "$vendor" ]] || exit 1 | ||
| if [[ "$vendor" == amd ]]; then | ||
| _write_amd_smi_sidecar "$power_dir/gpu_metrics_devices.json" list --json | ||
| fi | ||
| _background_process_is_running "$GPU_MONITOR_PID" || exit 1 | ||
| write_control "ready-$rank" ready | ||
| while [[ ! -f "$control_dir/stop" ]]; do | ||
| _background_process_is_running "$GPU_MONITOR_PID" || exit 1 | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| sleep 1 & | ||
| wait $! || true | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/usr/bin/env bash | ||
| # Shared barriers for native collectors. Launchers own host scratch and mounts. | ||
|
|
||
| powerx_start_collector() { | ||
| local power_dir="$1" control_dir="$2" vendor="$3" rank="$4" role="$5" gpus="$6" nodes="$7" | ||
| local indices | ||
| indices=$(seq -s, 0 "$((gpus - 1))") || return 1 | ||
| POWERX_CONTROL_DIR="$control_dir" | ||
| POWERX_NUM_NODES="$nodes" | ||
| bash "$(dirname "${BASH_SOURCE[0]}")/native_power_collect.sh" \ | ||
| "$power_dir" "$control_dir" "$vendor" "$rank" "$role" "$indices" "$nodes" & | ||
| POWERX_COLLECTOR_PID=$! | ||
| } | ||
|
|
||
| powerx_write_control() { | ||
| local path="$POWERX_CONTROL_DIR/$1" | ||
| local pending="$path.tmp" | ||
| printf '%s\n' "$2" > "$pending" || return | ||
| if [[ -n "${POWERX_HOST_UID:-}" && -n "${POWERX_HOST_GID:-}" ]]; then | ||
| chown "$POWERX_HOST_UID:$POWERX_HOST_GID" "$pending" || return | ||
| fi | ||
| mv -f "$pending" "$path" | ||
| } | ||
|
|
||
| powerx_wait_collectors() { | ||
| local phase="$1" deadline=$((SECONDS + ${POWERX_BARRIER_TIMEOUT_S:-60})) rank pending failed | ||
| while :; do | ||
| pending=0 | ||
| failed=0 | ||
| for ((rank=0; rank<POWERX_NUM_NODES; rank++)); do | ||
| if [[ "$phase" == ready && -f "$POWERX_CONTROL_DIR/done-$rank" ]]; then | ||
| echo "PowerX collector $rank stopped before benchmark readiness" >&2 | ||
| return 1 | ||
| fi | ||
| if [[ ! -f "$POWERX_CONTROL_DIR/$phase-$rank" ]]; then | ||
| pending=1 | ||
| elif [[ "$phase" == done && "$(cat "$POWERX_CONTROL_DIR/done-$rank")" != 0 ]]; then | ||
| failed=1 | ||
| fi | ||
| done | ||
| if [[ "$pending" == 0 ]]; then | ||
| [[ "$failed" == 0 ]] || echo "One or more PowerX collectors failed" >&2 | ||
| return "$failed" | ||
| fi | ||
| if (( SECONDS >= deadline )); then | ||
| echo "Timed out waiting for PowerX $phase receipts" >&2 | ||
| return 1 | ||
| fi | ||
| sleep 1 | ||
| done | ||
| } | ||
|
|
||
| powerx_stop_collectors() { | ||
| local rc=0 | ||
| powerx_write_control stop stop || rc=$? | ||
| powerx_wait_collectors done || rc=$? | ||
| powerx_reap_collector || rc=$? | ||
| return "$rc" | ||
| } | ||
|
|
||
| powerx_reap_collector() { | ||
| [[ -n "${POWERX_COLLECTOR_PID:-}" ]] || return 0 | ||
| local deadline=$((SECONDS + ${POWERX_BARRIER_TIMEOUT_S:-60})) rc=0 | ||
| while kill -0 "$POWERX_COLLECTOR_PID" 2>/dev/null; do | ||
| if (( SECONDS >= deadline )); then | ||
| kill -TERM "$POWERX_COLLECTOR_PID" 2>/dev/null || true | ||
| # The shared AMD monitor drains for three seconds before writing receipts. | ||
| local grace_deadline=$((SECONDS + 5)) | ||
| while kill -0 "$POWERX_COLLECTOR_PID" 2>/dev/null && (( SECONDS < grace_deadline )); do | ||
| sleep 1 | ||
| done | ||
| kill -KILL "$POWERX_COLLECTOR_PID" 2>/dev/null || true | ||
| rc=1 | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
| wait "$POWERX_COLLECTOR_PID" || rc=$? | ||
| POWERX_COLLECTOR_PID="" | ||
| return "$rc" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.