diff --git a/development/comfyui-server/startup-flags.mdx b/development/comfyui-server/startup-flags.mdx index 0d3515412..04d7453c0 100644 --- a/development/comfyui-server/startup-flags.mdx +++ b/development/comfyui-server/startup-flags.mdx @@ -165,6 +165,10 @@ See the [UNET precision](#unet-precision) section for the explanation of each FP | `--cache-lru` `N` | `0` (disabled) | LRU caching with a maximum of N node results cached. No hard upper limit; bounded by available RAM/VRAM. May use more RAM/VRAM. | | `--cache-none` | — | Reduced RAM/VRAM usage; re-executes every node on each run. | + + ComfyUI reuses cached node results between runs in the same session, which is what makes repeat runs faster. Use `--cache-none` when you would rather every run start from a clean cache, for example while debugging a workflow, comparing settings, or ruling out carry-over from an earlier run in the same session. Every node re-executes, so generations take longer. + + ## Attention diff --git a/ja/development/comfyui-server/startup-flags.mdx b/ja/development/comfyui-server/startup-flags.mdx index 08799a0be..b4fd915f0 100644 --- a/ja/development/comfyui-server/startup-flags.mdx +++ b/ja/development/comfyui-server/startup-flags.mdx @@ -3,7 +3,7 @@ title: "起動オプション" sidebarTitle: "起動オプション" description: "ComfyUI 起動フラグリファレンス:comfy/cli_args.py のすべての main.py コマンドライン引数と、Windows ポータブル版の .bat ランチャーへのフラグ追加方法。" icon: "terminal" -translationSourceHash: 461ffdad +translationSourceHash: 641eabe1 translationFrom: development/comfyui-server/startup-flags.mdx translationBlockHashes: "_intro": 10812161 @@ -13,7 +13,7 @@ translationBlockHashes: "Devices & CUDA": d25282b5 "Precision & Inference": 3211a33a "Preview": 92d0c26e - "Cache": 94a7f737 + "Cache": b2809f5f "Attention": 35477f4d "VRAM & Memory": cf79989d "Performance & Debugging": 5c337217 @@ -183,6 +183,10 @@ python main.py --disable-auto-launch | `--cache-lru` `N` | `0`(無効) | LRU キャッシュ。最大 N 個のノード結果をキャッシュ。硬性の上限はなく、利用可能な RAM/VRAM に制限される。RAM/VRAM を多く使用する可能性あり。 | | `--cache-none` | — | RAM/VRAM 使用量を削減。実行のたびにすべてのノードを再実行。 | + + ComfyUI は同一セッション内でキャッシュされたノード結果を再利用します。これが繰り返し実行を速くしている仕組みです。毎回クリーンなキャッシュから開始したい場合は `--cache-none` を使用してください。たとえばワークフローのデバッグ中、設定の比較中、同じセッション内の前回実行からの引き継ぎを切り分けたい場合などです。すべてのノードが再実行されるため、生成には時間がかかります。 + + ## アテンション diff --git a/ja/tutorials/video/minimax/minimax-h3.mdx b/ja/tutorials/video/minimax/minimax-h3.mdx index 76fdaa1d1..0226bfcb9 100644 --- a/ja/tutorials/video/minimax/minimax-h3.mdx +++ b/ja/tutorials/video/minimax/minimax-h3.mdx @@ -2,15 +2,16 @@ title: "ComfyUI MiniMax H3 動画生成ガイド" description: "ComfyUI でオープンウェイトの MiniMax H3 を使う方法: テキストから動画、画像から動画、参照から動画のワークフローとネイティブステレオオーディオ、プロンプト作成のコツ、Sage Attention による高速化。" sidebarTitle: "概要" -translationSourceHash: 409b82a5 +translationSourceHash: 8490d612 translationFrom: tutorials/video/minimax/minimax-h3.mdx translationBlockHashes: "_intro": bcfdbb95 "Key features": 7bfa7de1 "Getting started": fddf949c "Workflow index": 208e71ea - "Setting the output resolution": b3a75643 - "Speeding up generation with Sage Attention": 1b231e7c + "Setting the output resolution": 1ece1dc7 + "Speeding up generation with Sage Attention": cc061bad + "Speeding up generation with sparse attention": bfc451cb --- [MiniMax H3](https://www.minimax.io/blog/minimax-h3) は、MiniMaxの汎用オムニモーダル生成モデルで、現在はオープンウェイトとして公開されています。テキスト、画像、ビデオ、オーディオを単一のコンテキストで統合的に理解し、**ネイティブステレオオーディオ**付きのビデオを生成します。つまり、音声、サウンドエフェクト、音楽は、後から重ね合わせるのではなく、単一のフォワードパスでまとめてモデル化されます。出力は最大2K解像度、24fps、約15秒です。 @@ -83,6 +84,8 @@ MiniMax H3はオープンウェイトで、ComfyUIでサポートされていま テンプレートは高速なプレビューサイズになっています。フル品質で出力するには、16:9 で Resolution Selector のメガピクセルを `0.98` に設定します。これは H3 のネイティブキャンバス(短辺 768px、16:9 では 1344x768)です。あるいは、MiniMax H3 ノードの `width` と `height` に直接 `1344 x 768` を入力します(デフォルト値)。`1.0` メガピクセルは 1376x768 になり、モデルの 768x1344 ピクセルの面積上限を超えるため、使用しないでください。 +H3 のコミュニティテスト(2026 年 9 月)でも、この上限が裏付けられています。モデルの学習解像度は約 100 万ピクセルのため、ネイティブキャンバスを大きく超えるフレームは、後からどんなアップスケールのテクニックを使ってもディテールの一貫性を失いがちです。2K 出力が必要な場合は、ネイティブキャンバスで生成してから別パスでアップスケールするのが確実です。また、ステップ数を 50 程度に上げると、フレームのシャープさではなくモーションの品質が向上するというテスト結果もあります。ステップ数を増やすのは、ディテールが柔らかいときよりも、動きが硬いときに効果的です。 + ## Sage Attention で生成を高速化 サンプルワークフローはデフォルトで標準のアテンション実装を使用します。[Sage Attention](https://github.com/woct0rdho/SageAttention) を使用すると、品質の低下を最小限に抑えながら生成速度をおよそ2倍にできます。Sage Attention はオプションの依存関係のため、自分でインストールする必要があります: @@ -96,3 +99,22 @@ MiniMax H3はオープンウェイトで、ComfyUIでサポートされていま - Sage Attention は float16 または bfloat16 テンソルを必要とします。MiniMax H3 の一部のレイヤーは他の dtype で実行されるため、コンソールに "Input tensors must be in dtype of torch.float16 or torch.bfloat16, using pytorch attention instead" というメッセージが表示されることがあります。これは正常です。影響を受けるレイヤーは標準アテンションにフォールバックし、生成は正常に動作します。 - 別の方法として、ノードを追加せずに `--use-sage-attention` フラグ付きで ComfyUI を起動して、Sage Attention をグローバルに有効にすることもできます。 + +### INT8 アテンションによる品質劣化 + +Sage Attention 使用時にクリップの終盤でモーフィングや画面内テキストの文字化けが発生する場合、原因は INT8 アテンションの量子化である可能性が高いです。H3 の終盤ブロックはアテンションキーの信号の大部分を少数のチャンネルに集中させており、単一の共有スケールで行全体を丸める INT8 カーネルはその信号の一部を失います。H3 でのコミュニティ検証済み: デンスアテンションバックエンドを **Comfy Kitchen attention** に切り替えると、これらのアーティファクトが解消されます。この INT8 カーネルは量子化の前にチャンネル回転を適用し、Sage Attention と同程度の速度で信号を保持します。 + +注意: Comfy Kitchen attention には、INT8-convrot 量子化された H3 チェックポイント(例: `minimax_h3_fl2va_pruned_int8_convrot.safetensors`)との既知の非互換性があり、サンプリング中にアライメントエラーでクラッシュします。これらのチェックポイントでは、下記の bfloat16 の回避策を使用してください。詳細は [ComfyUI issue #15529](https://github.com/Comfy-Org/ComfyUI/issues/15529) を参照してください。 + +バックエンドを切り替えるには、組み込みの **Model Attention Backend** ノード(カテゴリ `model/patch`)をワークフローに追加し、`UNETLoader` と `BasicGuider` ノードの間に接続して、バックエンドを `comfy kitchen attention` に設定します。または、`--use-ck-attention` フラグ付きで ComfyUI を起動してください(ComfyUI 0.32.0 以降で利用可能)。このバックエンドは ComfyUI に同梱される `comfy-kitchen` パッケージを使用しますが、INT8 カーネルがハードウェアで利用可能な場合にのみオプションが表示されます。利用できない場合、ノードは PyTorch アテンションにフォールバックします。該当ブロックを bfloat16 アテンションで実行することでもアーティファクトは解消されますが、レンダリング時間が長くなります。 + +## スパースアテンションによる生成の高速化 + +アテンションのコストはクリップが長くなるほど急増します。ComfyUI 内蔵の **Model Sparse Attention** ノード(カテゴリ `model/patch`)は、対象となるレイヤーでブロックスパースアテンションを実行してこのコストを削減します。シーケンスが長いほど効果が大きくなります。H3 でのコミュニティ検証では、このノードの既定スケジュールは疎化の開始が早すぎ、終了が遅すぎるため画質を損ないます。 + +- **サンプリングの最初と最後のステップではスパースアテンションを使わないでください。** 既定値は `start_percent` が `0.2`、`end_percent` が `1.0` で、スケジュールの 20% から最終ステップまで疎化が有効になります。開始を `0.4` 程度まで遅らせるとショット全体の動きをデンスアテンションで先に確定でき、終了を `0.9` 程度まで早めると最後のステップをデンスに保てます。`0.4` と `0.9` の報告では、クリップ前半のモーフィングが減り終盤フレームのちらつきも軽減され、代わりに速度がやや低下します。 +- **H3 では `sink_conditioning` を既定値(`exact_kv_and_rows`)のままにしてください。** パックされたテキスト、オーディオ、参照の行を正確に計算し、生成オーディオのクエリ行をデンスに保つため、スパース経路でも音声トラックが劣化しません。 +- **`tau` は `sol-attn` の疎さを決めます**: `1.0` でキーブロックの約 16% を正確に保持、`1.5` で約 7%、`2.0` で約 2.7%。既定は `1.3` で、値が大きいほど高速ですがリスクも大きくなります。 +- **短いクリップでは効果がほとんどありません。** `min_tokens`(既定 `12288`)未満のシーケンスと、`dense_blocks` に記載したブロックはデンスのまま実行されます。 + +FastH3 チェックポイントは同じノードの `vsa` モードを使用し、`keep_percent` `10` のスパースパターンで学習されています。詳しくは [FastH3 ワークフローのページ](/ja/tutorials/video/minimax/minimax-h3-fastvideo)を参照してください。 diff --git a/ko/development/comfyui-server/startup-flags.mdx b/ko/development/comfyui-server/startup-flags.mdx index 01f7b60d3..94c8ac0bb 100644 --- a/ko/development/comfyui-server/startup-flags.mdx +++ b/ko/development/comfyui-server/startup-flags.mdx @@ -3,7 +3,7 @@ title: "시작 플래그" sidebarTitle: "시작 플래그" description: "ComfyUI 시작 플래그 레퍼런스: comfy/cli_args.py의 모든 main.py 명령줄 인수와 Windows 휴대용 .bat 런처에 플래그를 추가하는 방법." icon: "terminal" -translationSourceHash: 461ffdad +translationSourceHash: 641eabe1 translationFrom: development/comfyui-server/startup-flags.mdx translationBlockHashes: "_intro": 10812161 @@ -13,7 +13,7 @@ translationBlockHashes: "Devices & CUDA": d25282b5 "Precision & Inference": 3211a33a "Preview": 92d0c26e - "Cache": 94a7f737 + "Cache": b2809f5f "Attention": 35477f4d "VRAM & Memory": cf79989d "Performance & Debugging": 5c337217 @@ -182,6 +182,10 @@ python main.py --disable-auto-launch | `--cache-lru` `N` | `0` (비활성화) | LRU 캐싱으로, 최대 N개의 노드 결과가 캐시됩니다. 하드 상한은 없으며, 사용 가능한 RAM/VRAM에 의해 제한됩니다. 더 많은 RAM/VRAM을 사용할 수 있습니다. | | `--cache-none` | - | RAM/VRAM 사용량을 줄입니다. 매 실행마다 모든 노드를 다시 실행합니다. | + + ComfyUI는 같은 세션에서 캐시된 노드 결과를 재사용하며, 이것이 반복 실행을 빠르게 만드는 이유입니다. 매번 깨끗한 캐시에서 시작하려면 `--cache-none`을 사용하세요. 예를 들어 워크플로를 디버깅할 때, 설정을 비교할 때, 같은 세션에서 이전 실행의 잔여물이 넘어오는지 확인할 때 유용합니다. 모든 노드가 다시 실행되므로 생성 시간은 더 길어집니다. + + ## 어텐션 diff --git a/ko/tutorials/video/minimax/minimax-h3.mdx b/ko/tutorials/video/minimax/minimax-h3.mdx index 74e0088fa..ddf5220ed 100644 --- a/ko/tutorials/video/minimax/minimax-h3.mdx +++ b/ko/tutorials/video/minimax/minimax-h3.mdx @@ -2,15 +2,16 @@ title: "ComfyUI MiniMax H3 비디오 생성 가이드" description: "ComfyUI에서 오픈 가중치 MiniMax H3를 사용하는 방법: 텍스트 기반, 이미지 기반, 레퍼런스 기반 비디오 워크플로와 네이티브 스테레오 오디오, 프롬프트 작성 팁, Sage Attention 가속화." sidebarTitle: "개요" -translationSourceHash: 409b82a5 +translationSourceHash: 8490d612 translationFrom: tutorials/video/minimax/minimax-h3.mdx translationBlockHashes: "_intro": bcfdbb95 "Key features": 7bfa7de1 "Getting started": fddf949c "Workflow index": 208e71ea - "Setting the output resolution": b3a75643 - "Speeding up generation with Sage Attention": 1b231e7c + "Setting the output resolution": 1ece1dc7 + "Speeding up generation with Sage Attention": cc061bad + "Speeding up generation with sparse attention": bfc451cb --- [MiniMax H3](https://www.minimax.io/blog/minimax-h3)는 MiniMax의 범용 옴니모달 생성 모델로, 현재 오픈 가중치로 제공됩니다. 이 모델은 단일 컨텍스트에서 텍스트, 이미지, 비디오, 오디오를 함께 이해하며, **네이티브 스테레오 오디오**로 비디오를 생성합니다. 음성, 사운드 효과, 음악이 이후에 덧붙여지는 대신 단일 포워드 패스에서 함께 모델링됩니다. 출력은 최대 2K 해상도, 24fps, 약 15초입니다. @@ -84,6 +85,8 @@ MiniMax H3는 오픈 가중치로 ComfyUI에서 지원됩니다. 시작하려면 템플릿은 빠른 미리보기 크기로 제공됩니다. 전체 품질로 출력하려면 16:9에서 Resolution Selector의 메가픽셀을 `0.98`로 설정하세요. 이는 H3의 네이티브 캔버스(단변 768px, 16:9에서 1344x768)입니다. 또는 MiniMax H3 노드의 `width`와 `height`에 직접 `1344 x 768`을 입력하세요(기본값). `1.0` 메가픽셀 단계는 1376x768로, 모델의 768x1344 픽셀 면적 상한을 초과하므로 건너뛰세요. +H3 커뮤니티 테스트(2026년 9월)에서도 이 상한이 확인되었습니다. 모델의 학습 해상도는 약 100만 픽셀이므로, 네이티브 캔버스를 크게 벗어나는 프레임은 이후 어떤 업스케일 트릭을 써도 디테일 일관성을 잃기 쉽습니다. 2K 출력이 필요하다면 네이티브 캔버스에서 생성한 뒤 별도 패스로 업스케일하는 것이 더 확실합니다. 커뮤니티 테스트에서는 스텝 수를 50 정도로 올리면 프레임의 선명도가 아니라 모션 품질이 개선된다는 결과도 있습니다. 스텝 수를 늘리는 것은 디테일이 부드러울 때보다 움직임이 뻣뻣할 때 더 효과적입니다. + ## Sage Attention으로 생성 가속화 예제 워크플로는 기본적으로 표준 어텐션 구현을 사용합니다. [Sage Attention](https://github.com/woct0rdho/SageAttention)을 사용하면 품질 손실을 최소화하면서 생성 속도를 약 2배 높일 수 있습니다. Sage Attention은 선택적 의존성으로, 직접 설치해야 합니다: @@ -97,3 +100,22 @@ MiniMax H3는 오픈 가중치로 ComfyUI에서 지원됩니다. 시작하려면 - Sage Attention은 float16 또는 bfloat16 텐서가 필요합니다. MiniMax H3의 일부 레이어는 다른 dtype으로 실행되므로 콘솔에 "Input tensors must be in dtype of torch.float16 or torch.bfloat16, using pytorch attention instead" 메시지가 표시될 수 있습니다. 이는 정상입니다. 영향을 받는 레이어는 표준 어텐션으로 대체되며 생성은 계속 정상 작동합니다. - 또는 노드를 추가하는 대신 `--use-sage-attention` 플래그로 ComfyUI를 시작하여 Sage Attention을 전역적으로 활성화할 수도 있습니다. + +### INT8 어텐션으로 인한 품질 저하 + +Sage Attention 사용 시 클립 후반부에 모핑이나 화면 내 텍스트가 깨지는 현상이 나타나면, 원인은 INT8 어텐션 양자화일 가능성이 높습니다. H3의 마지막 블록들은 어텐션 키 신호의 대부분을 소수의 채널에 집중시키며, 단일 공유 스케일로 각 행을 반올림하는 INT8 커널은 그 신호의 일부를 잃습니다. H3에서 커뮤니티 검증됨: 덴스 어텐션 백엔드를 **Comfy Kitchen attention**으로 전환하면 이러한 아티팩트가 해결됩니다. 이 INT8 커널은 양자화 전에 채널 회전을 적용하여 Sage Attention과 비슷한 속도로 신호를 보존합니다. + +참고: Comfy Kitchen attention은 INT8-convrot 양자화된 H3 체크포인트(예: `minimax_h3_fl2va_pruned_int8_convrot.safetensors`)와 알려진 비호환성이 있어 샘플링 중 정렬 오류로 크래시가 발생합니다. 이러한 체크포인트에는 아래의 bfloat16 우회 방법을 사용하세요. 자세한 내용은 [ComfyUI issue #15529](https://github.com/Comfy-Org/ComfyUI/issues/15529)를 참조하세요. + +백엔드를 전환하려면 내장 **Model Attention Backend** 노드(카테고리 `model/patch`)를 워크플로에 추가하고, `UNETLoader`와 `BasicGuider` 노드 사이에 연결한 뒤 백엔드를 `comfy kitchen attention`으로 설정하세요. 또는 `--use-ck-attention` 플래그로 ComfyUI를 시작할 수도 있습니다(ComfyUI 0.32.0 이상에서 사용 가능). 이 백엔드는 ComfyUI에 포함된 `comfy-kitchen` 패키지를 사용하지만, INT8 커널이 하드웨어에서 사용 가능한 경우에만 옵션이 나타납니다. 사용할 수 없는 경우 노드는 PyTorch 어텐션으로 폴백합니다. 해당 블록을 bfloat16 어텐션으로 실행하는 방법으로도 아티팩트가 해결되지만, 렌더링 시간이 더 오래 걸립니다. + +## 스파스 어텐션으로 생성 속도 높이기 + +어텐션 비용은 클립이 길어질수록 빠르게 증가합니다. ComfyUI에 내장된 **Model Sparse Attention** 노드(카테고리 `model/patch`)는 해당 레이어에서 블록 스파스 어텐션을 실행해 이 비용을 줄이며, 시퀀스가 길수록 효과가 커집니다. H3에서의 커뮤니티 검증에 따르면 이 노드의 기본 스케줄은 희소화를 너무 이르게 시작하고 너무 늦게 끝내서 품질을 떨어뜨립니다. + +- **샘플링의 처음과 마지막 스텝에서는 스파스 어텐션을 쓰지 마세요.** 기본값은 `start_percent` `0.2`, `end_percent` `1.0`이므로 스케줄의 20%부터 마지막 스텝까지 희소화가 적용됩니다. 시작을 `0.4` 정도로 늦추면 샷 전체의 움직임을 덴스 어텐션으로 먼저 확정할 수 있고, 종료를 `0.9` 정도로 앞당기면 마지막 스텝을 덴스로 유지할 수 있습니다. `0.4`와 `0.9`를 사용한 사례에서는 클립 전반부의 모핑이 줄고 마지막 프레임의 플리커도 완화되었으며, 대신 속도가 다소 느려졌습니다. +- **H3에서는 `sink_conditioning`을 기본값(`exact_kv_and_rows`)으로 두세요.** 패킹된 텍스트, 오디오, 레퍼런스 행을 정확히 계산하고 생성 오디오 쿼리 행을 덴스로 유지하므로, 스파스 경로가 오디오 트랙을 떨어뜨리지 않습니다. +- **`tau`는 `sol-attn`의 희소 정도를 정합니다**: `1.0`은 키 블록의 약 16%를 정확히 유지하고, `1.5`는 약 7%, `2.0`은 약 2.7%입니다. 기본값은 `1.3`이며 값이 높을수록 빠르지만 위험도 커집니다. +- **짧은 클립에서는 이득이 거의 없습니다.** `min_tokens`(기본값 `12288`)보다 짧은 시퀀스와 `dense_blocks`에 나열한 블록은 덴스로 실행됩니다. + +FastH3 체크포인트는 같은 노드의 `vsa` 모드를 사용하며 `keep_percent` `10`의 스파스 패턴으로 학습되었습니다. 자세한 내용은 [FastH3 워크플로 페이지](/ko/tutorials/video/minimax/minimax-h3-fastvideo)를 참조하세요. diff --git a/tutorials/video/minimax/minimax-h3.mdx b/tutorials/video/minimax/minimax-h3.mdx index 5190b95ee..fe77f9b9a 100644 --- a/tutorials/video/minimax/minimax-h3.mdx +++ b/tutorials/video/minimax/minimax-h3.mdx @@ -74,6 +74,8 @@ Each workflow uses a **Resolution Selector** node to control the overall output The template ships with a fast preview size. For full-quality output at 16:9, set the Resolution Selector's Megapixels to `0.98` for H3's native canvas (a 768px short edge, 1344x768 at 16:9), or enter `1344 x 768` directly in the MiniMax H3 node's `width` and `height` inputs (its default). Skip the `1.0` Megapixel step: it yields 1376x768, above the model's 768x1344 pixel area cap. +Community testing on H3 (September 2026) reinforces this cap: the model was trained at around 1 megapixel, so frames well above the native canvas tend to lose detail consistency no matter what upscaling tricks are applied afterward. If you need 2K output, the more reliable path is generating at the native canvas and upscaling in a separate pass. Community tests also show that raising the step count to about 50 improves motion quality rather than frame sharpness, so extra steps are better spent when motion looks too stiff, not when detail looks too soft. + ## Speeding up generation with Sage Attention The example workflows use the standard attention implementation. You can roughly double the generation speed with [Sage Attention](https://github.com/woct0rdho/SageAttention), with minimal quality loss. Sage Attention is an optional dependency, so you need to install it yourself: @@ -87,3 +89,22 @@ Notes: - Sage Attention requires float16 or bfloat16 tensors. MiniMax H3 runs some layers in other dtypes, so you may see "Input tensors must be in dtype of torch.float16 or torch.bfloat16, using pytorch attention instead" messages in the console. These are expected; the affected layers fall back to standard attention and generation still works. - Alternatively, you can enable Sage Attention globally by launching ComfyUI with the `--use-sage-attention` flag instead of adding the node. + +### Quality degradation with INT8 attention + +If you see morphing near the end of a clip or garbled on-screen text while using Sage Attention, the INT8 attention quantization is the likely cause. H3's last blocks concentrate most of their attention-key signal into a few channels, and INT8 kernels that round each row with a single shared scale lose part of that signal. Community-verified on H3: switching the dense attention backend to **Comfy Kitchen attention** fixes these artifacts. Its INT8 kernel applies a channel rotation before quantizing, which preserves that signal at a similar speed to Sage Attention. + +Note: Comfy Kitchen attention has a known incompatibility with the INT8-convrot quantized H3 checkpoints (for example `minimax_h3_fl2va_pruned_int8_convrot.safetensors`), where sampling crashes with an alignment error. Use the bfloat16 workaround below with those checkpoints. See [ComfyUI issue #15529](https://github.com/Comfy-Org/ComfyUI/issues/15529). + +To switch backends, add the built-in **Model Attention Backend** node (category `model/patch`) to the workflow, connect it between the `UNETLoader` and the `BasicGuider` node, and set backend to `comfy kitchen attention`. Alternatively, launch ComfyUI with the `--use-ck-attention` flag (available in ComfyUI 0.32.0 or later). The backend uses the `comfy-kitchen` package that ships with ComfyUI, but the option only appears when the INT8 kernels are available on your hardware; otherwise the node falls back to PyTorch attention. Running the affected blocks in bfloat16 attention instead also fixes the artifacts, at the cost of longer render times. + +## Speeding up generation with sparse attention + +Attention cost grows quickly with clip length. ComfyUI's built-in **Model Sparse Attention** node (category `model/patch`) runs block-sparse attention on eligible layers to cut that cost, and the gain grows with sequence length. Community testing on H3 found that the node's default schedule sparsifies too early and ends too late, which costs quality: + +- **Keep sparse attention out of the first and last steps.** The defaults are `start_percent` `0.2` and `end_percent` `1.0`, so sparsity runs from 20% of the schedule through the final step. Starting later (around `0.4`) lets the overall motion of the shot resolve with dense attention first, and ending earlier (around `0.9`) keeps the last steps dense. Reported results with `0.4` and `0.9`: less morphing early in the clip and less flicker on the closing frames, at a modest cost in speed. +- **Leave `sink_conditioning` at its default** (`exact_kv_and_rows`) on H3. It keeps the packed text, audio, and reference rows exact and the generated audio query rows dense, so the sparse path does not degrade the audio track. +- **`tau` controls how sparse `sol-attn` is**: `1.0` keeps roughly 16% of key blocks exact, `1.5` about 7%, and `2.0` about 2.7%. The default is `1.3`, and higher values are faster but riskier. +- **Short clips gain little.** Sequences below `min_tokens` (default `12288`) and blocks listed in `dense_blocks` stay dense. + +FastH3 checkpoints use the same node in `vsa` mode, which is trained for its sparse pattern at `keep_percent` `10`. See the [FastH3 workflow page](/tutorials/video/minimax/minimax-h3-fastvideo) for details. diff --git a/zh/development/comfyui-server/startup-flags.mdx b/zh/development/comfyui-server/startup-flags.mdx index 946e2c87d..54075267e 100644 --- a/zh/development/comfyui-server/startup-flags.mdx +++ b/zh/development/comfyui-server/startup-flags.mdx @@ -3,7 +3,7 @@ title: "启动参数" sidebarTitle: "启动参数" description: "ComfyUI 启动参数参考:comfy/cli_args.py 中的全部 main.py 命令行参数,以及如何在 Windows 便携版 .bat 启动器中添加参数。" icon: "terminal" -translationSourceHash: 461ffdad +translationSourceHash: 641eabe1 translationFrom: development/comfyui-server/startup-flags.mdx translationBlockHashes: "_intro": 10812161 @@ -13,7 +13,7 @@ translationBlockHashes: "Devices & CUDA": d25282b5 "Precision & Inference": 3211a33a "Preview": 92d0c26e - "Cache": 94a7f737 + "Cache": b2809f5f "Attention": 35477f4d "VRAM & Memory": cf79989d "Performance & Debugging": 5c337217 @@ -183,6 +183,10 @@ python main.py --disable-auto-launch | `--cache-lru` `N` | `0`(关闭) | LRU 缓存,最多缓存 N 个节点结果。无硬性上限;受可用 RAM/VRAM 限制。可能占用更多 RAM/VRAM。 | | `--cache-none` | — | 降低 RAM/VRAM 占用;每次运行重新执行所有节点。 | + + ComfyUI 会在同一会话中复用已缓存的节点结果,这正是重复运行更快的原因。如果你希望每次运行都从干净的缓存开始,请使用 `--cache-none`,例如在调试工作流、对比设置,或需要排除同一会话中上一次运行的残留时。代价是每个节点都会重新执行,生成时间会更长。 + + ## 注意力机制 diff --git a/zh/tutorials/video/minimax/minimax-h3.mdx b/zh/tutorials/video/minimax/minimax-h3.mdx index c00061e1c..872922ed5 100644 --- a/zh/tutorials/video/minimax/minimax-h3.mdx +++ b/zh/tutorials/video/minimax/minimax-h3.mdx @@ -2,15 +2,16 @@ title: "ComfyUI MiniMax H3 视频生成指南" description: "如何在 ComfyUI 中使用开放权重的 MiniMax H3:文生视频、图生视频、参考生视频工作流,支持原生立体声音频,附提示词编写技巧与 Sage Attention 加速方法。" sidebarTitle: "概述" -translationSourceHash: 409b82a5 +translationSourceHash: 8490d612 translationFrom: tutorials/video/minimax/minimax-h3.mdx translationBlockHashes: "_intro": bcfdbb95 "Key features": 7bfa7de1 "Getting started": fddf949c "Workflow index": 208e71ea - "Setting the output resolution": b3a75643 - "Speeding up generation with Sage Attention": 1b231e7c + "Setting the output resolution": 1ece1dc7 + "Speeding up generation with Sage Attention": cc061bad + "Speeding up generation with sparse attention": bfc451cb --- [MiniMax H3](https://www.minimax.io/blog/minimax-h3) 是 MiniMax 推出的通用全模态生成模型,现已以开放权重形式提供。它能在单一上下文中联合理解文本、图像、视频和音频,并生成带**原生立体声音频**的视频:语音、音效和音乐在单次前向传播中一并建模,而非事后叠加。输出最高支持 2K 分辨率、24fps,时长约 15 秒。 @@ -83,6 +84,8 @@ ComfyUI 支持开放权重的 MiniMax H3。开始使用: 模板默认使用一个较快的预览尺寸。要获得全质量输出,请在 16:9 下将分辨率选择器的百万像素设为 `0.98`,即 H3 的原生画布(短边 768px,16:9 下为 1344x768);或在 MiniMax H3 节点的 `width` 和 `height` 中直接输入 `1344 x 768`(默认值)。请跳过 `1.0` 百万像素档:它得到 1376x768,超出模型 768x1344 像素的面积上限。 +H3 社区实测(2026 年 9 月)也印证了这个上限:模型的训练分辨率在 100 万像素左右,远超原生画布的帧无论后续使用什么放大技巧,都容易丢失细节一致性。如果需要 2K 输出,更可靠的做法是先在原生画布下生成,再单独跑一次放大。社区测试还表明,把步数提高到 50 左右改善的是运动质量而不是画面锐度,因此步数更适合用在运动显得僵硬的时候,而不是细节偏软的时候。 + ## 使用 Sage Attention 加速生成 示例工作流默认使用标准注意力实现。使用 [Sage Attention](https://github.com/woct0rdho/SageAttention) 可以将生成速度大约提升一倍,质量损失极小。Sage Attention 是可选依赖,需要你自行安装: @@ -96,3 +99,22 @@ ComfyUI 支持开放权重的 MiniMax H3。开始使用: - Sage Attention 要求 float16 或 bfloat16 张量。MiniMax H3 的部分层使用其他数据类型,因此你可能会在控制台看到 "Input tensors must be in dtype of torch.float16 or torch.bfloat16, using pytorch attention instead" 消息。这是正常现象;受影响的层会回退到标准注意力,生成仍然可以正常工作。 - 另一种方式是使用 `--use-sage-attention` 启动参数启动 ComfyUI 来全局启用 Sage Attention,无需添加节点。 + +### INT8 注意力导致的质量劣化 + +使用 Sage Attention 时,如果视频片段末尾附近出现画面形变或屏幕文字乱码,最可能的原因是 INT8 注意力量化。H3 的最后几个 Transformer 块将大部分注意力键信号集中到少数通道中,而使用单一共享缩放对整行进行取整的 INT8 内核会丢失部分信号。社区实测(H3):将稠密注意力后端切换为 **Comfy Kitchen attention** 可以修复这些伪影。它的 INT8 内核在量化前先进行通道旋转,从而在保留信号的同时保持与 Sage Attention 相近的速度。 + +注意:Comfy Kitchen attention 与 INT8-convrot 量化的 H3 检查点(如 `minimax_h3_fl2va_pruned_int8_convrot.safetensors`)存在已知的不兼容问题,采样时会因对齐错误而崩溃。使用这些检查点时请采用下方的 bfloat16 方案。参见 [ComfyUI issue #15529](https://github.com/Comfy-Org/ComfyUI/issues/15529)。 + +要切换后端,请在工作流中添加内置的 **Model Attention Backend** 节点(分类 `model/patch`),将其连接在 `UNETLoader` 和 `BasicGuider` 节点之间,并将后端设置为 `comfy kitchen attention`。也可以使用 `--use-ck-attention` 启动参数启动 ComfyUI(ComfyUI 0.32.0 及以上版本可用)。该后端使用随 ComfyUI 自带的 `comfy-kitchen` 包,但只有当 INT8 内核在你的硬件上可用时该选项才会出现;否则节点会回退到 PyTorch attention。将受影响的块改为以 bfloat16 注意力运行同样能修复伪影,但渲染时间会更长。 + +## 使用稀疏注意力加速生成 + +注意力开销会随视频时长快速上升。ComfyUI 内置的 **Model Sparse Attention** 节点(分类 `model/patch`)会在符合条件的层上执行块稀疏注意力来降低这部分开销,序列越长收益越明显。社区在 H3 上的实测发现,该节点的默认调度稀疏得过早、结束得太晚,会损失画质: + +- **不要在采样的最开始和最后几步启用稀疏注意力。** 默认值为 `start_percent` `0.2`、`end_percent` `1.0`,也就是从调度的 20% 一直稀疏到最后一步。把开始时间推迟到 `0.4` 左右,可以让画面的整体运动先用稠密注意力确定下来;把结束时间提前到 `0.9` 左右,则能让最后几步保持稠密。报告显示使用 `0.4` 与 `0.9` 后,片段前段的形变减少、结尾几帧的闪烁减轻,代价是速度略有下降。 +- **H3 上保持 `sink_conditioning` 的默认值**(`exact_kv_and_rows`)。它会让打包的文本、音频和参考行保持精确计算,并让生成音频的查询行保持稠密,因此稀疏路径不会降低音轨质量。 +- **`tau` 决定 `sol-attn` 的稀疏程度**:`1.0` 大约保留 16% 的关键块做精确计算,`1.5` 约 7%,`2.0` 约 2.7%。默认值为 `1.3`,数值越高越快,风险也越大。 +- **短视频片段收益有限。** 长度低于 `min_tokens`(默认 `12288`)的序列,以及 `dense_blocks` 中列出的块都会保持稠密。 + +FastH3 检查点使用同一个节点的 `vsa` 模式,该模式按 `keep_percent` `10` 的稀疏模式训练。详见 [FastH3 工作流页面](/zh/tutorials/video/minimax/minimax-h3-fastvideo)。