fix: sed patch xflux DoubleStreamBlock.forward for attn_mask compat

This commit is contained in:
2026-06-22 18:16:17 +00:00
parent 81a6e6f150
commit 65cd147189
+2 -10
View File
@@ -21,16 +21,8 @@ RUN cd /app/custom_nodes \
&& git clone --depth 1 https://github.com/XLabs-AI/x-flux-comfyui \ && git clone --depth 1 https://github.com/XLabs-AI/x-flux-comfyui \
&& pip install --no-cache-dir -r x-flux-comfyui/requirements.txt && pip install --no-cache-dir -r x-flux-comfyui/requirements.txt
# Fix: xflux DoubleStreamBlock.forward must accept attn_mask kwarg passed by ComfyUI RUN sed -i 's/def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor) -> tuple\[Tensor, Tensor\]:/def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor, attn_mask=None, transformer_options={}, **kwargs):/' /app/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py \
RUN python3 -c " && grep "attn_mask" /app/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py
path = '/app/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py'
with open(path) as f: c = f.read()
old = ' def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor) -> tuple[Tensor, Tensor]:\n return self.processor(self, img, txt, vec, pe)'
new = ' def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor, attn_mask=None, transformer_options={}, **kwargs):\n return self.processor(self, img, txt, vec, pe)'
assert old in c, 'Pattern not found!'
with open(path, 'w') as f: f.write(c.replace(old, new))
print('Patch applied')
"
RUN useradd -u 1000 -m comfyui && chown -R 1000:1000 /app RUN useradd -u 1000 -m comfyui && chown -R 1000:1000 /app