ComfyUI_SDXL_LongContext
SDXL Long Context extends SDXL positional embeddings from 77 to 248 tokens using learned sinusoidal extrapolation method. (Description by CC)
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
-
Download repository as ZIP. Copy paste scripts directory from repository to: C:\Users\User\Documents\ComfyUI_windows_portable
-
Edit convert_spectral.bat — set your checkpoint filename: set "CKPT_NAME=FernflowerAI-2D.safetensors"
-
Double-click convert_learned.bat. Script will generate: -> your_model_long248.safetensors in ComfyUI\models\checkpoints directory
-
Create directory sdxl_long_context in ComfyUI\custom_nodes directory
-
Copy paste init.py and nodes.py to sdxl_long_context directory
-
Restart ComfyUI
-
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