Extensions/ComfyUI_SDXL_LongContext
ComfyUI Extension

ComfyUI_SDXL_LongContext

SDXL Long Context extends SDXL positional embeddings from 77 to 248 tokens using learned sinusoidal extrapolation method. (Description by CC)

By brahianrosswill·Created 6 months ago·Updated 6 months ago· 0
brahianrosswill/ComfyUI_SDXL_LongContext
Nodes
On cloudLocal install
Stars0
Updated6 months ago
Readme

SDXL Long Context — Learned Sinusoidal Extrapolation Method Technical Description

OVERVIEW

This method extends SDXL positional embeddings from 77 to 248 tokens by reverse-engineering the mathematical structure that CLIP text encoders learn during training, then using that structure to generate embeddings for positions beyond the original training range.

Instead of blind signal processing (FFT, interpolation, repetition), this approach fits explicit parametric models — the same mathematical forms used in transformer positional encoding — to the learned weights, then evaluates those models at extended positions.

QUICK START

  1. Download repository as ZIP. Copy paste scripts directory from repository to: C:\Users\User\Documents\ComfyUI_windows_portable

  2. Edit convert_spectral.bat — set your checkpoint filename: set "CKPT_NAME=FernflowerAI-2D.safetensors"

  3. Double-click convert_learned.bat. Script will generate: -> your_model_long248.safetensors in ComfyUI\models\checkpoints directory

  4. Create directory sdxl_long_context in ComfyUI\custom_nodes directory

  5. Copy paste init.py and nodes.py to sdxl_long_context directory

  6. Restart ComfyUI

  7. Use workflow_sdxl_long248.json from examples directory

IMPORTANT

  • Always convert from ORIGINAL checkpoint, not already converted
  • Prompts up to 77 tokens = almost identical to original model
  • Only 248 tokens is stable. 512+ breaks the model.
  • Works with any SDXL checkpoint (base, fine-tuned, merged)
  • VRAM increase is minimal (~0.5 GB)

LICENSE: MIT