Repository navigation
Conversation
DiscreteSampler draws value vectors from a fixed list and returns the same float32 tensors as UniformSampler, so it drives any variation that takes a ContinuousSampler. It draws entries at random, optionally weighted, or gives env i the entry values[i % n] without drawing. ChoiceSampler and DiscreteSampler share one random index draw, which keeps ChoiceSampler's draws unchanged for a given seed. The numeric variations now accept any ContinuousSamplerCfg instead of only UniformSamplerCfg. Signed-off-by: Xinjie Yao <[email protected]>
Hydra overrides cannot change the type of a config node, so a numeric variation could not switch from its uniform sampler from the command line or an experiment config. Continuous sampler cfgs now carry a distribution name, and a <variation>.sampler_cfg.distribution override makes the override schema hold that sampler cfg before the remaining overrides set its fields, for example: apple.mass.sampler_cfg.distribution=discrete apple.mass.sampler_cfg.values=[[0.17],[0.24]] Signed-off-by: Xinjie Yao <[email protected]>
Keep the variations page to what a fixed set of values is for and its two modes; move the override syntax into the author-environment skill. Signed-off-by: Xinjie Yao <[email protected]>
ChoiceSampler now draws from its own values as well as from per-call choices, at random with optional probabilities or as one fixed entry per env. DiscreteSampler is removed, and ContinuousSampler is back to its form on main apart from the distribution name. Numeric variations type sampler_cfg as SamplerBaseCfg and draw through sample_float_rows(), which returns a float32 tensor of the shape the variation needs from a UniformSampler or a ChoiceSampler. The override that selects the sampler is now <variation>.sampler_cfg.distribution=choice. Signed-off-by: Xinjie Yao <[email protected]>
…uild With random_choice=false, a draw without env ids now starts at the rebuild index, so rebuild k of a build-time variation takes values[k % n], as in-order asset selection does. VariationBase passes the rebuild index to its sampler. Numeric variations declare numeric_sample_shape, and configure_at_build_time checks every value the sampler can draw against it, so a wrong-shaped value, a choice sampler without values or a non-numeric sampler fails before the env is built. HDRImageVariation gets its own HDRImageSamplerCfg with only random_choice, so its listing no longer shows a values field that conflicts with hdr_names. Signed-off-by: Xinjie Yao <[email protected]>
xyao-nv
force-pushed
the
xyao/feature/discrete-value-sampler
branch
from
November 30, 2026 22:57
66dee11 to
73c863a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Let
ChoiceSamplerdraw from its ownvalues, at random with optional weights or as one fixed entry per env, and let numeric variations take it in place ofUniformSampler.Why this change?
Numeric variations, such as object mass, light intensity and camera extrinsics, accept only
UniformSamplerCfg. To evaluate an apple at two known masses, 0.17 kg and 0.24 kg, a user runs twice withlowequal tohigh. There is also no way to give each parallel environment its own fixed value, so that one run covers every value without randomness.ChoiceSampleralready picks from a set, but only for name lists such as HDR images and assets, only uniformly, and only from thechoicesthat a variation passes to each draw.Hydra overrides also cannot change the type of a config node, so overrides could not switch a variation away from its uniform sampler.
What changes?
Motivated by measuring apple weights task,
ChoiceSamplerdraws from a set of any values:ChoiceSamplerCfggains three fields:values: the entries to draw from, for example[[0.17], [0.24]]. Withvaluesset, a draw needs nochoices.probabilities: weights for random draws.random_choice=False: envigets entryi % len(entries)on every reset, with no random draws. A build-time variation draws without env ids, so it gets the first entry.When
valuesis empty, each draw passes its ownchoices, as before.HDRImageVariationandRigidAssetSelectionVariationkeep working unchanged, and a seed gives the same draws as before, which a test pins.Numeric variations take either sampler: object mass, camera extrinsics and intrinsics, and light intensity, color, color temperature and direction now type
sampler_cfgasSamplerBaseCfg. Their defaults are unchanged. They draw through the newsample_float_rows()insampler_base.py, which turns a sampler's output into a float32 tensor of the shape the variation needs. It accepts both the tensor fromUniformSamplerand the list of number lists fromChoiceSampler. This draw-time shape check replaces the setup-timeshape_per_samplechecks.Sampler selection in overrides:
UniformSamplerCfgandChoiceSamplerCfgcarry adistributionname,"uniform"or"choice". Before Hydra composes the config,build_variations_cfg_with_overridesreads<host>.<variation>.sampler_cfg.distributionoverrides and puts a default cfg of the selected type into the schema. The remaining overrides then set its fields.valueswithoutdistribution=choice, fails with a hint to setdistribution.Docs: the variations concept page describes drawing from a fixed set and its two modes, and its
--list_variationsexample shows the newdistributionfield. The author-environment skill has the override syntax.Limitations:
SamplerBaseCfgalso admits sampler cfgs that do not return numbers, such asBernoulliSamplerCfg. Such a sampler fails at its first draw. Overrides can select onlyuniformandchoice.lowandhighfor every Run cannot switch tochoicein one Run. The merged overrides fail with an unknown-field error. Set the sampler fields in each Run instead.Usage example
Before, a single fixed mass, one run per mass:
After, selecting mass per episode:
pick_up_object.mass.enabled=true \ pick_up_object.mass.sampler_cfg.distribution=choice \ "pick_up_object.mass.sampler_cfg.values=[[0.17],[0.24]]" \ pick_up_object.mass.sampler_cfg.random_choice=falseWith
random_choice=false, even envs get 0.17 kg and odd envs get 0.24 kg on every reset. Without it, each reset draws a mass at random;"pick_up_object.mass.sampler_cfg.probabilities=[0.8,0.2]"weights the draws. The same keys work in an experiment config'svariationsfield.Validation