Communitygithub.com

wshobson/quantized-export

プロモートされたファインチューニング済みモデルを適切なデプロイ形式(マージ済みsafetensors、LoRA専用、imatrix付きGGUF、FP8)にエクスポートします。チェックポイントがプロモーションを通過した後、ターゲットデバイスに合わせた量子化形式を選択する場合、またはエクスポートされたモデルのスモークテストが失敗した場合に使用します。

quantized-export とは?

**Quantized Export** スキルは、`checkpoint-promotion` スキルによってプロモートされたチェックポイントを、様々なターゲットランタイムに適した形式にエクスポートし、その有効性を検証するための最終ステップです。このスキルの主な目的は、モデルが正しい形式でデプロイされ、エクスポート後も動作することを確認することにあります。対応プラットフォームは、vLLMやllama.cppなどの主要な推論エンジンを含む、幅広いデプロイ環境を網羅しています。スキルは、ハードウェアとデプロイ形状に基づく形式選択マップ(FP8、AWQ INT4、GGUF、NVFP4など)、特定のワークロード(長文脈、コード、数学)に対するオーバーライドルール、そしてエクスポートバグを発見するための必須スモークテストから構成されています。このスキルは、プロモートされたチェックポイントのみを入力とし、選択された形式のエクスポート成果物と、エクスポート前後の3~5個のゴールデン出力を比較するスモークテストの差分レポートを出力します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/wshobson/agents/tree/main/plugins/llm-finetuning/skills/quantized-export

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Quantized Export (量子化エクスポート)

checkpoint-promotion の後、PROMOTE 判定が渡される最終地点です。4段階のゲートを通過したチェックポイントでも、ターゲットランタイムに適した形式でエクスポートされ、エクスポート後も動作することを確認するまではデプロイされません。REJECT 判定はこのスキルに到達しません。エクスポートはプロモートされたチェックポイントからのみ開始されます。

入力: プロモートされたチェックポイント(またはLoRAアダプタ)と、ターゲットデプロイ面(GPUクラス、サービングスタック、長文脈/コード/数学ワークロードが対象かどうか)。 出力形式: 選択された形式のエクスポート成果物と、エクスポート前後の3~5個のゴールデン出力を比較するスモークテスト差分レポート。

形式マップ (Format Map)

形式は、習慣ではなくハードウェアとデプロイ形状に基づいて選択します。誤った選択は、スループットの余力を無駄にするか、特定のワークロードで静かに壊れます(「ワークロードオーバーライド」を参照)。

  • FP8 は Hopper クラス以上のGPUのデフォルトです。 ほぼbf16の品質をメモリ約半分で維持し、ターゲットGPUがサポートしておりエッジデバイスの制約がない場合の安全な第一選択肢です。
  • AWQ INT4 は FP8 ハードウェアサポートより前の古いGPUを対象とします。新しいデプロイでは GPTQ は置き換えられています。 新しいエクスポートではGPTQに頼らないでください。AWQは同じビット幅で精度保持が優れており、現在のツールサポートも広いです。
  • imatrix から構築された GGUF Q4_K_M 量子化は、エッジ/llama.cpp形式です。 ローカルまたはCPUに近いデプロイに使用し、GPUサービングのスループット向けではありません。フットプリントを最適化し、データセンタGPUのトークン/秒を重視しません。
  • NVFP4 は Blackwell スケールのデプロイ専用であり、GB10 では明示的に使用しないでください。 GB10 (SM121) での NVFP4 は FP8 より約32%遅くなります。これは、ハードウェアがカーネルを sm_121a でコンパイルしない限り、ネイティブの cvt.e2m1x2 パスを持たないためです。GB10 ターゲットで NVFP4 を選択することは後退であり、アップグレードではありません。代わりに FP8 を選択してください。
  • マージ版 vs LoRA専用版 は量子化形式とは別の軸です。 マージエクスポートはアダプタをベースウェイトに統合します。成果物は大きくなりますが、サービング時にベースモデル依存がありません。LoRA専用版はアダプタを分離したままにします。成果物ははるかに小さいですが、サービングスタックはまったく同じベースモデルを一緒にロードする必要があります。一致しないリビジョンのベースは静かに出力を変更します。成果物のポータビリティがストレージより重要な場合はマージ版を選択し、ディスクフットプリントやマルチアダプタサービングが重要な場合はLoRA専用版を選択します。

実例選択

形式選択の核心的なトレードオフを、一般的なシナリオのルックアップテーブルとして示します。

ターゲットワークロード形式
データセンタGPU汎用チャットFP8
データセンタGPU長文脈/コード/数学FP8 または W8A8 — INT4は不可
古いGPU世代汎用AWQ INT4
エッジデバイス/ラップトップllama.cpp サービングGGUF Q4_K_M + imatrix
GB10任意のワークロードvLLM nightly 経由の FP8、または llama.cpp 経由の GGUF ローカル — NVFP4 はスキップ
# 素早い判断スニペット — 完全なマップは上の表を参照
hopper_or_newer: fp8
older_gpu: awq-int4
edge_llama_cpp: gguf-q4_k_m+imatrix
gb10_any_workload: fp8-vllm-nightly   # GB10 では nvfp4 は不可

ワークロードオーバーライド (Workload Overrides)

上記の形式マップはデフォルトであり、すべてのワークロードで有効なルールではありません。長文脈、コード、数学ワークロードは INT4 で動作しません。 量子化誤差は長いシーケンスや正確なトークンレベルの推論で複合的に悪化し、短く一般的なプロンプトでは現れません。これら3つのワークロードクラスについては、FP8 または W8A8 を維持してください。 たとえターゲットハードウェアがコストの理由で INT4 を正当化する場合でも同様です。

  • このオーバーライドを MMLU や類似の広範知識ベンチマークで検証しないでください。これらのベンチマークは障害モードをストレス処理しません。実際のタスク評価で測定してください。 eval-harness-first のゴールデンとグレーダーを、エクスポートされた成果物で実行します。INT4 の長文脈、コード、数学での劣化は、知識ベンチマークに影響を与えるずっと前に、タスク固有の障害(文脈の消失、構文の破損、算術エラー)として現れます。
  • これら3つのワークロードクラスのいずれかで INT4 エクスポート後にタスク評価が低下した場合、修正は形式の切り替えであり、量子化レシピの再調整ではありません。同じビット幅の AWQ と GPTQ のバリアントは、これらのワークロードで同じ複合誤差の障害モードを共有します。

スモークテスト (Smoke Test)

エクスポートのバグはファイルレベルでは静かです。不正な形式のエクスポートでもロード可能な成果物が生成されるため、ファイルの存在チェックは無意味です。スモークテストはすべてのエクスポートで必須であり、「動作するはず」の形式でも例外はありません。

  1. エクスポートされた成果物を実際のターゲットランタイムでロードします。 FP8/AWQ の場合は vLLM、GGUF の場合は llama.cpp を使用し、本番で使用するものとは異なるフレームワークでの簡易検証は行わないでください。
  2. 3~5個のゴールデンプロンプトを実行します。 これらは eval-harness-first が管理する同じ eval/goldens.jsonl から取得し、新たにアドホックなセットを作成しないでください。
  3. 各出力をエクスポート前の生成結果と比較します。 同じプロンプト、同じ決定論的サンプリング設定(温度0のグリーディデコーディング、固定シード)を使用し、エクスポート前後の実行間で永続化および再利用します。単なる名目上同じ設定ではありません。ロスレスエクスポートの場合、バイト一致がゲートです。差分はすべてバグです。 ロッシー(量子化)エクスポートの場合、バイト一致は失敗することが予想されます。ゲートは代わりにタスクグレーダー判定の一致です。詳細は references/export-commands.md の「スモークテストスクリプトスケルトン」を参照してください。

これを手動チェックではなくゲートとして実行します。

python smoke_test.py "$EXPORT_PATH" \
    eval/goldens.jsonl pre-export-outputs.jsonl
# エクスポート前後の不一致で非ゼロ終了

障害シグネチャ (Failure Signatures)

エクスポートバグが実際にどのように見えるか。単なる合格/不合格のフラグではありません。

  • テンプレートの不一致 は、文字化けした出力や継ぎ足しのような出力として現れます。エクスポートに組み込まれたチャットテンプレートが、チェックポイントがトレーニングおよび評価されたものと一致しないため、ターン境界や特殊トークンが間違った場所に配置されます。
  • lm_head に誤った量子化が適用された場合 は、テンプレートから外れた、または意味的に無意味でありながら流暢に見える出力として現れます。出力ヘッドが必要な精度を失っている一方で、ネットワークの残りの部分はきれいに量子化されています。

このステップをスキップしたエクスポートを絶対に出荷しないでください。チェックポイントの PROMOTE 判定は、エクスポートされていないチェックポイントが良好であることを示します。エクスポートパイプラインについては何も示しません。最初のエクスポート後だけでなく、量子化方法やランタイムのバージョンが上がった場合にも再実行してください。すべての形式の実行可能なコマンドシーケンスとスモークテストスクリプトのスケルトンについては、references/export-commands.md を参照してください。

関連スキル (Related Skills)

  • checkpoint-promotion — このスキルの唯一の有効な上流ソース。PROMOTE 判定のないチェックポイントはエクスポートに到達しません。
  • eval-harness-first — このスキルのスモークテストが3~5個のプロンプトを取得する eval/goldens.jsonl と、ワークロードオーバーライドセクションが長文脈/コード/数学検証に必要とするタスク評価を所有します。
  • finetuning-method-selection — その references/model-catalog.md は、上記の形式マップから形式を選択する前に、ハードウェアクラスの前提(ベースモデルがターゲットとするGPU世代)をチェックする場所です。

Spark ユーザーへ: GB10 では、llama.cpp 経由の GGUF はローカルサービングに適しており、vLLM nightly ビルド経由の FP8 サービングも実績のあるパスです。NVFP4 はそこで避けるべき唯一の形式です(上記の形式マップの例外を参照)。dgx-spark-ops プラグインがインストールされたら、Spark固有のサービングや熱に関する質問は、ここで再導出するのではなく、そのスキルに委ねてください。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

wshobson/accessibility-compliance

Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.

wshobson/airflow-dag-patterns

Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.

wshobson/angular-migration

Migrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.

wshobson/anti-reversing-techniques

Understand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.

wshobson/api-design-principles

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

wshobson/architecture-decision-records

Write and maintain Architecture Decision Records (ADRs) following best practices for technical decision documentation. Use when documenting significant technical decisions, reviewing past architectural choices, or establishing decision processes.

wshobson/architecture-patterns

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.

wshobson/async-python-patterns

Master Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.

wshobson/attack-tree-construction

Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.

wshobson/auth-implementation-patterns

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

wshobson/avoid-ai-writing

Audit and rewrite prose so it stops reading as machine-generated. Use this skill when asked to remove AI-isms, clean up AI writing, edit a draft for AI tells, audit a README, changelog, release note, PR description, or blog post for machine-sounding prose, or make text sound less like AI. Supports a detect-only mode, a rewrite mode, and an edit-in-place mode, with optional voice and context profiles.

wshobson/backtesting-frameworks

Build robust backtesting systems for trading strategies with proper handling of look-ahead bias, survivorship bias, and transaction costs. Use when developing trading algorithms, validating strategies, or building backtesting infrastructure.

wshobson/bash-defensive-patterns

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

wshobson/bats-testing-patterns

Master Bash Automated Testing System (Bats) for comprehensive shell script testing. Use when writing tests for shell scripts, CI/CD pipelines, or requiring test-driven development of shell utilities.

wshobson/bazel-build-optimization

Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.

wshobson/before-you-build

Pre-build product and feature risk review for founders, product managers, and AI-assisted builders. Use this skill when the user is about to build a landing page, MVP, SaaS product, internal tool, agent workflow, or major feature and needs to check demand, positioning, monetization, retention, trust, distribution, and adoption risk before implementation starts.

wshobson/billing-automation

Build automated billing systems for recurring payments, invoicing, subscription lifecycle, and dunning management. Use when implementing subscription billing, automating invoicing, or managing recurring payment systems.

wshobson/binary-analysis-patterns

Master binary analysis patterns including disassembly, decompilation, control flow analysis, and code pattern recognition. Use when analyzing executables, understanding compiled code, or performing static analysis on binaries.

wshobson/block-no-verify-hook

Configure a PreToolUse hook to prevent AI agents from skipping git pre-commit hooks with --no-verify and other bypass flags. Use when setting up Claude Code projects that enforce commit quality gates.

wshobson/brand-landingpage

Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens — use frontend-design instead.

関連スキル