Nodes/ComfyUI_agilly1989_motorway/Mahiro_motorway_edition
ComfyUI Node

Mahiro_motorway_edition

Mahiro is a CFG hack with a crush on the positive prompt

By agilly1989Β·Created 2 years agoΒ·Updated about a year agoΒ· 7
Mahiro_motorway_edition
  • MOTORWAY πŸšŒπŸ’¨
  • MOTORWAY πŸšŒπŸ’¨
β—„INPUT_model_keymodelβ–Ί
β—„OUTPUT_patched_model_keypatched_modelβ–Ί

Mahiro is not a video model and not an image model - it's a guidance function with an anime girl's name. ComfyUI shipped it as an experimental node whose display name is, no joke, "Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)". It was so obscure that when people first spotted it in the node menu they had to go read the source to figure out what it did. This is the Motorway-ed clone of that node, and the good news is that in this form the whole thing is two key fields and a philosophy.

What it does to your sampling

Classic CFG steers the denoised prediction by the difference between your positive and negative prompts. That's great when you have a meaningful negative prompt and quietly broken when you don't - with an empty negative, the guidance can wander off the positive direction entirely. Mahiro's fix (called "Positive-Biased Guidance" in Comfy's own schema) patches the model so that after each CFG step the result is nudged to scale more along the direction of the positive prompt itself. It computes a similarity between the positive prediction and the merged output, then blends the CFG result with the "leap" toward the positive based on that similarity. More aligned, more CFG; less aligned, pulled back toward positive. No new weights, no training - it's a post_cfg_function bolted onto a clone of your existing model.

In practical terms it's aimed at people who generate with a weak or empty negative prompt and want a firmer hand on the wheel anyway. It's a "try it and see" node, and it costs one extra patched model in the graph, so the experiment is cheap.

The inputs (there are only two that matter)

  • INPUT_model_key - the key in the Motorway holding your MODEL. Default model. This is the model the patch gets applied to.
  • OUTPUT_patched_model_key - the key the patched result is written to. Default patched_model. Wire that key into your sampler's model input instead of the original.

Everything else about it is the Motorway wrapper: the MOTORWAY πŸšŒπŸ’¨ input and output, widgets preserved, node-typed inputs turned into key strings. The clone just instantiates the real Mahiro node, pulls the model out by key, runs the patch, and stores the result. Like the original, it's flagged experimental (_for_testing category) - expect it to change or vanish from a future ComfyUI release, and don't build a production pipeline's identity around it.

Install

Same as every node in the pack - one install covers all Motorway-ed clones. ComfyUI Manager, search "ComfyUI_agilly1989_motorway", or:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart ComfyUI. No requirements.txt, no model downloads.

Troubleshooting

  • If you get 'MotorwayClass' object has no attribute 'hash_', the key you typed (defaults model / patched_model) isn't in the Motorway - confirm whatever stored the model ran first and matches case-for-case.
  • The clone lives in the pack's "clone nodes in the dangerzone" folder for a reason. The newest published version (1.1.7) disabled clone generation while the author reworks it, so on a fresh install you may not find this node in the menu at all. Older 1.1.x builds have it.
  • Mahiro does nothing unless it's wired into the sampler as the model. If you hook up patched_model but sample with the original, the node just silently cloned a model you never used.
Categoryagilly1989 Nodes/Motorway-ed/_for_testing

Inputs (3)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_model_keySTRINGmodelβ€”
OUTPUT_patched_model_keySTRINGpatched_modelβ€”

Outputs (1)

NameTypeDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”