#!/usr/bin/env bash set -euo pipefail root=${1:?Pass the source/work/publish parent directory} mode=${2:-build} case "$mode" in build|publish) ;; *) exit 2 ;; esac source_dir="$root/source" release="$root/publish" python="$root/work/venv/bin/python" scripts="$release/reproduction/scripts" converter="$release/reproduction/converter" manifests="$release/reproduction/manifests" plan="$manifests/swift/ssd-ple-q5" variant=MQ-Q5-SSD-PLE-BF16 main="$release/$variant" # Conversion is CPU-only and keeps source tensors mmap-backed. export CUDA_VISIBLE_DEVICES= export OMP_NUM_THREADS=8 export QWEN4EXP_QUANT_THREADS=16 export DS4_QUANTS_LIBRARY="$root/work/libds4quants.so" export HF_XET_CHUNK_CACHE_SIZE_BYTES=0 "$python" - "$source_dir" "$manifests/swift/source-files.json" <<'PY' import json, sys from pathlib import Path root = Path(sys.argv[1]) files = json.loads(Path(sys.argv[2]).read_text())["files"] for row in files: path = root / row["rfilename"] if not path.is_file() or path.stat().st_size != row["size"]: raise SystemExit(f"source missing or truncated: {path}") print(f"Source inventory: {len(files)} complete files", flush=True) PY hf cache verify ukisai/Swift1.5-Qwen3.8-Flash-Next \ --revision 0bd4fe22431372cdad1979267d3ab45aa7e6150a \ --local-dir "$source_dir" --format json \ > "$manifests/swift/verify-source-files.json" "$python" "$scripts/verify_source_topology.py" \ --model-dir "$source_dir" --source-map "$manifests/swift/recipe-base-source-map.json" \ --out "$manifests/swift/verify-source-topology.json" "$python" "$converter/build_ssd_ple_manifests.py" \ --source-map "$manifests/swift/recipe-base-source-map.json" \ --model-dir "$source_dir" --out-dir "$plan" "$python" "$scripts/verify_recipe_equivalence.py" \ --reference "$manifests/reference/q5-main-gguf-source-map.json" \ --candidate "$plan/main-gguf-source-map.json" --out "$plan/verify-recipe-equivalence.json" "$python" "$scripts/verify_ple_plan_equivalence.py" \ --reference "$manifests/reference/ple-manifest.plan.json" \ --candidate "$plan/ple-manifest.plan.json" --out "$plan/verify-ple-plan-equivalence.json" "$python" "$scripts/verify_ple_identity.py" \ --model-dir "$source_dir" --reference "$manifests/reference/bf16-ple-manifest.json" \ --reference-files "$manifests/reference/base-source-info.json" \ --candidate-files "$manifests/swift/upstream-source-info.json" \ --out "$manifests/swift/verify-ple-identity.json" # PLE-FP8 is copied from the local Qwen model only after complete identity proof. test -f "$release/PLE-FP8/ple-manifest.json" (cd "$release/PLE-FP8" && sha256sum -c SHA256SUMS) cc -O3 -fPIC -shared -std=c11 "$release/ds4/gguf-tools/quants.c" \ -o "$DS4_QUANTS_LIBRARY" -lm -pthread mkdir -p "$main" "$python" "$converter/convert_qwen4exp_gguf.py" \ --model-dir "$source_dir" --source-map "$plan/main-gguf-source-map.json" \ --variant "$variant" --out "$main/Swift1.5-Qwen3.8-Flash-Next-$variant.gguf" \ --artifact-manifest "$main/main-artifact-manifest.json" \ --split-max-size-gib 30 --hash-output --sha256sums "$main/SHA256SUMS.main" "$python" "$scripts/verify_gguf_structure.py" "$main"/*.gguf \ --source-map "$plan/main-gguf-source-map.json" --variant "$variant" \ --out "$main/verify-main-gguf.json" "$python" "$scripts/hash_artifacts.py" "$main"/*.gguf \ --sha256sums "$main/SHA256SUMS.independent-main" --json "$main/hashes-independent-main.json" "$python" "$scripts/hash_artifacts.py" "$release/PLE-FP8"/ple-fp8-*.bin \ "$release/PLE-FP8/ple-manifest.json" --sha256sums "$release/PLE-FP8/SHA256SUMS" \ --json "$release/PLE-FP8/hashes-independent.json" "$python" "$scripts/build_release_manifest.py" \ --main-hashes "$main/hashes-independent-main.json" \ --ple-hashes "$release/PLE-FP8/hashes-independent.json" \ --main-structure "$main/verify-main-gguf.json" \ --ple-report "$manifests/swift/verify-ple-identity.json" \ --recipe-report "$plan/verify-recipe-equivalence.json" \ --ple-plan-report "$plan/verify-ple-plan-equivalence.json" \ --source-report "$manifests/swift/verify-source-topology.json" \ --sha256sums "$release/SHA256SUMS" --out "$release/artifact-manifest.json" "$python" "$scripts/write_card.py" "$release" if [[ "$mode" == publish ]]; then hf repos create Baekpica/Swift1.5-Qwen3.8-Flash-Next-Mixed-Quant-GGUF \ --public --exist-ok hf repos settings Baekpica/Swift1.5-Qwen3.8-Flash-Next-Mixed-Quant-GGUF --public hf upload Baekpica/Swift1.5-Qwen3.8-Flash-Next-Mixed-Quant-GGUF "$release" . \ --exclude '.git/**' --exclude '.gitignore' --exclude '**/__pycache__/**' \ --exclude '*.so' --commit-message 'Publish Swift1.5 Q5 with FP8 PLE' \ --format json > "$root/work/upload.json" "$python" "$scripts/verify_publication.py" "$release" \ --out "$root/work/remote-verification.json" cp "$root/work/remote-verification.json" "$release/remote-verification.json" "$python" - "$release" <<'PY' import json, sys from pathlib import Path root = Path(sys.argv[1]) receipt = json.loads((root / "remote-verification.json").read_text()) path = root / "artifact-manifest.json" artifact = json.loads(path.read_text()) artifact["verification"]["remote_lfs"] = "passed_sha256_and_bytes_7_of_7" artifact["remote_verification"] = { "status": "all_staged_files_verified_at_public_revision", "resolved_revision": receipt["resolved_revision"], "verified_files": receipt["verified_files"], "receipt": "remote-verification.json", } path.write_text(json.dumps(artifact, indent=2, sort_keys=True) + "\n") PY "$python" "$scripts/write_card.py" "$release" hf upload Baekpica/Swift1.5-Qwen3.8-Flash-Next-Mixed-Quant-GGUF "$release" . \ --include README.md --include artifact-manifest.json --include remote-verification.json \ --include "$variant/quant-recipe.yaml" \ --commit-message 'Record public artifact verification' \ --format json > "$root/work/verification-upload.json" "$python" "$scripts/verify_publication.py" "$release" \ --out "$root/work/remote-verification-final.json" fi