Skip to content

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

3.8 KB
Raw Blame
# Nightly pipeline: runs the slower CPU integration + e2e suites that are
# excluded from the fast PR unit-test pipeline. Scheduled daily; can also be
# triggered manually from the Azure DevOps UI.

trigger: none
pr:
  autoCancel: true
  drafts: false
  branches:
    include:
      - main
      - "*rc"
  paths:
    include:
      - test/integration/test_cpu
      - .azure-pipelines/nightly-test-cpu.yml
      - .azure-pipelines/scripts/ut/detect_changed_tests.sh

parameters:
  - name: unitTestParts
    type: object
    default:
      - 0
      - 1
      - 2
      - inc
      - llmc

schedules:
  - cron: "0 18 * * *"   # 02:00 Asia/Shanghai every day
    displayName: Daily nightly run
    branches:
      include:
        - main
    always: true

pool: INTEL-CPU

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

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

  - 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:
            # PR-triggered runs only cover inc/llmc; the 0-4 parts duplicate the fast PR unit-test pipeline.
            ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
              part_inc:
                PART: inc
              part_llmc:
                PART: llmc
            ${{ else }}:
              ${{ each part in parameters.unitTestParts }}:
                part_${{ part }}:
                  PART: ${{ part }}
        steps:
          - template: template/ut-template.yml
            parameters:
              utScriptFileName: "run_ut"
              uploadPath: $(UPLOAD_PATH)
              utArtifact: "ut-$(PART)"
              utTestMode: $(PART)
              utContainerName: "AutoRoundUnitTest$(NODE_LABEL)"
              buildARKWheel: $(BUILD_ARK_WHEEL)
              filterChangedTests: true

  - stage: Coverage
    displayName: "Collect Coverage"
    pool:
      vmImage: "ubuntu-latest"
    dependsOn: [Unit_test]
    condition: and(succeeded('Unit_test'), ne(variables['Build.Reason'], 'PullRequest'))
    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/cpu
              uv pip install .
              pip list
              cd ${BUILD_SOURCESDIRECTORY}/.azure-pipelines/scripts
              bash ut/collect_log.sh cpu
            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