openpi icon indicating copy to clipboard operation
openpi copied to clipboard

loss explosion and not converge

Open yanan1116 opened this issue 1 year ago • 22 comments

i have always been using this config below and it did not causes any error and the checkpoints works fine.

    TrainConfig(
        name="pi05_base-genesis_self_collect_pick_red_cube_ee_abs-nodeltatrans",
        model=pi0_config.Pi0Config(pi05=True, action_horizon=10, discrete_state_input=False),
        data=LeRobotLiberoDataConfig(
            repo_id="yananchen/genesis_self_collect_pick_red_cube_ee_abs",
            base_config=DataConfig(prompt_from_task=True),
            extra_delta_transform=False,
        ),
        batch_size=64,
        lr_schedule=_optimizer.CosineDecaySchedule(
            warmup_steps=10_000,
            peak_lr=5e-5,
            decay_steps=1_000_000,
            decay_lr=5e-5,
        ),
        optimizer=_optimizer.AdamW(clip_gradient_norm=1.0),
        freeze_filter=pi0_config.Pi0Config(
            paligemma_variant="gemma_2b_lora", action_expert_variant="gemma_300m_lora"
        ).get_freeze_filter(),
        ema_decay=None,
        weight_loader=weight_loaders.CheckpointWeightLoader("gs://openpi-assets/checkpoints/pi05_base/params"),
        # pytorch_weight_path="/path/to/your/pytorch_weight_path",
        num_train_steps=100_000,
        wandb_enabled=False,
    ),

however, this time i encounter the loss did not converge the value is unnormal. the checkpoint does not learn anything useful.

Step 0: grad_norm=42428.3164, loss=4455984128.0000, param_norm=1802.3843
Step 100: grad_norm=9733.3320, loss=270172288.0000, param_norm=1802.3843
Step 200: grad_norm=10547.5195, loss=428922144.0000, param_norm=1802.3840
Step 300: grad_norm=10625.2793, loss=503149024.0000, param_norm=1802.3840
Step 400: grad_norm=10061.1963, loss=395684576.0000, param_norm=1802.3837
Step 500: grad_norm=11206.5449, loss=597274880.0000, param_norm=1802.3834
Step 600: grad_norm=8955.1885, loss=335899232.0000, param_norm=1802.3834
Step 700: grad_norm=11221.3105, loss=582588736.0000, param_norm=1802.3837
Step 800: grad_norm=12643.8594, loss=356632480.0000, param_norm=1802.3839
Step 900: grad_norm=17032.3828, loss=325648256.0000, param_norm=1802.3846
Step 1000: grad_norm=18550.5527, loss=183984048.0000, param_norm=1802.3854
Step 1100: grad_norm=26488.5195, loss=465837728.0000, param_norm=1802.3867
Step 1200: grad_norm=31794.9824, loss=587410752.0000, param_norm=1802.3881
Step 1300: grad_norm=35957.1211, loss=635810816.0000, param_norm=1802.3900
Step 1400: grad_norm=31383.3242, loss=260584336.0000, param_norm=1802.3918
Step 1500: grad_norm=41220.9766, loss=726546752.0000, param_norm=1802.3942
Step 1600: grad_norm=48064.6602, loss=448036224.0000, param_norm=1802.3969
Step 1700: grad_norm=48309.5781, loss=349050816.0000, param_norm=1802.3999
Step 1800: grad_norm=52535.3320, loss=399005632.0000, param_norm=1802.4031
Step 1900: grad_norm=51209.5195, loss=239943344.0000, param_norm=1802.4065
Step 2000: grad_norm=58153.7656, loss=475945856.0000, param_norm=1802.4099
Step 2100: grad_norm=67178.3672, loss=594960832.0000, param_norm=1802.4135
Step 2200: grad_norm=58703.6680, loss=269423392.0000, param_norm=1802.4166
Step 2300: grad_norm=60908.3281, loss=337792512.0000, param_norm=1802.4203
Step 2400: grad_norm=76694.9766, loss=339369024.0000, param_norm=1802.4241
Step 2500: grad_norm=82912.8047, loss=551790080.0000, param_norm=1802.4277
Step 2600: grad_norm=84520.0703, loss=469687488.0000, param_norm=1802.4315
Step 2700: grad_norm=73268.6406, loss=362459872.0000, param_norm=1802.4349
Step 2800: grad_norm=85909.3672, loss=269993184.0000, param_norm=1802.4384
Step 2900: grad_norm=97589.2578, loss=356184992.0000, param_norm=1802.4419
Step 3000: grad_norm=124934.8203, loss=630651840.0000, param_norm=1802.4453
Step 3100: grad_norm=113131.1094, loss=585547264.0000, param_norm=1802.4487
Step 3200: grad_norm=134768.3594, loss=598229248.0000, param_norm=1802.4520
Step 3300: grad_norm=125678.1562, loss=247623488.0000, param_norm=1802.4553
Step 3400: grad_norm=116248.5703, loss=525452160.0000, param_norm=1802.4584
Step 3500: grad_norm=125749.9609, loss=461091840.0000, param_norm=1802.4618
Step 3600: grad_norm=155541.0000, loss=247461536.0000, param_norm=1802.4653
Step 3700: grad_norm=147741.4531, loss=653145472.0000, param_norm=1802.4681
Step 3800: grad_norm=154517.2344, loss=385248192.0000, param_norm=1802.4712
Step 3900: grad_norm=190455.1094, loss=292619488.0000, param_norm=1802.4744
Step 4000: grad_norm=165326.1719, loss=426971552.0000, param_norm=1802.4778
Step 4100: grad_norm=185573.5938, loss=411330496.0000, param_norm=1802.4806
Step 4200: grad_norm=169827.9219, loss=346864992.0000, param_norm=1802.4840
Step 4300: grad_norm=186055.3906, loss=453237760.0000, param_norm=1802.4878
Step 4400: grad_norm=202503.5781, loss=444049568.0000, param_norm=1802.4912
Step 4500: grad_norm=198841.2812, loss=347236288.0000, param_norm=1802.4946
Step 4600: grad_norm=226166.1562, loss=392481632.0000, param_norm=1802.4984
Step 4700: grad_norm=251287.7188, loss=499067456.0000, param_norm=1802.5022
Step 4800: grad_norm=286629.7188, loss=394617472.0000, param_norm=1802.5056
Step 4900: grad_norm=352235.4062, loss=633822080.0000, param_norm=1802.5093
Step 5000: grad_norm=349187.8438, loss=221160096.0000, param_norm=1802.5125
Step 5100: grad_norm=440111.0625, loss=429969920.0000, param_norm=1802.5159
Step 5200: grad_norm=467993.7812, loss=615082688.0000, param_norm=1802.5193
Step 5300: grad_norm=398584.6250, loss=348464032.0000, param_norm=1802.5231
Step 5400: grad_norm=464347.1250, loss=446079648.0000, param_norm=1802.5271
Step 5500: grad_norm=483245.0312, loss=619981696.0000, param_norm=1802.5309
Step 5600: grad_norm=538705.4375, loss=320443968.0000, param_norm=1802.5349
Step 5700: grad_norm=574690.7500, loss=438120832.0000, param_norm=1802.5387
Step 5800: grad_norm=516636.1562, loss=465989376.0000, param_norm=1802.5427
Step 5900: grad_norm=681325.8125, loss=344671968.0000, param_norm=1802.5465
Step 6000: grad_norm=846482.3750, loss=436317056.0000, param_norm=1802.5505
Step 6100: grad_norm=549847.8750, loss=247026608.0000, param_norm=1802.5544
Step 6200: grad_norm=775058.3750, loss=536607616.0000, param_norm=1802.5588
Step 6300: grad_norm=897108.3125, loss=267218320.0000, param_norm=1802.5636
Step 6400: grad_norm=968878.0625, loss=658586624.0000, param_norm=1802.5681
Step 6500: grad_norm=725348.6875, loss=429716640.0000, param_norm=1802.5725
Step 6600: grad_norm=1168754.7500, loss=392010944.0000, param_norm=1802.5768
Step 6700: grad_norm=971743.1875, loss=482869024.0000, param_norm=1802.5815
Step 6800: grad_norm=880253.2500, loss=197257216.0000, param_norm=1802.5867
Step 6900: grad_norm=900671.1250, loss=401711744.0000, param_norm=1802.5916
Step 7000: grad_norm=978040.0625, loss=458975520.0000, param_norm=1802.5967
Step 7100: grad_norm=1013011.1250, loss=587125760.0000, param_norm=1802.6018
Step 7200: grad_norm=1019747.5625, loss=603648512.0000, param_norm=1802.6072
Step 7300: grad_norm=1052039.1250, loss=294684352.0000, param_norm=1802.6134
Step 7400: grad_norm=1104884.8750, loss=401008768.0000, param_norm=1802.6189
Step 7500: grad_norm=1133271.8750, loss=300948032.0000, param_norm=1802.6245
Step 7600: grad_norm=1154049.6250, loss=556811840.0000, param_norm=1802.6302
Step 7700: grad_norm=1290454.2500, loss=484517952.0000, param_norm=1802.6361
Step 7800: grad_norm=1239534.5000, loss=382912960.0000, param_norm=1802.6418
Step 7900: grad_norm=1401604.1250, loss=535536928.0000, param_norm=1802.6481
Step 8000: grad_norm=1124354.8750, loss=353101952.0000, param_norm=1802.6543
Step 8100: grad_norm=1330590.7500, loss=455153248.0000, param_norm=1802.6608
Step 8200: grad_norm=1662245.7500, loss=238609328.0000, param_norm=1802.6716
Step 8300: grad_norm=1070714.0000, loss=321045632.0000, param_norm=1802.6862
Step 8400: grad_norm=1189851.0000, loss=749049600.0000, param_norm=1802.6973
Step 8500: grad_norm=641726.0000, loss=350157856.0000, param_norm=1802.7087
Step 8600: grad_norm=791260.6875, loss=525327712.0000, param_norm=1802.7246
Step 8700: grad_norm=643611.2500, loss=456855616.0000, param_norm=1802.7396
Step 8800: grad_norm=648928.8125, loss=310116096.0000, param_norm=1802.7520
Step 8900: grad_norm=720912.6250, loss=472699776.0000, param_norm=1802.7648
Step 9000: grad_norm=760532.2500, loss=407122688.0000, param_norm=1802.7759
Step 9100: grad_norm=622872.8125, loss=422562528.0000, param_norm=1802.7896
Step 9200: grad_norm=670702.1875, loss=425237440.0000, param_norm=1802.8009
Step 9300: grad_norm=690730.2500, loss=543700928.0000, param_norm=1802.8119
Step 9400: grad_norm=653421.2500, loss=500191808.0000, param_norm=1802.8253
Step 9500: grad_norm=586115.1875, loss=413367904.0000, param_norm=1802.8357
Step 9600: grad_norm=717062.2500, loss=398324768.0000, param_norm=1802.8494
Step 9700: grad_norm=772330.8750, loss=411376288.0000, param_norm=1802.8612
Step 9800: grad_norm=549117.0625, loss=307878208.0000, param_norm=1802.8723
Step 9900: grad_norm=578951.6250, loss=311249088.0000, param_norm=1802.8839
Step 10000: grad_norm=679569.8750, loss=404387840.0000, param_norm=1802.8973
Step 10100: grad_norm=709223.6875, loss=404078496.0000, param_norm=1802.9110
Step 10200: grad_norm=658804.8125, loss=683833344.0000, param_norm=1802.9230
Step 10300: grad_norm=547986.8125, loss=260065728.0000, param_norm=1802.9323
Step 10400: grad_norm=805208.4375, loss=638999040.0000, param_norm=1802.9423
Step 10500: grad_norm=359832.0625, loss=203552592.0000, param_norm=1802.9568
Step 10600: grad_norm=764498.5625, loss=487308864.0000, param_norm=1802.9678
Step 10700: grad_norm=720295.8125, loss=516902080.0000, param_norm=1802.9735

any possible causes for this ?

yanan1116 avatar Dec 02 '25 21:12 yanan1116

the norm_stats.json after uv run python scripts/compute_norm_stats.py

is it because the values of actions are too close to zero which causes numeric instability ?

{
  "norm_stats": {
    "state": {
      "mean": [
        0.301199346780777,
        0.2090054303407669,
        0.3108702600002289,
        0.015071570873260498,
        -0.00402136379852891,
        0.6693373918533325,
        0.03223223239183426,
        0.032243505120277405
      ],
      "std": [
        0.24634718894958496,
        0.23574261367321014,
        0.16496814787387848,
        0.12026138603687286,
        0.0777687281370163,
        3.0535709857940674,
        0.010693548247218132,
        0.010707397945225239
      ],
      "q01": [
        -0.43754340294599536,
        -0.4821332550048828,
        0.130424203813076,
        -0.05528819303512572,
        -0.25868174762725826,
        -3.1415927410125732,
        -0.00004182962495833612,
        -0.00007873999467119565
      ],
      "q99": [
        0.6710306460499762,
        0.47940248260498053,
        0.5678430295586585,
        0.5572348650932312,
        0.24429144802093505,
        3.140335865545273,
        0.04159356473851949,
        0.04192314930167049
      ]
    },

    "actions":  # delta x y z roll pitch yaw gripper, 
{
      "mean": [
        -0.0004126667627133429,
        0.00031892865081317723,
        -0.00008734524453757331,
        0.0,
        0.0,
        -8.777653420111164e-6,
        0.4229417145252228
      ],
      "std": [
        0.004524962045252323,
        0.004427351523190737,
        0.0032394288573414087,
        0.0,
        0.0,
        0.0007520596263930202,
        0.4940263330936432
      ],
      "q01": [
        -0.0061907957971095995,
        -0.00660119787454605,
        -0.006115201342105858,
        0.0,
        0.0,
        -3.999999910592883e-6,
        0.0
      ],
      "q99": [
        0.0058500044047832545,
        0.0057696021080017035,
        0.005937598460912713,
        0.0,
        0.0,
        -3.999999910592883e-6,
        0.9998
      ]
    }
  }
}

yanan1116 avatar Dec 04 '25 20:12 yanan1116

i find that a common point in my failed dataset is that the std is zero for some action dimensions such as roll and pitch.

due to the lack of functionality during my tele operation trajectories collection process, some actions are permanantly disabled, causing std to be zero.

not sure this zero variance will causes this issue ?

    "actions": {
      "mean": [
        0.30516013503074646,
        0.201986163854599,
        0.30340754985809326,
        3.141157627105713,
        1.2246510877499041e-16,
        3.14013934135437,
        -0.17578142881393433
      ],
      "std": [
        0.23775915801525116,
        0.2307763695716858,
        0.16840794682502747,
        0.052498750388622284,
        0.0,
        0.025277692824602127,
        0.9844292402267456
      ],
      "q01": [
        -0.42413202333450317,
        -0.47441399637460707,
        0.0697767967402935,
        3.1403361039161677,
        1.2246468525851679e-16,
        3.1414967410087584,
        -1.0
      ],
      "q99": [
        0.6836171718120576,
        0.4716480171203613,
        0.5915823836684228,
        3.1403361039161677,
        1.2246468525851679e-16,
        3.1414967410087584,
        0.9996
      ]
    }
  }

another example

    "actions": {
      "mean": [
        -0.00041266667540185153,
        0.00031892844708636403,
        -0.00008734526636544615,
        0.0,
        0.0,
        -8.777629773248918e-6,
        -0.15411648154258728
      ],
      "std": [
        0.0045249625109136105,
        0.004427350591868162,
        0.0032394295558333397,
        0.0,
        0.0,
        0.0007520588696934283,
        0.9880526661872864
      ],
      "q01": [
        -0.0061907957971095995,
        -0.00660119787454605,
        -0.006264001339674002,
        0.0,
        0.0,
        -3.999999910592883e-6,
        -1.0
      ],
      "q99": [
        0.005642404401302342,
        0.0059724021077156575,
        0.005937598460912713,
        0.0,
        0.0,
        -3.999999910592883e-6,
        0.9996
      ]
    }
  }

yanan1116 avatar Dec 05 '25 18:12 yanan1116

Hi @yanan1116 , i also encountered this problem, and my dataset also contains 0 std data, have you figured out the root cause?

  "std": [
    0.2855009138584137,
    0.11289037764072418,
    0.13164478540420532,
    0.45261669158935547,
    0.129362553358078,
    0.24880079925060272,
    0.20012737810611725,
    0.41185539960861206,
    0.1438695192337036,
    0.17598208785057068,
    0.4903377294540405,
    0.11197040230035782,
    0.22900764644145966,
    0.1424848586320877,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.4477739930152893,
    0.4477739930152893,
    0.4477739930152893,
    0.4477739930152893,
    0.4477739930152893,
    0.4981798529624939
  ],

HomerIsAFool avatar Dec 09 '25 07:12 HomerIsAFool

@HomerIsAFool hi , could u paste the full stats here? like mean max min of each action dim.

i do not think the zero std of some of the dimensions is the only cause since another dataset of mine https://huggingface.co/datasets/yananchen/robosuite_lift does not cause any training issue.

yanan1116 avatar Dec 09 '25 14:12 yanan1116

Hi @yanan1116 ,below is the full stats. But i do not think the loss explosion is due to the 0 std data, because i deleted the 0 std dof data yesterday and retrained, but the loss still do not converge.

    {
      "norm_stats": {
        "state": {
          "mean": [
            -0.18821308016777039,
            0.11031429469585419,
            0.18490295112133026,
            0.498685747385025,
            -0.20490087568759918,
            -0.426245778799057,
            -0.31233686208724976,
            -0.26759472489356995,
            -0.20897972583770752,
            -0.09802993386983871,
            0.401615709066391,
            0.008379596285521984,
            -0.4383883774280548,
            0.18407194316387177,
            1.1067990064620972,
            14.014400482177734,
            14.045822143554688,
            1.6249879598617554,
            1.34459388256073,
            0.6830214262008667,
            0.9243986010551453,
            5.503140926361084,
            5.521818161010742,
            1.1389774084091187,
            1.0645207166671753,
            0.492778480052948
          ],
          "std": [
            0.2858356535434723,
            0.11144094169139862,
            0.13144098222255707,
            0.45122355222702026,
            0.12888950109481812,
            0.24879267811775208,
            0.19958192110061646,
            0.4091815650463104,
            0.14212080836296082,
            0.17555710673332214,
            0.48755043745040894,
            0.11050308495759964,
            0.22847901284694672,
            0.14176617562770844,
            0.20138834416866302,
            24.506988525390625,
            24.566259384155273,
            1.1768548488616943,
            0.6544931530952454,
            0.4699998199939728,
            0.2709965407848358,
            15.862862586975098,
            15.898843765258789,
            0.8002064824104309,
            0.45045050978660583,
            0.48047274351119995
          ],
          "q01": [
            -0.7751255036354066,
            -0.06628893314003943,
            -0.14285367208719252,
            -0.4463612747192383,
            -0.5394714005947113,
            -0.833250538110733,
            -0.7464100887298584,
            -1.1484143330454826,
            -0.5961258449584246,
            -0.606683812046051,
            -0.5917582214355469,
            -0.2801951551437378,
            -0.9043804765701294,
            -0.1265006319284439,
            0.9989559788703919,
            0.996999979019165,
            0.996999979019165,
            1.0,
            0.9929999709129333,
            0.213729593616724,
            0.23270759088993073,
            0.3008049964904785,
            0.328625404640194,
            0.38282880803234876,
            0.5568223882198333,
            0.0
          ],
          "q99": [
            0.4940645915985107,
            0.4194388959616423,
            0.444744226783514,
            1.3057540175914766,
            0.11012876959443085,
            0.10368834206461885,
            0.0354594443559646,
            0.6071272307395934,
            0.04284077525734897,
            0.2778990337371827,
            1.3043954193115233,
            0.25894046783447267,
            0.11162266764640805,
            0.5888801577091218,
            1.4859021418333054,
            60.149166498231885,
            60.292139454317095,
            3.8404318800926207,
            2.5766831027388575,
            1.5417336553007364,
            1.4857027418375015,
            60.148967098236085,
            60.291940654321294,
            3.84023228009264,
            2.576544702744484,
            1.2857428133487703
          ]
        },
        "actions": {
          "mean": [
            -0.1772158294916153,
            0.10904110968112946,
            0.18423554301261902,
            0.4979560673236847,
            -0.2050318419933319,
            -0.4250069260597229,
            -0.31268060207366943,
            -0.2623046040534973,
            -0.20738288760185242,
            -0.09799283742904663,
            0.40335068106651306,
            0.012809226289391518,
            -0.4390832781791687,
            0.18478535115718842,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            0.7176161408424377,
            0.7176161408424377,
            0.7176161408424377,
            0.7176161408424377,
            0.7176161408424377,
            0.5056135058403015
          ],
          "std": [
            0.2855009138584137,
            0.11289037764072418,
            0.13164478540420532,
            0.45261669158935547,
            0.129362553358078,
            0.24880079925060272,
            0.20012737810611725,
            0.41185539960861206,
            0.1438695192337036,
            0.17598208785057068,
            0.4903377294540405,
            0.11197040230035782,
            0.22900764644145966,
            0.1424848586320877,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.4477739930152893,
            0.4477739930152893,
            0.4477739930152893,
            0.4477739930152893,
            0.4477739930152893,
            0.4981798529624939
          ],
          "q01": [
            -0.7729136667966843,
            -0.09053632987141608,
            -0.14018893632888796,
            -0.4530159672141075,
            -0.531768733972311,
            -0.8370053074121475,
            -0.7497754722952843,
            -1.1573393796920777,
            -0.6031483749508858,
            -0.6084915634632111,
            -0.5899723381042481,
            -0.27328725981712343,
            -0.9083278991341591,
            -0.1285867049694061,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0
          ],
          "q99": [
            0.501810859465599,
            0.4135004655361175,
            0.4477763391494751,
            1.3152901514530182,
            0.10931202135682105,
            0.1077256854772568,
            0.03616183285713204,
            0.610426671218872,
            0.047127036237716635,
            0.27830446791648855,
            1.3113669764518736,
            0.26936762725114816,
            0.11368144569396965,
            0.5924246387481691,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            1.0,
            0.9998,
            0.9998,
            0.9998,
            0.9998,
            0.9998,
            0.9998
          ]
        }
      }
    }

HomerIsAFool avatar Dec 10 '25 01:12 HomerIsAFool

I also encountered this problem, and here is my normalization calculation result:

{
  "norm_stats": {
    "state": {
      "mean": [
        0.5599892139434814,
        -0.2531660199165344,
        -0.0747968778014183,
        0.461273729801178,
        -1.007473358072275e-7,
        0.008108857087790966
      ],
      "std": [
        0.426471471786499,
        0.24047580361366272,
        0.9558978080749512,
        0.46699562668800354,
        0.00001189525119116297,
        0.08968335390090942
      ],
      "q01": [
        -0.0033671585708856533,
        -0.735035491167847,
        -1.4845770597457886,
        -0.0026542617201805114,
        -2.792453917209968e-7,
        0.0
      ],
      "q99": [
        1.2453483819544315,
        0.0005830795175395531,
        1.4831106722593308,
        1.452168734407425,
        -2.792453917209968e-7,
        0.0
      ]
    },
    "actions": {
      "mean": [
        0.5636305809020996,
        -0.2541941702365875,
        -0.06858044117689133,
        0.4631446301937103,
        -9.40309234920278e-8,
        0.00564045924693346
      ],
      "std": [
        0.42566728591918945,
        0.24052844941616058,
        0.9689602255821228,
        0.4680411219596863,
        9.666234291216824e-6,
        0.07489088177680969
      ],
      "q01": [
        -0.0032857127025723576,
        -0.7299092346562539,
        -1.5699971914291382,
        -0.0023332272768020633,
        -2.7925267349925877e-7,
        0.0
      ],
      "q99": [
        1.2465884626865387,
        0.0004626836281269586,
        1.569371337890625,
        1.469108539521694,
        -6.981316837476048e-8,
        0.0
      ]
    }
  }
}

I suspect it may be due to the scattered data collected, but I haven't confirmed this yet.

sunmoon2018 avatar Dec 15 '25 07:12 sunmoon2018

ImageI have encountered this issue as well. Has anyone identified any possible causes?

lu-ran-qi-ran avatar Dec 18 '25 11:12 lu-ran-qi-ran

I also encountered this issue. After replacing the zero values in the standard deviation, the loss explosion disappeared and the training stabilized. This suggests that zero or near-zero std values were likely the root cause of the issue.

kingdom-of-warriors avatar Dec 20 '25 06:12 kingdom-of-warriors

My norm_stats.json result is:

    "action": {
        "q01": [
            -1.1451605429965186,
            -2.242609221335103,
            -2.2571858448691624,
            -1.153324126746803,
            1.568642928333805,
            -1.660688690313425,
            0.036514735546843445
        ],
        "q99": [
            -0.7886300352340484,
            -1.4988367923820078,
            -1.4468297973848614,
            -0.9084148509828917,
            1.5696224851423788,
            -1.3030340120492672,
            0.9370960097121583
        ]
    },

Only q01 and q99 are shown because I'm using quantile norm method here;

  def _normalize_quantile(self, x, stats: NormStats):
      assert stats.q01 is not None
      assert stats.q99 is not None
      q01, q99 = stats.q01[..., : x.shape[-1]], stats.q99[..., : x.shape[-1]]
      return (x - q01) / (q99 - q01 + 1e-6) * 2.0 - 1.0

According to the paper, π0.5 used the delta action to train the model, so the input action data will be close to 0 except EEF dimension. Suppose the input action is [0, 0, 0, 0, 0, 0, 0]. After norm, the normed value will be around [ 5.42, 5.03, 4.57, 8.42, -3200.49, 8.29, -1.081 ].

In the other hand, the output of π0.5 is very likely to be close to zero after pretraining, So the MSE loss between the model's output and the above normed value will be a very large number during finetuning.

I also recomputed the norm stats, the result is:

    "actions": {
      "q01": [
        -0.07642693030834198,
        -0.11600383603572845,
        -0.03346841468811035,
        -0.06057347936630249,
        -0.00026374580860137945,
        -0.07966181659698486,
        -0.0036465092182159445
      ],
      "q99": [
        0.06847352308034899,
        0.048216303467750576,
        0.13146085472106933,
        0.05824755527973177,
        0.00025566232204437254,
        0.07155142498016356,
        0.95600277582407
      ]
    }

the loss explosion disappeared with the new norm stats.

Maybe the difference between q01 and q99 of each dimension should not be a tiny value.

jyC23333 avatar Dec 24 '25 02:12 jyC23333

So. how deal this problem when there is the problem std close to 0

LufanM avatar Dec 28 '25 07:12 LufanM

I also encountered this issue. After replacing the zero values in the standard deviation, the loss explosion disappeared and the training stabilized. This suggests that zero or near-zero std values were likely the root cause of the issue.

Does that mean a problem will arise if the distribution of one feature dimension in the dataset stays the same or barely changes (this means the standard deviation of this dimension is zero or nearly zero)?

LufanM avatar Dec 29 '25 03:12 LufanM

I also encountered this issue. After replacing the zero values in the standard deviation, the loss explosion disappeared and the training stabilized. This suggests that zero or near-zero std values were likely the root cause of the issue.

Does that mean a problem will arise if the distribution of one feature dimension in the dataset stays the same or barely changes (this means the standard deviation of this dimension is zero or nearly zero)?

I completely agree with your assessment. In my case, I collected data for a single-arm task using a dual-arm robot, which meant one arm remained almost entirely static. This resulted in the std for those dimensions being close to zero.

To fix this, I replaced any zero or near-zero std values with a small value in the range of 2e-5 to 2e-4. This successfully resolved the loss convergence issue without negatively impacting the training performance.

kingdom-of-warriors avatar Dec 29 '25 06:12 kingdom-of-warriors

I also encountered this issue. After replacing the zero values in the standard deviation, the loss explosion disappeared and the training stabilized. This suggests that zero or near-zero std values were likely the root cause of the issue.我也遇到过这个问题。在将标准差中的零值替换后,损失爆炸消失,训练趋于稳定。这表明零或接近零的标准值很可能是问题的根源。

Does that mean a problem will arise if the distribution of one feature dimension in the dataset stays the same or barely changes (this means the standard deviation of this dimension is zero or nearly zero)?这是否意味着如果数据集中某一特征维度的分布保持不变或几乎没有变化(这意味着该维度的标准差为零或接近零)会出现问题?

I completely agree with your assessment. In my case, I collected data for a single-arm task using a dual-arm robot, which meant one arm remained almost entirely static. This resulted in the std for those dimensions being close to zero.我完全同意你的判断。就我而言,我用双臂机器人收集了单臂任务的数据,这意味着一只手臂几乎完全静止。这导致这些维度的标准差接近零。

To fix this, I replaced any zero or near-zero std values with a small value in the range of 2e-5 to 2e-4. This successfully resolved the loss convergence issue without negatively impacting the training performance.为了解决这个问题,我把任何零或接近零的标准值替换成一个 2e-5 到 2e-4 之间的小值。这成功解决了损失收敛问题,同时未对训练表现产生负面影响。

Hello, may I ask if you want to change all values close to 0 in "std", "q01", and "q99" in the norm_dats.rson file to a small value in the range of 2e-5 to 2e-4?

sunmoon2018 avatar Dec 29 '25 09:12 sunmoon2018

Unfortunately,even thought I change the value of std that close to 0 to 0.1, there still is a loss explosion problem. In addition, I also change the norm method to quantile norm method, but still has this problem.

  def _normalize_quantile(self, x, stats: NormStats):
      assert stats.q01 is not None
      assert stats.q99 is not None
      q01, q99 = stats.q01[..., : x.shape[-1]], stats.q99[..., : x.shape[-1]]
      return (x - q01) / (q99 - q01 + 1e-6) * 2.0 - 1.0

LufanM avatar Dec 29 '25 11:12 LufanM

seems that many guys feel like that the cause is the std.

however, when i train the model on another dataset (self collected within robosuite simulator), where the roll, pitch and yaw are all zero, and std is surely zero, there is no loss explosion issue.

here is the dataset https://huggingface.co/datasets/yananchen/robosuite_lift

stats:

"actions": {
--
"min": [
-1.0,
-1.0,
-1.0,
0.0,
0.0,
-0.0,
-1.0
],
"max": [
1.0,
1.0,
1.0,
0.0,
0.0,
-0.0,
1.0
],
"mean": [
0.16719493078637615,
0.004754358252418919,
-0.12876386815761753,
0.0,
0.0,
0.0,
-0.5760697313184405
],
"std": [
0.6126776304411433,
0.20680090800145207,
0.734359284118154,
0.0,
0.0,
0.0,
0.8174005500099302
],
"count": [
2524
]
},

yanan1116 avatar Dec 29 '25 15:12 yanan1116

@yanan1116 @LufanM This is really bad news, but that's what research is all about. Let's cheer up and share the good news with you.

sunmoon2018 avatar Dec 30 '25 00:12 sunmoon2018

seems that many guys feel like that the cause is the std.

however, when i train the model on another dataset (self collected within robosuite simulator), where the roll, pitch and yaw are all zero, and std is surely zero, there is no loss explosion issue.

here is the dataset https://huggingface.co/datasets/yananchen/robosuite_lift

stats:

"actions": {
--
"min": [
-1.0,
-1.0,
-1.0,
0.0,
0.0,
-0.0,
-1.0
],
"max": [
1.0,
1.0,
1.0,
0.0,
0.0,
-0.0,
1.0
],
"mean": [
0.16719493078637615,
0.004754358252418919,
-0.12876386815761753,
0.0,
0.0,
0.0,
-0.5760697313184405
],
"std": [
0.6126776304411433,
0.20680090800145207,
0.734359284118154,
0.0,
0.0,
0.0,
0.8174005500099302
],
"count": [
2524
]
},

yes, I also find this.but that's the problem, when I train dataset which collected by my dual-arm robot based on pi0 base model there is no loss explosion problem, But when I train dataset based on pi05 base model (same dataset, and has std close to 0),then the problem emerge

LufanM avatar Dec 30 '25 09:12 LufanM

seems that many guys feel like that the cause is the std. however, when i train the model on another dataset (self collected within robosuite simulator), where the roll, pitch and yaw are all zero, and std is surely zero, there is no loss explosion issue. here is the dataset https://huggingface.co/datasets/yananchen/robosuite_lift stats:

"actions": {
--
"min": [
-1.0,
-1.0,
-1.0,
0.0,
0.0,
-0.0,
-1.0
],
"max": [
1.0,
1.0,
1.0,
0.0,
0.0,
-0.0,
1.0
],
"mean": [
0.16719493078637615,
0.004754358252418919,
-0.12876386815761753,
0.0,
0.0,
0.0,
-0.5760697313184405
],
"std": [
0.6126776304411433,
0.20680090800145207,
0.734359284118154,
0.0,
0.0,
0.0,
0.8174005500099302
],
"count": [
2524
]
},

yes, I also find this.but that's the problem, when I train dataset which collected by my dual-arm robot based on pi0 base model there is no loss explosion problem, But when I train dataset based on pi05 base model (same dataset, and has std close to 0),then the problem emerge

I find a key problem that use_quantile_norm is default set as True if your model isn't pi0. and the detail you can reference to issue

when change the norm computation method to the follow

    def _normalize(self, x, stats: NormStats):
        # print("fuck 居然使用了z-score归一化")
        mean, std = stats.mean[..., : x.shape[-1]], stats.std[..., : x.shape[-1]]
        res = (x - mean) / (std + 1e-6)
        if (res > 1e4).any():
            print(f"原始数据为x: {x}, 归一化后为res: {res},对应的std:{std}")
        return (x - mean) / (std + 1e-6)

my loss explosion problem has disappeared. And I find that the important thing is the value of one dimension of my q1 and q99 is very close just as the std close to 0 when you use z-score to norm computation

Furthermore,I have a new question: Why use z-score method compute norm is ok, use quantile norm method will cause loss explosion. comparing the difference between z-score and quantile method:

    def _normalize(self, x, stats: NormStats):
        # print("fuck 居然使用了z-score归一化")
        mean, std = stats.mean[..., : x.shape[-1]], stats.std[..., : x.shape[-1]]
        res = (x - mean) / (std + 1e-6)
        if (res > 1e4).any():
            print(f"原始数据为x: {x}, 归一化后为res: {res},对应的std:{std}")
        return (x - mean) / (std + 1e-6)

    def _normalize_quantile(self, x, stats: NormStats):
        print(f"使用 quantile 归一化")
        assert stats.q01 is not None
        assert stats.q99 is not None
        q01, q99 = stats.q01[..., : x.shape[-1]], stats.q99[..., : x.shape[-1]]
        return (x - q01) / (q99 - q01 + 1e-6) * 2.0 - 1.0

they all add 1e-6 to avoid explosion, why will quantile norm method cause loss explosion problem.

LufanM avatar Dec 30 '25 13:12 LufanM

@LufanM In fact, if q01 and q99 of one-dimensional data in your action or state sequence are very similar, use quantile norm method will cause loss explosion problem, But if the one-dimensional STD is not 0, then use the Z-score method will not cause loss explosion problem. If the one-dimensional STD is also 0, there is no help, unless you clean your data, delete the wrong data, and recalculate norm.

sunmoon2018 avatar Dec 31 '25 07:12 sunmoon2018

@LufanM In fact, if q01 and q99 of one-dimensional data in your action or state sequence are very similar, use quantile norm method will cause loss explosion problem, But if the one-dimensional STD is not 0, then use the Z-score method will not cause loss explosion problem. If the one-dimensional STD is also 0, there is no help, unless you clean your data, delete the wrong data, and recalculate norm.

got it

LufanM avatar Jan 19 '26 12:01 LufanM