PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
# Reusable AI-failure-analysis stages shared across pipelines (CPU, XPU, ...).
# Split into two stages because a job condition cannot read a previous stage's
# overall result (`stageDependencies.<stage>` only exposes per-job nodes, so
# `stageDependencies.<stage>.result` is a dictionary miss -> Null). A stage-level
# condition can check previous stage results (failed()/succeeded()), so we branch there instead.
parameters:
# A single stage name or a list of stage names (e.g. the per-part CUDA stages).
- name: dependsOn
type: object
default: "Unit_test"
- name: stageName
type: string
default: "AI_Analysis"
- name: enableAiAnalysis
type: boolean
default: true
- name: postComment
type: boolean
default: true
- name: topUnknown
type: number
default: 3
- name: knownIssueLabel
type: string
default: "CI-known-issue"
stages:
- stage: ${{ parameters.stageName }}
displayName: "AI Failure Analysis"
pool:
vmImage: "ubuntu-latest"
dependsOn: ${{ parameters.dependsOn }}
# failed() with no arguments checks the direct dependencies listed in dependsOn.
condition: and(failed(), eq(variables['System.StageAttempt'], '1'))
variables:
- group: "auto-round-bot-secrets"
jobs:
- job: AnalyzeFailures
displayName: "Analyze failed unit tests"
timeoutInMinutes: 90
variables:
base: $(Build.SourcesDirectory)
output_dir: $(Build.SourcesDirectory)/ai_analysis_results
scripts: $(Build.SourcesDirectory)/.azure-pipelines/scripts/ai_analysis
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "3.12"
displayName: "Use Python 3.12"
- task: DownloadPipelineArtifact@2
inputs:
artifact:
patterns: "ut-*-1/unittest_*"
path: $(output_dir)/failed_logs
displayName: "Download failed-log artifacts"
- task: Bash@3
displayName: "Cluster failures"
inputs:
targetType: "inline"
script: |
set -eo pipefail
python "$(scripts)/analyze_failures.py" \
--input-dir "$(output_dir)/failed_logs" \
--clusters-json "$(output_dir)/clusters.json" \
--decision-log "$(output_dir)/decision_log.md"
echo "Cluster analysis completed. Results are in $(output_dir)/clusters.json"
cat "$(output_dir)/clusters.json"
- task: Bash@3
displayName: "Match known issues"
env:
AUTO_ROUND_BOT_TOKEN: $(AUTO_ROUND_BOT_TOKEN)
inputs:
targetType: "inline"
script: |
set -eo pipefail
repo_path="${BUILD_REPOSITORY_URI#https://github.com/}"
repo_path="${repo_path%.git}"
python "$(scripts)/match_known_issues.py" \
--clusters-json "$(output_dir)/clusters.json" \
--output "$(output_dir)/annotated.json" \
--repo "${repo_path}" \
--label "${{ parameters.knownIssueLabel }}"
echo "Matching known issues completed. Results are in $(output_dir)/annotated.json"
cat "$(output_dir)/annotated.json"
- task: Bash@3
displayName: "AI analysis of top unknown failures"
continueOnError: true
env:
AI_TOKEN: $(AI_TOKEN)
inputs:
targetType: "inline"
script: |
set -uo pipefail
if [ "${{ parameters.enableAiAnalysis }}" = "True" ]; then
echo "Installing Copilot CLI for AI analysis..."
curl -fsSL https://gh.io/copilot-install | bash
export PATH="$HOME/.local/bin:$PATH"
fi
python "$(scripts)/ai_analyze.py" \
--clusters-json "$(output_dir)/annotated.json" \
--output "$(output_dir)/ai.json" \
--pr-sha "$(Build.SourceVersion)" \
--top ${{ parameters.topUnknown }} \
--enable-ai-analysis ${{ parameters.enableAiAnalysis }} \
--backend copilot \
--model gpt-5.6-luna \
--reasoning-effort max \
--escalation-model claude-opus-5.5 \
--escalation-reasoning-effort high \
--trace-file "$(output_dir)/ai_trace.jsonl" \
--project-root "$(base)" \
--log-dir "$(output_dir)/failed_logs"
echo "AI analysis completed. Results are in $(output_dir)/ai.json"
cat "$(output_dir)/ai.json"
- task: Bash@3
displayName: "Merge markdown report"
env:
BUILD_DEFINITIONNAME: $(Build.DefinitionName)
PR_NUMBER: $(System.PullRequest.PullRequestNumber)
CURRENT_SHA: $(Build.SourceVersion)
RUN_URL: $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)
inputs:
targetType: "inline"
script: |
set -eo pipefail
python "$(scripts)/merge_reports.py" \
--clusters-json "$(output_dir)/annotated.json" \
--ai-json "$(output_dir)/ai.json" \
--output "$(output_dir)/report.md"
- ${{ if eq(parameters.postComment, true) }}:
- task: Bash@3
displayName: "Post report as PR comment"
condition: eq(variables['Build.Reason'], 'PullRequest')
env:
AUTO_ROUND_BOT_TOKEN: $(AUTO_ROUND_BOT_TOKEN)
inputs:
targetType: "inline"
script: |
set -uo pipefail
repo_path="${BUILD_REPOSITORY_URI#https://github.com/}"
repo_path="${repo_path%.git}"
python "$(scripts)/post_pr_comment.py" \
--repo "${repo_path}" \
--pr "${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-}" \
--marker-key "$(Build.DefinitionName)" \
--body-file "$(output_dir)/report.md"
- task: PublishPipelineArtifact@1
condition: always()
inputs:
targetPath: $(Build.SourcesDirectory)/ai_analysis_results
artifact: "ai-failure-analysis"
publishLocation: "pipeline"
displayName: "Publish AI failure-analysis report"
- stage: ${{ parameters.stageName }}_HideOutdated
displayName: "Hide AI Analysis Comments"
pool:
vmImage: "ubuntu-latest"
dependsOn: ${{ parameters.dependsOn }}
# succeeded() with no arguments checks the direct dependencies listed in dependsOn.
condition: succeeded()
variables:
- group: "auto-round-bot-secrets"
jobs:
- job: HideComments
displayName: "Hide AI Analysis Comments"
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "3.12"
displayName: "Use Python 3.12"
- task: Bash@3
displayName: "Hide outdated AI analysis comment"
condition: eq(variables['Build.Reason'], 'PullRequest')
env:
AUTO_ROUND_BOT_TOKEN: $(AUTO_ROUND_BOT_TOKEN)
inputs:
targetType: "inline"
script: |
set -uo pipefail
base="$(Build.SourcesDirectory)"
scripts="${base}/.azure-pipelines/scripts/ai_analysis"
repo_path="${BUILD_REPOSITORY_URI#https://github.com/}"
repo_path="${repo_path%.git}"
python "${scripts}/post_pr_comment.py" \
--repo "${repo_path}" \
--pr "${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-}" \
--marker-key "$(Build.DefinitionName)" \
--hide