Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

3.8 KB
Raw Blame
trigger: none

pr:
  autoCancel: true
  drafts: false
  branches:
    include:
      - main
      - "*rc"
  paths:
    include:
      - auto_round
      - auto_round_extension
      - test/unit/test_ark
      - test/unit/test_xpu
      - test/unit/common
      - setup.py
      - .azure-pipelines/template/ut-template.yml
      - .azure-pipelines/unit-test-xpu.yml
      - .azure-pipelines/scripts/ut/run_ut_xpu.sh
      - .azure-pipelines/scripts/ut/detect_changed_tests.sh
      - .azure-pipelines/docker/xpu.dockerfile
      - .azure-pipelines/build-auto-round-lib.yml
      - .azure-pipelines/template/lib-build-template.yml
    exclude:
      - "*.md"
      - "**/*.md"

# use XPU BMG B60 agent pool to run unit tests
pool: B60

variables:
  IMAGE_NAME: "auto-round"
  IMAGE_TAG: "py314-xpu"
  DOCKERFILE_NAME: "xpu.dockerfile"
  UPLOAD_PATH: $(Build.SourcesDirectory)/log_dir
  DOWNLOAD_PATH: $(Build.SourcesDirectory)/log_dir
  ARTIFACT_NAME: "UT_coverage_report"
  REPO: $(Build.Repository.Uri)

parameters:
  - name: unitTestParts
    type: object
    default:
      - common
      - base

stages:
  - template: template/lib-build-template.yml
    parameters:
      enableChangeDetection: true
      publishToTestPyPI: false

  - stage: Unit_test
    displayName: Unit Test
    dependsOn: [DetectArkChanges, BuildArkWheel]
    condition: and(succeeded('DetectArkChanges'), in(dependencies.BuildArkWheel.result, 'Succeeded', 'Skipped'))
    variables:
      BUILD_ARK_WHEEL: $[ stageDependencies.DetectArkChanges.Detect.outputs['SetArkWheelFlag.BUILD_ARK_WHEEL'] ]
    jobs:
      - job:
        timeoutInMinutes: 60
        strategy:
          matrix:
            ${{ each part in parameters.unitTestParts }}:
              part_${{ part }}:
                PART: ${{ part }}
        steps:
          - template: template/ut-template.yml
            parameters:
              utScriptFileName: "run_ut_xpu"
              uploadPath: $(UPLOAD_PATH)
              utArtifact: "ut-$(PART)"
              utTestMode: $(PART)
              imageTag: $(IMAGE_TAG)
              dockerFileName: $(DOCKERFILE_NAME)
              utContainerName: "AutoRoundUnitTest$(NODE_LABEL)"
              buildARKWheel: $(BUILD_ARK_WHEEL)
              filterChangedTests: true

  - template: template/ai-stage-template.yml
    parameters:
      dependsOn: "Unit_test"
      enableAiAnalysis: true
      postComment: true

  - stage: Coverage
    displayName: "Collect Coverage"
    pool:
      vmImage: "ubuntu-latest"
    dependsOn: [Unit_test]
    jobs:
      - job: CollectDatafiles
        steps:
          - task: DownloadPipelineArtifact@2
            inputs:
              artifact:
              patterns: '*_coverage/.coverage.*'
              path: $(DOWNLOAD_PATH)

          - task: UsePythonVersion@0
            inputs:
              versionSpec: '3.14'
            displayName: 'Use Python 3.14'

          - script: |
              cd ${BUILD_SOURCESDIRECTORY}
              pip install -U pip setuptools uv
              uv pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/xpu
              uv pip install .
              pip list
              cd ${BUILD_SOURCESDIRECTORY}/.azure-pipelines/scripts
              bash ut/collect_log.sh xpu
            env:
              PYTHONUNBUFFERED: '1'
              UV_NO_PROGRESS: '1'
              UV_SYSTEM_PYTHON: '1'
            displayName: "Collect UT Coverage"

          - task: PublishPipelineArtifact@1
            condition: succeededOrFailed()
            inputs:
              targetPath: $(UPLOAD_PATH)/coverage_PR
              artifact: $(ARTIFACT_NAME)
              publishLocation: "pipeline"

          - task: PublishCodeCoverageResults@2
            inputs:
              summaryFileLocation: $(Build.SourcesDirectory)/log_dir/coverage_PR/coverage.xml