Nodes/ComfyUI-PolyhedronLoRAStack/⬡ Polyhedron Token Counter
ComfyUI Node

⬡ Polyhedron Token Counter

Counts the prompt against the text encoder's hard token limit and says how close it is. Over the limit, the native path truncates in silence: no crash, the end of the prompt simply never reaches the model. It also distrusts its own trigger_words input - if that socket is handed a serialised config instead of triggers, it says so on the number itself rather than printing a count it does not believe.

By PolyhedronAI·Created 3 months ago·Updated 17 days ago· 2
⬡ Polyhedron Token Counter
    • report
    • positive_tokens
    • negative_tokens
    • over_limit
    • trigger_tokens
    model_limit512
    warn_threshold0.90
    positive_prompt
    negative_prompt
    trigger_words
    CategoryPolyhedron/Utils

    Inputs (5)

    NameTypeDefaultDescription
    model_limitINT51264–8192Max tokens supported by the target model's text encoder. WAN 2.1 / WAN 2.2 = 512 (UMT5-XXL hard limit). FLUX = 512 (T5-XXL). SDXL = 75 per CLIP chunk. Leave at 512 for WAN.
    warn_thresholdFLOAT0.900.5–1Fraction of the limit at which to warn. 0.90 means warn at ≥460 of 512 tokens.
    positive_promptoptSTRINGPositive prompt to count.
    negative_promptoptSTRINGNegative prompt to count.
    trigger_wordsoptSTRINGOptional: wire the Stack's trigger_words output here to see how much of the budget the auto-collected triggers alone consume. Diagnostic only — these are normally already part of the positive prompt, so they are NOT added to over_limit.

    Outputs (5)

    NameTypeDescription
    reportSTRING
    positive_tokensINT
    negative_tokensINT
    over_limitBOOLEAN
    trigger_tokensINT