point_transformer_v3
Point Transformer V3 classification and segmentation models.

Classes:
-
SerializedFeaturesDictβPooledFeaturesDictof a Point Transformer V3 stage, carrying the serialization the decoder blocks re-use. -
PointTransformerV3BlockβTransformer block over serialized patches: an xCPE sparse-convolution residual, then pre-normed
-
PointTransformerV3EncoderBlockβOne encoder stage: an optional pooling downsampling, then
depthPointTransformerV3Blockunits. -
PointTransformerV3DecoderBlockβOne decoder stage: an optional upsampling onto the skip resolution, then
depthPointTransformerV3Blockunits -
PointTransformerV3EncoderβPoint Transformer V3 encoder backbone.
-
PointTransformerV3DecoderβPoint Transformer V3 decoder with skip connections.
-
PointTransformerV3ClassificationβPyTorch implementation of the Point Transformer V3 model, as described in the paper
-
PointTransformerV3SegmentationβPyTorch implementation of the Point Transformer V3 model for segmentation tasks.
Functions:
-
serializeβEncode voxel-grid coordinates along one or more space-filling curves and sort the points by each code.
-
encoder_checkpoint_filter_fnβRename the keys of a released Sonata, Concerto or Utonia encoder checkpoint to the
PointTransformerV3Encoder -
segmentation_checkpoint_filter_fnβRename the keys of a released segmentation checkpoint (a
backbone.encoder and decoder with aseg_head) to -
pretrained_encoder_hparamsβThe
PointTransformerV3Encoderhparams shared by the released Sonata, Concerto and Utonia encoders: a linear
SerializedFeaturesDict [source] ΒΆ
Bases: PooledFeaturesDict
PooledFeaturesDict of a Point Transformer V3 stage, carrying the serialization the decoder blocks re-use.
Attributes:
-
serialized_code(Tensor) βSerialization codes of the stage's points, shape \((L, N_s)\), one row per order.
-
serialized_order(Tensor) βPermutation sorting the points along each order, shape \((L, N_s)\).
-
serialized_inverse(Tensor) βInverse of
serialized_order, shape \((L, N_s)\).
PointTransformerV3Block [source] ΒΆ
PointTransformerV3Block(
channels: int,
num_heads: int,
patch_size: int = 48,
mlp_ratio: float = 4.0,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.0,
act: Union[str, Callable] = "gelu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
cpe_indice_key: Optional[str] = None,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = True,
upcast_softmax: bool = True,
rope_base: float = 10.0,
legacy: bool = False,
)
Bases: Module
Transformer block over serialized patches: an xCPE sparse-convolution residual, then pre-normed patch attention and an MLP.
PointTransformerV3EncoderBlock [source] ΒΆ
PointTransformerV3EncoderBlock(
channels: int,
depth: int,
num_heads: int,
patch_size: int,
mlp_ratio: float = 4.0,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: ValueCollection[float] = 0.0,
act: Union[str, Callable] = "gelu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
cpe_indice_key: Optional[str] = None,
downsample: Optional[Module] = None,
serialization_orders: Optional[
Sequence[SerializationOrder]
] = None,
shuffle_serialization_orders: bool = False,
rope_base: float = 10.0,
legacy: bool = False,
)
Bases: Module
One encoder stage: an optional pooling downsampling, then depth PointTransformerV3Block units.
Consecutive blocks cycle through the available serialization orders, so each attends over a differently ordered patch partition. Grid pooling re-serializes the pooled cloud, while serialized pooling derives the coarser codes by bit-shifting the finer ones.
PointTransformerV3DecoderBlock [source] ΒΆ
PointTransformerV3DecoderBlock(
channels: int,
depth: int,
num_heads: int,
patch_size: int,
mlp_ratio: float = 4.0,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: ValueCollection[float] = 0.0,
act: Union[str, Callable] = "gelu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
cpe_indice_key: Optional[str] = None,
upsample: Optional[SerializedUpsample] = None,
cpe_from_skip: bool = True,
rope_base: float = 10.0,
legacy: bool = False,
)
Bases: Module
One decoder stage: an optional upsampling onto the skip resolution, then depth PointTransformerV3Block units cycling through the skip's serialization orders.
cpe_from_skip picks the features the first block's xCPE convolves after upsampling: the projected skip branch, as serialized unpooling leaves it in the sparse tensor, or the summed output, as grid unpooling does.
PointTransformerV3Encoder [source] ΒΆ
PointTransformerV3Encoder(
in_channels: int = 6,
serialization_orders: Sequence[SerializationOrder] = (
"hilbert",
"hilbert-trans",
),
shuffle_serialization_orders: bool = True,
strides: Sequence[int] = (2, 2, 2, 2),
encoder_depths: Sequence[int] = (2, 2, 2, 6, 2),
encoder_channels: Sequence[int] = (
32,
64,
128,
256,
512,
),
encoder_num_heads: Sequence[int] = (2, 4, 8, 16, 32),
encoder_patch_size: Sequence[int] = (
48,
48,
48,
48,
48,
),
act: Union[str, Callable] = "gelu",
norm: Union[str, Callable] = "batch_norm",
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = True,
mlp_ratio: float = 4,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.3,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
pooling: str = "serialized",
stem_type: str = "sparse_conv",
rope_base: float = 10.0,
legacy: bool = False,
)
Bases: Module
Point Transformer V3 encoder backbone.
Encoder-only backbone for feature extraction from 3D point clouds. Supports both sparse convolution (PTV3 Mode 1) and linear (Sonata / Mode 2) embedding stems, and both serialized (code-space) and grid-based pooling.
Parameters:
-
in_channels(int, default:6) βNumber of input channels.
-
serialization_orders(Sequence[SerializationOrder], default:('hilbert', 'hilbert-trans')) βSerialization orders for attention.
-
shuffle_serialization_orders(bool, default:True) βShuffle orders each forward pass.
-
strides(Sequence[int], default:(2, 2, 2, 2)) βDownsampling strides between encoder stages.
-
encoder_depths(Sequence[int], default:(2, 2, 2, 6, 2)) βNumber of blocks per encoder stage.
-
encoder_channels(Sequence[int], default:(32, 64, 128, 256, 512)) βFeature channels per encoder stage.
-
encoder_num_heads(Sequence[int], default:(2, 4, 8, 16, 32)) βAttention heads per encoder stage.
-
encoder_patch_size(Sequence[int], default:(48, 48, 48, 48, 48)) βPatch size per encoder stage.
-
norm(Union[str, Callable], default:'batch_norm') βNormalization layer type.
-
act(Union[str, Callable], default:'gelu') βActivation function type.
-
mlp_ratio(float, default:4) βMLP expansion ratio.
-
qkv_bias(bool, default:True) βUse bias in QKV projection.
-
qk_scale(Optional[float], default:None) βCustom QK scaling factor.
-
attn_drop(float, default:0.0) βAttention dropout rate.
-
proj_drop(float, default:0.0) βProjection dropout rate.
-
drop_path(float, default:0.3) βDrop path rate.
-
attn_kind(AttentionKind, default:'default') βAttention variant:
"default"(vanilla, PT-V3 / Sonata / Concerto),"rpe"(PT-V3 with learned relative position bias), or"rope"(Utonia, 3D rotary position embedding onQ,K). The"rope"variant requires the real-valuedposargument at forward time. -
use_flash_attn(bool, default:True) βUse Flash Attention. The registered configurations construct with
use_flash_attn=True, which requiresflash-attnand a CUDA device; passuse_flash_attn=Falseto run without it (the xCPE sparse convolution still needs aspconvbuild matching the device; the standard CUDA wheel cannot run on CPU). -
upcast_attn(bool, default:False) βUpcast attention to fp32.
-
upcast_softmax(bool, default:False) βUpcast softmax to fp32.
-
pooling(str, default:'serialized') βPooling strategy:
"serialized"(code-space bit-shift) or"grid"(grid-coordinate clustering). -
stem_type(str, default:'sparse_conv') βHow to embed raw features:
"sparse_conv"(SubMConv3d stem) or"linear"(linear projection). -
rope_base(float, default:10.0) βRoPE frequency base. Only used when
attn_kind="rope". -
act_kwargs(Optional[Dict[str, Any]], default:None) βOptional keyword arguments for the activation factory.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βOptional keyword arguments for the normalization factory.
-
bias(bool, default:True) βWhether the stem and blocks use learnable bias where applicable.
-
legacy(bool, default:False) βReproduce the reference implementation's v1.5.1 block xCPE bug (the block output was not written back to the sparse tensor the next block convolves; fixed in v1.5.2). The released weights need
legacy=True; leaveFalse(default) for new training.
Inputs
x: Float tensor of shape \((N, \text{in\_channels})\). pos_grid: Int tensor of shape \((N, 3)\) with voxel-grid coordinates. batch: Long tensor of shape \((N,)\).
Outputs
Encoded features at the deepest encoder level.
Methods:
-
configure_stemβBuild the embedding stem, either a
LinearBlockor aSubMConv3dBlock. -
configure_blocksβBuild the
PointTransformerV3EncoderBlockstages, giving every stage but the first a pooling downsampling.
Attributes:
-
embedding_dim(int) βFeature dimension \(C\) of the encoder output.
configure_stem [source] ΒΆ
configure_stem(
in_channels: int,
out_channels: int,
norm: Union[str, Callable],
act: Union[str, Callable],
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = True,
stem_type: str = "sparse_conv",
) -> Module
Build the embedding stem, either a LinearBlock or a SubMConv3dBlock.
configure_blocks [source] ΒΆ
configure_blocks(
depths: Sequence[int],
channels: Sequence[int],
num_heads: Sequence[int],
patch_sizes: Sequence[int],
strides: Sequence[int],
mlp_ratio: float = 4.0,
bias: bool = True,
norm: Union[str, Callable] = "batch_norm",
act: Union[str, Callable] = "gelu",
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.0,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
pooling: str = "serialized",
serialization_orders: Optional[
Sequence[SerializationOrder]
] = None,
shuffle_serialization_orders: bool = False,
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
rope_base: float = 10.0,
legacy: bool = False,
) -> ModuleList
Build the PointTransformerV3EncoderBlock stages, giving every stage but the first a pooling downsampling.
PointTransformerV3Decoder [source] ΒΆ
PointTransformerV3Decoder(
encoder_channels: Sequence[int] = (
32,
64,
128,
256,
512,
),
decoder_depths: Sequence[int] = (2, 2, 2, 2),
decoder_channels: Sequence[int] = (256, 128, 64, 64),
decoder_num_heads: Sequence[int] = (16, 8, 4, 4),
decoder_patch_size: Sequence[int] = (48, 48, 48, 48),
norm: Union[str, Callable] = "batch_norm",
act: Union[str, Callable] = "gelu",
mlp_ratio: float = 4,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.3,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
rope_base: float = 10.0,
legacy: bool = False,
pooling: str = "serialized",
)
Bases: Module
Point Transformer V3 decoder with skip connections.
Decoder backbone that upsamples encoder features using skip connections from intermediate encoder stages. Used for dense prediction tasks like semantic segmentation.
Parameters:
-
encoder_channels(Sequence[int], default:(32, 64, 128, 256, 512)) βChannel sequence from the encoder (needed to derive skip-connection channels).
-
decoder_depths(Sequence[int], default:(2, 2, 2, 2)) βNumber of blocks per decoder stage.
-
decoder_channels(Sequence[int], default:(256, 128, 64, 64)) βFeature channels per decoder stage.
-
decoder_num_heads(Sequence[int], default:(16, 8, 4, 4)) βAttention heads per decoder stage.
-
decoder_patch_size(Sequence[int], default:(48, 48, 48, 48)) βPatch size per decoder stage.
-
norm(Union[str, Callable], default:'batch_norm') βNormalization layer type.
-
act(Union[str, Callable], default:'gelu') βActivation function type.
-
mlp_ratio(float, default:4) βMLP expansion ratio.
-
qkv_bias(bool, default:True) βUse bias in QKV projection.
-
qk_scale(Optional[float], default:None) βCustom QK scaling factor.
-
attn_drop(float, default:0.0) βAttention dropout rate.
-
proj_drop(float, default:0.0) βProjection dropout rate.
-
drop_path(float, default:0.3) βDrop path rate.
-
attn_kind(AttentionKind, default:'default') βAttention variant (
"default","rpe", or"rope"). -
use_flash_attn(bool, default:True) βUse Flash Attention.
-
upcast_attn(bool, default:False) βUpcast attention to fp32.
-
upcast_softmax(bool, default:False) βUpcast softmax to fp32.
-
rope_base(float, default:10.0) βRoPE frequency base. Only used when
attn_kind="rope". -
pooling(str, default:'serialized') βPooling the encoder used between stages (
"serialized"or"grid"). After grid pooling the block xCPE convolves the summed upsampling output, after serialized pooling the projected skip, as the reference unpooling modules leave them.
Inputs
x: Encoded features at the deepest encoder level. intermediates: List of dicts from the encoder, each containing skip features, positions, batch indices, serialization tensors, and pooling inverse indices.
Outputs
Decoded features at the shallowest decoder level.
Methods:
-
configure_blocksβBuild the
PointTransformerV3DecoderBlockstages, giving every stage an upsampling onto its skip resolution.
Attributes:
-
out_channels(int) βFeature dimension \(C\) of the decoder output.
configure_blocks [source] ΒΆ
configure_blocks(
depths: Sequence[int],
channels: Sequence[int],
skip_channels: Sequence[int],
num_heads: Sequence[int],
patch_sizes: Sequence[int],
mlp_ratio: float = 4.0,
norm: Union[str, Callable] = "batch_norm",
act: Union[str, Callable] = "gelu",
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.0,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
rope_base: float = 10.0,
legacy: bool = False,
pooling: str = "serialized",
) -> ModuleList
Build the PointTransformerV3DecoderBlock stages, giving every stage an upsampling onto its skip resolution.
PointTransformerV3Classification [source] ΒΆ
PointTransformerV3Classification(
in_channels: int,
num_classes: int,
serialization_orders: Sequence[SerializationOrder] = (
"hilbert",
"hilbert-trans",
),
shuffle_serialization_orders: bool = True,
strides: Sequence[int] = (2, 2, 2, 2),
encoder_depths: Sequence[int] = (2, 2, 2, 6, 2),
encoder_channels: Sequence[int] = (
32,
64,
128,
256,
512,
),
encoder_num_heads: Sequence[int] = (2, 4, 8, 16, 32),
encoder_patch_size: Sequence[int] = (
48,
48,
48,
48,
48,
),
norm: Union[str, Callable] = "batch_norm",
act: Union[str, Callable] = "gelu",
mlp_ratio: float = 4,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.3,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
rope_base: float = 10.0,
dropout: float = 0.0,
global_pool: PoolLike = "max",
pooling: str = "serialized",
stem_type: str = "sparse_conv",
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
legacy: bool = False,
pdnorm_conditions: Optional[Sequence[str]] = None,
condition: Optional[str] = None,
)
Bases: ClassificationModel
PyTorch implementation of the Point Transformer V3 model, as described in the paper Point Transformer V3: Simpler, Faster, Stronger by Xiaoyang Wu, Li Jiang, Peng-Shuai Wang, Zhijian Liu, Xihui Liu, Yu Qiao, Wanli Ouyang, Tong He, Hengshuang Zhao.
This implementation is based on the original implementation from Pointcept.
Important
This model requires spconv to be installed. It is also recommended to install flash-attn for faster attention. The registered configurations construct with use_flash_attn=True, which requires flash-attn and a CUDA device; pass use_flash_attn=False to run without it. The xCPE sparse convolution still needs a spconv build matching the device; the standard CUDA wheel cannot run on CPU. In addition, it is recommended to install ocnn if you want to use more serialization orders.
Parameters:
-
in_channels(int) βNumber of input channels (corresponding to the number of features).
-
num_classes(int) βNumber of output classes.
-
serialization_orders(Sequence[SerializationOrder], default:('hilbert', 'hilbert-trans')) βSerialization orders to use for the
PointTransformerV3Encoder. -
shuffle_serialization_orders(bool, default:True) βWhether to shuffle the serialization orders each step.
-
strides(Sequence[int], default:(2, 2, 2, 2)) βDownsampling strides between encoder stages.
-
encoder_depths(Sequence[int], default:(2, 2, 2, 6, 2)) βNumber of encoder blocks per stage.
-
encoder_channels(Sequence[int], default:(32, 64, 128, 256, 512)) βNumber of channels per stage.
-
encoder_num_heads(Sequence[int], default:(2, 4, 8, 16, 32)) βNumber of attention heads per stage.
-
encoder_patch_size(Sequence[int], default:(48, 48, 48, 48, 48)) βPatch size per stage.
-
norm(Union[str, Callable], default:'batch_norm') βNormalization layer to use.
-
act(Union[str, Callable], default:'gelu') βActivation function to use.
-
mlp_ratio(float, default:4) βMLP hidden dimension ratio inside each block.
-
qkv_bias(bool, default:True) βWhether to use bias in the QKV projection.
-
qk_scale(Optional[float], default:None) βScaling factor for the QK matrix.
-
attn_drop(float, default:0.0) βDropout rate for the attention.
-
proj_drop(float, default:0.0) βDropout rate for the output projection of each block.
-
drop_path(float, default:0.3) βStochastic depth rate.
-
attn_kind(AttentionKind, default:'default') βAttention variant:
"default","rpe", or"rope". The"rope"variant requires the real-valuedposargument at forward time. -
use_flash_attn(bool, default:True) βWhether to use flash attention.
-
upcast_attn(bool, default:False) βWhether to upcast the attention to fp32.
-
upcast_softmax(bool, default:False) βWhether to upcast the softmax in fp32.
-
rope_base(float, default:10.0) βRoPE frequency base. Only used when
attn_kind="rope". -
dropout(float, default:0.0) βDropout rate before the classification head.
-
global_pool(PoolLike, default:'max') βHow to pool point features to a batch-level vector (
"max","mean", etc.). -
pooling(str, default:'serialized') βPooling between encoder stages (
"serialized"or"grid"). -
stem_type(str, default:'sparse_conv') βEncoder stem:
"sparse_conv"or"linear". -
act_kwargs(Optional[Dict[str, Any]], default:None) βOptional keyword arguments for the activation factory.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βOptional keyword arguments for the normalization factory.
Inputs
x: Float tensor of shape \((N, \text{in\_channels})\). pos_grid: Int tensor of shape \((N, 3)\) with voxel-grid coordinates. batch: Long tensor of shape \((N,)\). pos: Float tensor of shape \((N, 3)\) with metric coordinates. Required when attn_kind="rope".
Outputs
logits: Float tensor of shape \((N, \text{num\_classes})\).
Methods:
-
configure_encoderβBuild the
PointTransformerV3Encoderbackbone. -
reset_classifierβResets the classification head with new parameters.
-
forward_headβForward pass of the classification head from pre-pooling features.
-
forwardβForward pass of the Point Transformer V3 classification network.
Attributes:
-
num_features(int) βFeature dimension \(C\) of the encoder output.
configure_encoder [source] ΒΆ
configure_encoder() -> PointTransformerV3Encoder
Build the PointTransformerV3Encoder backbone.
reset_classifier [source] ΒΆ
reset_classifier(
num_classes: int,
global_pool: Optional[PoolLike] = None,
**kwargs: Any,
) -> None
Resets the classification head with new parameters.
Note
To set an empty classification head, use num_classes=0.
Parameters:
-
num_classes(int) βNumber of output classes.
-
global_pool(Optional[PoolLike], default:None) βPooling method to aggregate point features ("max" or "mean").
Nonekeeps the current pooling. -
**kwargs(Any, default:{}) βAdditional keyword arguments to pass to the classification head.
forward_head [source] ΒΆ
Forward pass of the classification head from pre-pooling features.
Parameters:
-
x(Tensor) βPre-pooling features of shape \((N, \text{embedding\_dim})\).
-
batch(Tensor) βBatch indices for each point of shape \((N,)\).
-
pre_logits(bool, default:False) βWhether to return pre-logits. Defaults to False.
Returns:
-
TensorβClassification logits of shape \((B, \text{num\_classes})\).
forward [source] ΒΆ
forward(
x: OptTensor,
pos_grid: Tensor,
batch: Tensor,
pos: OptTensor = None,
*,
condition: Union[str, Sequence[str], None] = None,
) -> Tensor
Forward pass of the Point Transformer V3 classification network.
Parameters:
-
x(OptTensor) βAdditional point features of shape \((N, C)\).
-
pos_grid(Tensor) βInteger grid coordinates of shape \((N, 3)\). The encoder uses these to derive the Z-order / Hilbert serialization index, so they must be voxel indices, not float positions.
-
batch(Tensor) βBatch indices for each point of shape \((N,)\).
-
pos(OptTensor, default:None) βReal-valued metric positions of shape \((N, 3)\). Required when
attn_kind="rope"; ignored otherwise. -
condition(Union[str, Sequence[str], None], default:None) βOptional per-batch condition selecting the PDNorm inner norms (keyword-only).
Returns:
-
TensorβClassification logits of shape \((B, \text{num\_classes})\).
PointTransformerV3Segmentation [source] ΒΆ
PointTransformerV3Segmentation(
in_channels: int,
num_classes: int,
serialization_orders: Sequence[SerializationOrder] = (
"hilbert",
"hilbert-trans",
),
strides: Sequence[int] = (2, 2, 2, 2),
encoder_depths: Sequence[int] = (2, 2, 2, 6, 2),
encoder_channels: Sequence[int] = (
32,
64,
128,
256,
512,
),
encoder_num_heads: Sequence[int] = (2, 4, 8, 16, 32),
encoder_patch_size: Sequence[int] = (
48,
48,
48,
48,
48,
),
decoder_depths: Sequence[int] = (2, 2, 2, 2),
decoder_channels: Sequence[int] = (256, 128, 64, 64),
decoder_num_heads: Sequence[int] = (16, 8, 4, 4),
decoder_patch_size: Sequence[int] = (48, 48, 48, 48),
norm: Union[str, Callable] = "batch_norm",
act: Union[str, Callable] = "gelu",
mlp_ratio: float = 4,
qkv_bias: bool = True,
qk_scale: Optional[float] = None,
attn_drop: float = 0.0,
proj_drop: float = 0.0,
drop_path: float = 0.3,
shuffle_serialization_orders: bool = True,
attn_kind: AttentionKind = "default",
use_flash_attn: bool = True,
upcast_attn: bool = False,
upcast_softmax: bool = False,
rope_base: float = 10.0,
dropout: float = 0.0,
pooling: str = "serialized",
stem_type: str = "sparse_conv",
act_kwargs: Optional[Dict[str, Any]] = None,
norm_kwargs: Optional[Dict[str, Any]] = None,
legacy: bool = False,
pdnorm_conditions: Optional[Sequence[str]] = None,
condition: Optional[str] = None,
)
Bases: SemanticSegmentationModel
PyTorch implementation of the Point Transformer V3 model for segmentation tasks.
Based on the paper Point Transformer V3: Simpler, Faster, Stronger by Xiaoyang Wu, Li Jiang, Peng-Shuai Wang, Zhijian Liu, Xihui Liu, Yu Qiao, Wanli Ouyang, Tong He, Hengshuang Zhao.
This segmentation variant uses an encoder-decoder architecture with skip connections.
Parameters:
-
in_channels(int) βNumber of input channels.
-
num_classes(int) βNumber of output classes for segmentation.
-
serialization_orders(Sequence[SerializationOrder], default:('hilbert', 'hilbert-trans')) βSerialization orders to use for the encoder.
-
strides(Sequence[int], default:(2, 2, 2, 2)) βStrides for the downsampling operations.
-
encoder_depths(Sequence[int], default:(2, 2, 2, 6, 2)) βNumber of encoder blocks for each stage.
-
encoder_channels(Sequence[int], default:(32, 64, 128, 256, 512)) βNumber of channels for each encoder block.
-
encoder_num_heads(Sequence[int], default:(2, 4, 8, 16, 32)) βNumber of attention heads for each encoder block.
-
encoder_patch_size(Sequence[int], default:(48, 48, 48, 48, 48)) βPatch size for each encoder block.
-
decoder_depths(Sequence[int], default:(2, 2, 2, 2)) βNumber of decoder blocks for each stage.
-
decoder_channels(Sequence[int], default:(256, 128, 64, 64)) βNumber of channels for each decoder block.
-
decoder_num_heads(Sequence[int], default:(16, 8, 4, 4)) βNumber of attention heads for each decoder block.
-
decoder_patch_size(Sequence[int], default:(48, 48, 48, 48)) βPatch size for each decoder block.
-
norm(Union[str, Callable], default:'batch_norm') βNormalization layer to use.
-
act(Union[str, Callable], default:'gelu') βActivation function to use.
-
mlp_ratio(float, default:4) βRatio of the hidden dimension to the input dimension.
-
qkv_bias(bool, default:True) βWhether to use bias in the QKV projection.
-
qk_scale(Optional[float], default:None) βScaling factor for the QK matrix.
-
attn_drop(float, default:0.0) βDropout rate for the attention.
-
proj_drop(float, default:0.0) βDropout rate for the projection.
-
drop_path(float, default:0.3) βDropout rate for the drop path.
-
shuffle_serialization_orders(bool, default:True) βWhether to shuffle the serialization orders.
-
attn_kind(AttentionKind, default:'default') βAttention variant:
"default","rpe", or"rope". The"rope"variant requires the real-valuedposargument at forward time. -
rope_base(float, default:10.0) βRoPE frequency base. Only used when
attn_kind="rope". -
use_flash_attn(bool, default:True) βWhether to use flash attention. The registered configurations construct with
use_flash_attn=True, which requiresflash-attnand a CUDA device; passuse_flash_attn=Falseto run without it (the xCPE sparse convolution still needs aspconvbuild matching the device; the standard CUDA wheel cannot run on CPU). -
upcast_attn(bool, default:False) βWhether to upcast the attention.
-
upcast_softmax(bool, default:False) βWhether to upcast the softmax.
-
dropout(float, default:0.0) βDropout on the per-point logits.
-
pooling(str, default:'serialized') βInter-stage pooling (
"serialized"or"grid"). -
stem_type(str, default:'sparse_conv') βEncoder stem (
"sparse_conv"or"linear"). -
act_kwargs(Optional[Dict[str, Any]], default:None) βOptional keyword arguments for the activation factory.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βOptional keyword arguments for the normalization factory.
Methods:
-
configure_encoderβBuild the
PointTransformerV3Encoderbackbone. -
configure_decoderβBuild the
PointTransformerV3Decoderupsampling the coarsest features back through the encoder skips. -
reset_classifierβResets the segmentation head with new parameters.
-
forwardβForward pass of the Point Transformer V3 segmentation network.
Attributes:
-
num_features(int) βChannel count \(C\) of the per-point decoder features entering the head.
num_features property ΒΆ
Channel count \(C\) of the per-point decoder features entering the head.
configure_encoder [source] ΒΆ
configure_encoder() -> PointTransformerV3Encoder
Build the PointTransformerV3Encoder backbone.
configure_decoder [source] ΒΆ
configure_decoder() -> PointTransformerV3Decoder
Build the PointTransformerV3Decoder upsampling the coarsest features back through the encoder skips.
reset_classifier [source] ΒΆ
Resets the segmentation head with new parameters.
Note
To set an empty segmentation head, use num_classes=0.
Parameters:
-
num_classes(int) βNumber of output classes.
-
**kwargs(Any, default:{}) βAdditional keyword arguments to pass to the segmentation head.
forward [source] ΒΆ
forward(
x: Tensor,
pos_grid: Tensor,
batch: Tensor,
pos: OptTensor = None,
*,
condition: Union[str, Sequence[str], None] = None,
) -> Tensor
Forward pass of the Point Transformer V3 segmentation network.
Parameters:
-
x(Tensor) βPer-point features of shape \((N, C)\).
-
pos_grid(Tensor) βInteger grid coordinates of shape \((N, 3)\) used for serialization.
-
batch(Tensor) βBatch indices for each point of shape \((N,)\).
-
pos(OptTensor, default:None) βReal-valued metric positions of shape \((N, 3)\). Required when
attn_kind="rope"; ignored otherwise. -
condition(Union[str, Sequence[str], None], default:None) βOptional per-batch condition selecting the PDNorm inner norms (keyword-only).
Returns:
-
TensorβPer-point segmentation logits of shape \((N, \text{num\_classes})\).
serialize [source] ΒΆ
serialize(
pos_grid: Tensor,
batch: Tensor,
orders: Sequence[SerializationOrder],
shuffle: bool = False,
) -> Tuple[Tensor, Tensor, Tensor]
Encode voxel-grid coordinates along one or more space-filling curves and sort the points by each code.
Parameters:
-
pos_grid(Tensor) βNon-negative integer grid coordinates of shape \((N, 3)\).
-
batch(Tensor) βPer-point batch index of shape \((N,)\).
-
orders(Sequence[SerializationOrder]) βThe \(L\) space-filling curves to encode along, one code row per order.
-
shuffle(bool, default:False) βWhether to permute
ordersbefore encoding, so consecutive blocks pick different curves.
Returns:
-
TensorβThe serialization codes, the permutation sorting the points by code, and its inverse, each of
-
Tensorβshape \((L, N)\).
Raises:
-
ValueErrorβIf
pos_gridholds a negative coordinate, which would silently wrap around to a valid code.
encoder_checkpoint_filter_fn [source] ΒΆ
Rename the keys of a released Sonata, Concerto or Utonia encoder checkpoint to the PointTransformerV3Encoder ones, as the pretrained_filter_fn of a WeightsDict.
The masked-modelling embedding.mask_token is dropped. When model holds the encoder as its encoder submodule (a linear-probing segmentation model), the encoder keys move under encoder. and the seg_head of the probe head file becomes head.
Parameters:
-
state_dict(Dict[str, Any]) βState dict keyed as in the released checkpoint files.
-
model(Module) βModel the state dict is loaded into.
Returns:
-
Dict[str, Any]βThe state dict keyed as
modelexpects.
segmentation_checkpoint_filter_fn [source] ΒΆ
Rename the keys of a released segmentation checkpoint (a backbone. encoder and decoder with a seg_head) to the PointTransformerV3Segmentation ones, as the pretrained_filter_fn of a WeightsDict.
The released decoder names its stages after the encoder stage they upsample to, so the deepest runs first; model numbers them in execution order: dec{i} of n stages becomes decoder.blocks.{n - 1 - i}.
Parameters:
-
state_dict(Dict[str, Any]) βState dict keyed as in the released checkpoint file.
-
model(Module) βPointTransformerV3Segmentationthe state dict is loaded into.
Returns:
-
Dict[str, Any]βThe state dict keyed as
modelexpects.
pretrained_encoder_hparams [source] ΒΆ
pretrained_encoder_hparams(
encoder_depths: Sequence[int],
encoder_channels: Sequence[int],
encoder_num_heads: Sequence[int],
) -> Dict[str, Any]
The PointTransformerV3Encoder hparams shared by the released Sonata, Concerto and Utonia encoders: a linear stem on 9 input channels (position, color, normal), grid pooling and node-mode layer norm. The sizes differ by depth, width and head count only.
Parameters:
-
encoder_depths(Sequence[int]) βNumber of blocks per stage.
-
encoder_channels(Sequence[int]) βFeature width per stage.
-
encoder_num_heads(Sequence[int]) βAttention heads per stage.
Returns:
-
Dict[str, Any]βKeyword arguments for
PointTransformerV3Encoder.