fix(g05): unnormalize queued actions by timestep

This commit is contained in:
Pepijn
2026-07-28 15:38:30 +02:00
parent eec1e19374
commit d613c0cd74
3 changed files with 76 additions and 6 deletions
+18 -1
View File
@@ -606,7 +606,11 @@ def test_checkpoint_normalization_clips_to_author_finite_range():
def test_stepwise_quantiles_constant_dimension_are_finite_and_serializable(tmp_path: Path):
config = _config(normalization_mode="q01_q99")
config = _config(
normalization_mode="q01_q99",
use_stepwise_action_norm=True,
n_action_steps=2,
)
q01_action = torch.zeros(4, 7)
q99_action = torch.ones(4, 7)
q99_action[:, 2] = 0
@@ -627,6 +631,19 @@ def test_stepwise_quantiles_constant_dimension_are_finite_and_serializable(tmp_p
assert torch.isfinite(processed[ACTION]).all()
torch.testing.assert_close(postprocessor(processed[ACTION]), torch.zeros(4, 7))
step_q01 = torch.arange(4, dtype=torch.float32).view(4, 1).expand(4, 7)
step_stats = {
OBS_STATE: {"q01": torch.zeros(7), "q99": torch.ones(7)},
ACTION: {"q01": step_q01, "q99": step_q01 + 2},
}
_, stepwise_postprocessor = make_pre_post_processors(config, dataset_stats=step_stats)
normalized_action = torch.zeros(1, config.policy_action_dim)
torch.testing.assert_close(stepwise_postprocessor(normalized_action), torch.ones(1, 7))
torch.testing.assert_close(stepwise_postprocessor(normalized_action), torch.full((1, 7), 2.0))
torch.testing.assert_close(stepwise_postprocessor(normalized_action), torch.ones(1, 7))
stepwise_postprocessor.reset()
torch.testing.assert_close(stepwise_postprocessor(normalized_action), torch.ones(1, 7))
preprocessor.save_pretrained(tmp_path)
loaded = PolicyProcessorPipeline.from_pretrained(
tmp_path, config_filename=f"{POLICY_PREPROCESSOR_DEFAULT_NAME}.json"