File size: 2,457 Bytes
c4f8e4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from pydantic import BaseModel, Field, model_validator
from typing import Optional

class ActionTokenizerConfig(BaseModel):
    ...

# class BinActionTokenizerConfig(ActionTokenizerConfig):
#     bins: int = 256
#     min_action: float = -1.0
#     max_action: float = 1.0


# #### FSQModel
# class VQVaeActionTokenizerConfig(ActionTokenizerConfig):
#     ## vqvae arch
#     quantizer_name: str = "fsq" # choices=['residualvq', 'group_residualvq', 'part_group_residualvq', 'lfq', 'fsq']
#     dim_motion: int = 48
#     code_dim: int = 512
#     nb_code: int = 512
#     mu: float = 0.99
#     down_t: int = 2
#     stride_t: int = 2
#     width: int = 512
#     depth: int = 3
#     dilation_growth_rate: int = 3
#     output_emb_width: int = 512
#     activate: str = 'relu' # choices=['relu', 'silu', 'gelu']
#     norm: Optional[str] = None
#     num_conv_layers: int = 1
#     num_quantizers: int = 1
#     shared_codebook: bool = False


#     # loss related
#     commit_weight: float = 0.02
#     vel_weight: float = 0.5
#     recons_loss: str = 'l1_smooth'


#     # for openvla_rlds_vqvae
#     pretrained_checkpoint: str | None = None
#     freeze_vqvae: bool = True  # Whether to freeze VQ-VAE parameters during training


### ResidualVQModel
class VQVaeActionTokenizerConfig(ActionTokenizerConfig):
    ## vqvae arch
    quantizer_name: str = "residualvq" # choices=['residualvq', 'group_residualvq', 'part_group_residualvq', 'lfq', 'fsq']
    dim_motion: int = 48
    code_dim: int = 512
    nb_code: int = 512
    mu: float = 0.99
    down_t: int = 2
    stride_t: int = 2
    width: int = 512
    depth: int = 3
    dilation_growth_rate: int = 3
    output_emb_width: int = 512
    activate: str = 'relu' # choices=['relu', 'silu', 'gelu']
    norm: Optional[str] = None
    num_conv_layers: int = 1
    num_quantizers: int = 8
    shared_codebook: bool = False


    # loss related
    commit_weight: float = 0.02
    vel_weight: float = 0.5
    recons_loss: str = 'l1_smooth'


    # for openvla_rlds_vqvae
    pretrained_checkpoint: str | None = None
    freeze_vqvae: bool = True  # Whether to freeze VQ-VAE parameters during training


class FastActionTokenizerConfig(ActionTokenizerConfig):
    bins: int = 2048
    pretrained_checkpoint: str | None = None

class VQActionTokenizerConfig(ActionTokenizerConfig):
    bins: int = 256
    pretrained_checkpoint: str = ""

class TextActionTokenizerConfig(ActionTokenizerConfig):
    pass