CCP6's picture
Upload README.md
00eff5c verified
|
Raw History Blame Contribute Delete
3.77 kB
# ComfyUI-H3NegativeLab
Negative prompting for MiniMax H3 in ComfyUI.
H3 is CFG-distilled — there's no stock negative prompt input. This pack patches the H3 DiT blocks to run a shadow attention branch with your negative text while keeping the positive presentation, references, and keyframes intact. NAG-form normalized repulsion is applied to the generated video and audio targets independently.
Works with T2V, FL2VA (first/last-frame I2V), and REF2VA.
## Install
Extract in comfy\custom_nodes folder / Restart ComfyUI / No additional dependencies.
```
ComfyUI/custom_nodes/ComfyUI-H3NegativeLab/
__init__.py
h3_negative_lab_v1_0_2.py
README.md
```
## Nodes
### H3 Shadow Negative
The everyday node. Plug in one negative CONDITIONING (from a plain CLIP Text Encode on the H3 text encoder), connect the patched MODEL to a normal BasicGuider, done.
`video_scale` and `audio_scale` control how hard the output is pushed away from the negative. Scale 1 = off for that stream. If `audio_scale > 1` and no separate `audio_negative` is connected, the main negative is reused for audio.
`tau` caps the guided norm relative to the positive (prevents overcooking). `alpha` blends between the positive-only and guided result. `start_percent` / `end_percent` limits guidance to a window of the denoise schedule.
### H3 Shadow Negative (Advanced)
Same mechanism, explicit `video_negative` input. Optionally connect a separate `audio_negative`.
For REF2VA, two modes:
**Plain mode** — connect an ordinary H3 text CONDITIONING to `video_negative`. The patch preserves all packed REF2VA reference rows and replaces the user-prompt text in the shadow branch best-effort.
**Exact mode** — duplicate your stock `MiniMax H3 Reference to Video` node with the same refs, same sizing, same reference order, but put your negative description in its prompt. Connect that CONDITIONING to `video_negative`. The patch detects matching reference metadata and builds a full alternate packed layout with correct text/vision tags and RoPE coordinates for the shadow branch.
### H3 Weighted Text Encode
`(phrase:weight)` syntax for H3 text conditioning. Operates in embedding space — weights above 1 emphasize, below 1 de-emphasize. The `(syntax:1.5)` is stripped before Qwen encoding.
Designed to feed the Shadow node's negative inputs. Safe alongside the Shadow block patch (it modifies the conditioning tensor, not the DiT blocks).
## Usage
Minimal setup — add a negative to any H3 T2V workflow:
```
H3 CLIP Text Encode ("blurry, static, grainy")
|
v
H3 Shadow Negative <-- MODEL (after sigma shift if used)
|
v
BasicGuider <-- positive CONDITIONING
|
v
KSampler
```
Console output reports per-step metrics (neg-delta, guided-delta, clamp %) so you can tell whether your negative is actually doing anything.
## Defaults
These worked well in testing as starting points:
| Parameter | Basic | Advanced |
|-----------|-------|----------|
| video_scale | 3.0 | 3.0 |
| audio_scale | 1.0 | 1.0 |
| tau | 2.5 | 2.5 |
| alpha | 0.35 | 0.35 |
| start_percent | 0.0 | 0.0 |
| end_percent | 0.60 | 0.60 |
If your output looks overcooked, lower alpha first, then tau. If the negative isn't biting, raise video_scale.
## Known limitations
- **Block cache nodes**: This patch replaces H3's DiT double_blocks via `set_model_patch_replace`. Block-level cache nodes (Sage+Spectrum, T8mars, etc.) that replace the same blocks will conflict — use one or the other per run.
- **Experimental**: Keep fixed-seed A/B comparisons when tuning. The shadow branch adds one attention pass per active block per step; expect roughly 15-30% longer inference depending on your setup.
## License
MIT