ComfyUI Node

NNT Define GRU Layer

NNT Define GRU Layer — the cheaper cousin of the LSTM, in node form

By inventorado·Created 2 years ago·Updated 2 years ago· 69
NNT Define GRU Layer
  • LAYER_STACK
  • LAYER_STACK
input_size10
hidden_size20
num_layers1
biasTrue
batch_firstTrue
dropout0.0
bidirectionalFalse

The GRU is the LSTM's lighter sibling: same job - remembering things across a sequence - with fewer gates and less compute. For a lot of sequence tasks it gets you 95% of the LSTM's capability at a smaller footprint, which is why it's worth having in the toolkit even though it looks almost identical to its sibling node. NntDefineGRULayer appends a GRU definition to your LAYER_STACK.

The inputs

Identical field-for-field to the LSTM node, because a GRU constructor is basically an LSTM constructor with the forget-gate drama removed:

  • input_size (default 10) - features per time step.
  • hidden_size (default 20) - hidden state width.
  • num_layers (default 1) - stacked GRUs.
  • bias (True), batch_first (True), dropout (0), bidirectional (False).

Output: LAYER_STACK. The node records {'type': 'GRU', ...} and passes the growing list along.

How it works - same story as LSTM, so read it once

The pattern for the recurrent nodes in this pack is uniform: the define node writes a config dict onto the stack list, and NntCompileModel is supposed to turn that into nn.GRU at build time. The honest caveat from the source (v1.0.3): the compile loop currently materializes the classic layer types - Conv, Linear, Flatten, Reshape, pooling, norms - and GRU isn't in that dispatch list yet. The nn.GRU class appears nowhere in the compile path. So this node is currently a declaration: it builds the stack entry, but the model-building step that should instantiate it hasn't landed.

That's not a bug report against you - it's just where the pack is. It's an educational hobby project and the author says so. If your compiled model doesn't contain the GRU, that's expected behavior today, not a workflow mistake. Treat it as a node to learn the stack format with, and reach for plain PyTorch if you need a trainable GRU now.

Common issues

  • GRU missing from the compiled model - expected; see above.
  • Choosing GRU vs LSTM - if and when these compile, GRU wins on speed and memory, LSTM is the classic default. For teaching purposes the difference is the lesson.

Install

Pack-level, nothing special:

cd ComfyUI/custom_nodes
git clone https://github.com/inventorado/ComfyUI_NNT.git
cd ComfyUI_NNT
pip install -r requirements.txt

or ComfyUI Manager → "ComfyUI Neural Network Toolkit NNT", then restart ComfyUI. It sits with the other recurrent nodes under NNT Neural Network Toolkit/Layers.

CategoryNNT Neural Network Toolkit/Layers

Inputs (8)

NameTypeDefaultDescription
input_sizeINT101–2048
hidden_sizeINT201–2048
num_layersINT11–10
biasCOMBOTrue2 options: True, False
batch_firstCOMBOTrue2 options: True, False
dropoutFLOAT0.00–1
bidirectionalCOMBOFalse2 options: True, False
LAYER_STACKoptLIST

Outputs (1)

NameTypeDescription
LAYER_STACKLIST