Skip to content

Replace single_site_matching with single_site#552

Merged
bruno-f-cruz merged 7 commits into
mainfrom
feat-single-site-curriculum
May 30, 2026
Merged

Replace single_site_matching with single_site#552
bruno-f-cruz merged 7 commits into
mainfrom
feat-single-site-curriculum

Conversation

@galenlynch
Copy link
Copy Markdown
Member

Port the single_site_no_matching curriculum from
Aind.Behavior.VrForaging.Curricula#40 into the monorepo as a new independent curriculum, renamed to single_site per Bruno's request. Delete the old single_site_matching curriculum entirely.

Changes vs. the original branch in .Curricula:

  • Rename single_site_no_matching -> single_site (package + class + CURRICULUM_NAME + schema filename).
  • Drop cross-curriculum dependency on single_site_matching.helpers.clamp; inline as a local _clamp helper in policies.py.
  • Adapt to monorepo task_logic API drift:
    • aind_behavior_services.task_logic.distributions -> aind_behavior_services.task.distributions.
    • vr_task_logic.OdorSpecification(index=i, concentration=1) -> one-hot list[int] (OdorMixture).
  • Regenerate schema/single_site.json against monorepo pydantic models.

Tests: 31 single_site tests + 7 cli tests + 13 depletion tests pass.

@bruno-f-cruz bruno-f-cruz changed the title feat(curricula): replace single_site_matching with single_site Replace single_site_matching with single_site May 23, 2026
Copy link
Copy Markdown
Member

@bruno-f-cruz bruno-f-cruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small style things just so make sure we can read this easily in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be renamed "readme.md" to be picked up by the doc building process. Also I am not sure this is up-to-date. I will leave it up to you to include it or not, but if you don't feel like maintaining it just drop it.

Comment on lines +107 to +109
inter_patch.truncation_parameters.max = ip_max
gen.inter_site.length_distribution.distribution_parameters.value = is_len
gen.reward_site.length_distribution.distribution_parameters.value = rs_len
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard against other distributions just so we fail loudly in case it happens:

            else:
                raise ValueError(f"Unexpected inter-patch distribution type: {type(inter_patch)}")

reward-site lengths from the compressed start toward full spacing, scaled by
prior locomotion (n_patches_seen / GEOMETRY_EASE_PATCHES, clamped to 1). On the
first session (no prior metrics) the geometry stays compressed."""
frac = _clamp(metrics.n_patches_seen / GEOMETRY_EASE_PATCHES, 0.0, 1.0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use slightly longer names? I kinda know what these are, but being explicit with names here will help quite alot in the long run.

ip = inter_patch
is = inter_site
gen = patch_generator
inter_patch = inter_patch_generator



class TestLearnToChooseToProbabilityGridShort:
def _ok(self) -> SingleSiteMetrics:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming to something like: _make_passing_metrics()

galenlynch and others added 6 commits May 30, 2026 09:51
Port the single_site_no_matching curriculum from
Aind.Behavior.VrForaging.Curricula#40 into the monorepo as a new
independent curriculum, renamed to `single_site` per Bruno's request.
Delete the old `single_site_matching` curriculum entirely.

Changes vs. the original branch in .Curricula:
- Rename single_site_no_matching -> single_site (package + class +
  CURRICULUM_NAME + schema filename).
- Drop cross-curriculum dependency on
  single_site_matching.helpers.clamp; inline as a local _clamp helper
  in policies.py.
- Adapt to monorepo task_logic API drift:
  - aind_behavior_services.task_logic.distributions ->
    aind_behavior_services.task.distributions.
  - vr_task_logic.OdorSpecification(index=i, concentration=1) ->
    one-hot list[int] (OdorMixture).
- Regenerate schema/single_site.json against monorepo pydantic models.

Tests: 31 single_site tests + 7 cli tests + 13 depletion tests pass.
…, stochastic delay ramp)

- Restrict graduated grid to summed reward probability {0.8, 1.0, 1.2} (13
  blocks) and rename graduated_* -> probability_grid_short/long_delay.
- learn_to_stop: fixed 1.0 s stop (drop stop-duration updater), fast velocity
  ramp (GAIN on_success 0.93), compressed->full geometry easing via
  p_learn_to_run, and a cross-session reward-probability water gate
  (p_reward_water_gate: 1.0 while struggling, 0.8 once earning water).
- Remove learn_to_stop_low_p; struggling animals stay in learn_to_stop.
- Fold three_contrast into probability_grid_short_delay: move the
  REWARD_DELAY_OFFSET ramp (0 -> 1.5) into the grid stage; drop the coupled
  stop-duration shrink ramp (stop is now fixed).
- Keep reward delay stochastic in both grid stages (Exp base + within-session
  additive ramp in short, stationary in long) with a 0.2 s floor.
- Rewrite tests for the 4-stage chain and regenerate schema/single_site.json.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Inline the _learn_to_stop_saturation_met alias into its only caller.
- p_learn_to_run: explicit variable names + raise on an unexpected
  inter-patch distribution type.
- Rename test helper _ok -> _make_passing_metrics.
- Replace the stale SUMMARY.md with a concise, current README.md (so the
  doc builder picks it up).
- Speed up the probability_grid_short patience ramp (REWARD_DELAY_OFFSET
  on_success 0.005 -> 0.01) so it graduates in ~1 session.
- Lower the learn_to_stop graduation gate n_patches_seen 300 -> 250.
- Regenerate schema.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
main's #547 generalized environment sampling: Block.environment_statistics ->
Block.environment, and EnvironmentStatistics -> MarkovEnvironment. Update
make_block, the geometry/reward policies, and the tests accordingly, and
regenerate schema/single_site.json against task-logic 1.0.0rc6.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
No behavior change — schema/single_site.json is byte-identical.

- Extract task-logic builders into helpers.py (make_patch, make_block,
  make_default_operation_control, make_reward_delay, clamp, lerp), matching the
  per-curriculum helpers pattern used by depletion/template.
- Reuse ..utils.trainer_state_from_file / metrics_from_dataset_path instead of
  redefining them locally; drop the now-dead imports.
- Use the `task_logic` import alias (was vr_task_logic); normalize the transition
  predicates to `return (...)`.
- Rename GRADUATED_* -> PROBABILITY_GRID_* to match the stage names, and
  de-duplicate the 13-block grid via _POST_STOP_PATCH_KWARGS + _probability_grid_blocks.
- Remove the dead last_stop_duration_offset_updater metric (left from three_contrast);
  drop stale S1/S2/S3 references; name the cross-session seeding factors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@galenlynch galenlynch force-pushed the feat-single-site-curriculum branch from b55c64f to f72a9e5 Compare May 30, 2026 18:04
@bruno-f-cruz bruno-f-cruz merged commit 2f73831 into main May 30, 2026
4 checks passed
@bruno-f-cruz bruno-f-cruz deleted the feat-single-site-curriculum branch May 30, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants