Pt Bitwise Right Shift
Floor-division by powers of two, the fast way
- tens_a
- tens_b
- TENSOR
Right shift is the inverse of left shift, and the mental math is equally clean: shifting an integer right by one position floor-divides it by two. Shift right by n and you get value // 2**n, no floating point involved. Pt Bitwise Right Shift wraps torch.bitwise_right_shift(tens_a, tens_b), where tens_a is the value and tens_b is how many positions to shift.
In bit-packing terms this is the extraction half of the story: you packed several small integers into one field, and now you shift right to pull a specific chunk back out before masking it with PtBitwiseAnd. That packing/extraction pair is the single most common reason anyone touches this node.
Inputs
tens_a- theTENSORwhose bits get shifted (integer dtype).tens_b- theTENSORof shift counts, same shape.
Output is a same-shape TENSOR with tens_a >> tens_b.
The honest take
Like the rest of this pack's bitwise cluster, it's a one-line PyTorch wrapper with no hidden behavior. You will not need it for anything involving image generation, ControlNet, or samplers - this pack lives in a different corner of ComfyUI, the data-science corner, and right shift is a niche of a niche.
The failure modes are the same as its siblings: float tensors error (cast with PtToInt32 first), and shift amounts that exceed the bit width or go negative will give you junk or a runtime error. For the common case - extracting bits from a packed integer - keep tens_b small and you're fine. And remember it's floor division: for negative values the result differs from regular Python's // behavior on floats, so don't use shifts as a general-purpose divide. If you just want plain division, PtDiv is the node.
Installing it
Ships in ComfyUI-Pt-Wrapper by Hide Inada (HowToSD). Install via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") and restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
The pack pulls a large dependency tree - pandas, scipy, scikit-learn, transformers, datasets, gensim, peft, accelerate, seaborn, matplotlib. If the auto-install dies, run pip install -r requirements.txt inside the cloned directory. No model downloads needed for the tensor nodes.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — | |
| tens_b | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |