Repository navigation
Fix additive noise bias accumulating across resets - #8634
Conversation
NoiseModelWithAdditiveBias.reset applied the bias noise to the previous bias. With the default "add" operation every reset added a new sample to the old one, so the bias random-walked across episodes instead of being resampled as documented. Sample the bias from zeros instead, which leaves "abs" and "scale" results unchanged. Signed-off-by: Patrick-SCH03 <[email protected]>
[Medium impact] This PR appears safe to merge. SummaryFixes
Reviews (1) · Last reviewed commit: "Fix additive noise bias accumulating acr..." · Reviewed by Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
All reviewed code categories look good.
- PR description: The title and body match the four-file diff and report focused validation; mark the documentation checkbox complete and trim the repeated bug-versus-feature rationale.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: Implementation looks good.
- Style consistency: Style consistency looks good.
- Test quality: Test quality looks good.
No blocking issues. No inline findings.
Automated review; human maintainers own approval decisions.
AntoineRichard
left a comment
There was a problem hiding this comment.
Thanks for the PR @Patrick-SCH03! I have one comment, could you take a look? Thanks again!
| # reset the bias term | ||
| self._bias[env_ids] = self._bias_noise_cfg.func(self._bias[env_ids], self._bias_noise_cfg) | ||
| # sample a fresh bias; applying the noise to the previous bias would accumulate it for the "add" operation | ||
| self._bias[env_ids] = self._bias_noise_cfg.func(torch.zeros_like(self._bias[env_ids]), self._bias_noise_cfg) |
There was a problem hiding this comment.
Could we avoid the memory allocation here? Maybe pre-allocate a array full of 0 on the init?
Signed-off-by: Patrick-SCH03 <[email protected]>
|
Thanks for the review! Done in bccbe89: the model now keeps a zero tensor One note: for a full reset the slice is a view, but with a list or tensor of |
|
@AntoineRichard friendly ping: the zero buffer is now preallocated in |
AntoineRichard
left a comment
There was a problem hiding this comment.
Thanks for the changes @Patrick-SCH03. Looks good now!
|
run-ci |
|
run-ci |
Description
NoiseModelWithAdditiveBiasCfg.bias_noise_cfgis documented as "sampled at every reset of the noise model", and the direct-env how-to says the bias is "resampled at the next reset".NoiseModelWithAdditiveBias.resetinstead applies the bias noise to the previous bias:With the default
operation="add", every reset adds a new sample to the old bias, so the bias random-walks across episodes. With 4096 envs,sample_bias_per_component=False,GaussianNoiseCfg(std=0.1)as the bias noise andtorch.manual_seed(0), after N calls toreset():"add",develop)"abs")A
UniformNoiseCfg(n_min=-0.1, n_max=0.1)bias spans about -1.3 to 1.5 after 50 resets.ObservationManager.resetand the direct envs call this reset on every episode reset, so the observation bias of long training runs keeps growing."abs"happens to work because it ignores the input.This samples the bias from zeros instead of from the previous bias.
"add"now gives a fresh sample on each reset, the same as"abs". The noise functions draw the same random numbers either way, so"abs"(used by all in-repo configs) and"scale"give bit-identical results todevelop. The changelog fragment notes the behavior change for configs that use"add", and thebias_noise_cfgdocstring now says how each operation applies to the bias ("scale"already yielded no bias ondevelop, since the initial bias is zero).All in-repo configs have used
"abs"since the bias model was added, and I did not add an option to keep the accumulating behavior; happy to add one if you prefer.#8218 (draft) also edits this
resetto add anenv_maskpath, but both of its branches still pass the previous bias, so the two changes would need a small merge there.Type of change
Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists thereTesting
test_additive_bias_is_resampled_on_resettotest/utils/test_noise.py: with a constant"add"bias of 0.5, the output must stay 0.5 after repeated full resets, and after changing the bias to 0.25 a partial reset of env 1 must resample only that env. Ondevelopit fails at the first check with 1.0 (the explicit reset and the lazy per-component reset on the first call each add 0.5); it passes with the fix.resetwith thedevelopone under a fixed seed for Gaussian, uniform and constant bias noise, each operation, and bothsample_bias_per_componentsettings, over 50 full and partial resets:"abs"and"scale"outputs are identical, and"add"now stays at the configured spread.test_noise.pyandtest_observation_manager.pypass locally on CPU (thecuda:0rows of the existing noise tests were run with the device swapped to CPU, since my machine has no CUDA). I could not run the direct-env unit tests in my environment.checkandformatand codespell are clean on the changed files. I ran them directly because the fulluv run isaaclab --formatenvironment isn't available on my Windows machine.Release backport
develop