PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
Enhance CI workflow (#1858)
chen, suyue87c22224706b
diff --git a/.azure-pipelines/scripts/check_cuda_trigger.py b/.azure-pipelines/scripts/check_cuda_trigger.pynew file mode 100644index 000000000..19e053ea4--- /dev/null+++ b/.azure-pipelines/scripts/check_cuda_trigger.py@@ -0,0 +1,77 @@+import json+import os+import sys+from urllib.request import Request, urlopen+++def main():+ repo_path = os.environ.get("REPO_PATH", "")+ pr_number_str = os.environ.get("PR_NUMBER", "")+ sha = os.environ.get("CURRENT_SHA", "")+ token = os.environ.get("GITHUB_TOKEN", "")++ if not repo_path or "/" not in repo_path or not pr_number_str:+ print("Missing required environment variables (REPO_PATH, PR_NUMBER).", file=sys.stderr)+ sys.exit(1)++ owner, name = repo_path.split("/")+ pr = int(pr_number_str)++ query = """+ query($owner: String!, $name: String!, $pr: Int!) {+ repository(owner: $owner, name: $name) {+ pullRequest(number: $pr) {+ timelineItems(last: 50, itemTypes: [ISSUE_COMMENT, PULL_REQUEST_COMMIT]) {+ nodes {+ __typename+ ... on IssueComment {+ body+ }+ ... on PullRequestCommit {+ commit {+ oid+ }+ }+ }+ }+ }+ }+ }+ """++ req = Request(+ "https://api.github.com/graphql",+ data=json.dumps({"query": query, "variables": {"owner": owner, "name": name, "pr": pr}}).encode("utf-8"),+ headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},+ )++ try:+ with urlopen(req) as resp:+ data = json.loads(resp.read().decode("utf-8"))+ nodes = data["data"]["repository"]["pullRequest"]["timelineItems"]["nodes"]+ except Exception as e:+ print("GraphQL Error:", e, file=sys.stderr)+ sys.exit(1)++ target = "/azp run Unit-Test-CUDA-AutoRound"++ # Traverse nodes in reverse (from newest to oldest)+ for node in reversed(nodes):+ if node.get("__typename") == "IssueComment":+ if target in node.get("body", ""):+ # Target comment found before we reached the current commit.+ # It means a comment has already been posted to trigger CI for this commit state.+ sys.exit(0)+ elif node.get("__typename") == "PullRequestCommit":+ if node.get("commit", {}).get("oid") == sha:+ # We reached the tip commit of this trigger before finding any trigger comment.+ # Therefore, we need to post a new comment to trigger CI.+ break++ # Exit 1 means we break the loop (commit reached) without calling sys.exit(0)+ # The bash script catching exit 1 means "proceed to post the comment".+ sys.exit(1)+++if __name__ == "__main__":+ main()diff --git a/.azure-pipelines/scripts/ut/run_ut.sh b/.azure-pipelines/scripts/ut/run_ut.shindex c54f63d94..b4dbb261e 100644--- a/.azure-pipelines/scripts/ut/run_ut.sh+++ b/.azure-pipelines/scripts/ut/run_ut.sh@@ -55,10 +55,10 @@ function print_summary() {function check_storage_usage() {echo "##[group]check storage usage..."df -h- du -sh /auto-round- du -sh /home/hostuser/.cache/huggingface- du -sh /home/hostuser/.cache/huggingface/hub/*- du -sh /home/hostuser/.venv+ du -sh /auto-round || true+ du -sh /home/hostuser/.cache/huggingface || true+ du -sh /home/hostuser/.cache/huggingface/hub/* || true+ du -sh /home/hostuser/.venv || trueecho "##[endgroup]"}diff --git a/.azure-pipelines/unit-test-cuda.yml b/.azure-pipelines/unit-test-cuda.ymlindex 83deed2fb..be97904ff 100644--- a/.azure-pipelines/unit-test-cuda.yml+++ b/.azure-pipelines/unit-test-cuda.yml@@ -155,13 +155,6 @@ stages:fidisplayName: "Run GPU Tests"- - task: PublishPipelineArtifact@1- condition: succeededOrFailed()- inputs:- targetPath: $(Build.SourcesDirectory)/ut_log_dir- artifact: PART_${{ pair.value.PART }}_logs- publishLocation: "pipeline"-- script: |cd .azure-pipelines/scripts/cuda_unit_testuv run monitor_gpu.py stopdiff --git a/.azure-pipelines/unit-test.yml b/.azure-pipelines/unit-test.ymlindex 7e0735ba2..c404ffc8c 100644--- a/.azure-pipelines/unit-test.yml+++ b/.azure-pipelines/unit-test.yml@@ -121,3 +121,52 @@ stages:- task: PublishCodeCoverageResults@2inputs:summaryFileLocation: $(Build.SourcesDirectory)/log_dir/coverage_PR/coverage.xml++ - stage: Trigger_CUDA_CI+ displayName: "Trigger CUDA CI"+ pool:+ vmImage: "ubuntu-latest"+ dependsOn: [Coverage]+ condition: and(succeeded('Coverage'), eq(variables['Build.Reason'], 'PullRequest'))+ jobs:+ - job: CommentCudaTrigger+ displayName: "Comment to trigger CUDA CI"+ steps:+ - task: Bash@3+ displayName: "Post /azp run comment to PR"+ env:+ GITHUB_TOKEN: $(GITHUB_TOKEN)+ inputs:+ targetType: "inline"+ script: |+ set -euo pipefail++ pr_number="${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-}"+ if [ -z "${pr_number}" ]; then+ echo "PR number not found."+ exit 0+ fi++ repo_path="${BUILD_REPOSITORY_URI#https://github.com/}"+ repo_path="${repo_path%.git}"+ export REPO_PATH="${repo_path}"+ export PR_NUMBER="${pr_number}"+ export CURRENT_SHA="${SYSTEM_PULLREQUEST_SOURCECOMMITID:-${BUILD_SOURCEVERSION:-unknown}}"++ if python "$(Build.SourcesDirectory)/.azure-pipelines/scripts/check_cuda_trigger.py"; then+ echo "CUDA CI already triggered after commit ${CURRENT_SHA}. Skipping."+ exit 0+ fi++ echo "Triggering CUDA CI for commit ${CURRENT_SHA}..."+ if ! curl -fsS -X POST \+ -H "Authorization: Bearer ${GITHUB_TOKEN}" \+ -H "Accept: application/vnd.github+json" \+ -H "Content-Type: application/json" \+ -d '{"body":"/azp run Unit-Test-CUDA-AutoRound"}' \+ "https://api.github.com/repos/${repo_path}/issues/${pr_number}/comments"; then+ echo "Failed to post CUDA trigger comment (non-blocking)."+ exit 0+ fi++ echo "CUDA trigger comment posted to PR #${pr_number}."