Skip to content

add flow-matching policy with factory integration#3359

Open
DeepforThink wants to merge 8 commits intohuggingface:mainfrom
DeepforThink:feature/flow-matching
Open

add flow-matching policy with factory integration#3359
DeepforThink wants to merge 8 commits intohuggingface:mainfrom
DeepforThink:feature/flow-matching

Conversation

@DeepforThink
Copy link
Copy Markdown

Type / Scope

  • Type: Feature
  • Scope: policies.flow_matching

Summary / Motivation

This PR introduces a new flow_matching policy in LeRobot and integrates it into the policy factory and preprocessing pipeline.

Motivation:

  • Add an alternative continuous-action objective with simple ODE-based sampling.
  • Keep compatibility with existing LeRobot policy interfaces.

Related issues

  • Fixes / Closes: N/A
  • Related: N/A

What changed

  • Added flow_matching policy module:
    • src/lerobot/policies/flow_matching/configuration_flow_matching.py
    • src/lerobot/policies/flow_matching/modeling_flow_matching.py
    • src/lerobot/policies/flow_matching/processor_flow_matching.py
    • src/lerobot/policies/flow_matching/README.md
  • Exported FlowMatchingConfig in src/lerobot/policies/__init__.py
  • Integrated flow_matching into src/lerobot/policies/factory.py (config + processor paths)
  • Added tests:
    • tests/policies/flow_matching/test_flow_matching.py
  • Follow-up style fix in modeling_flow_matching.py to satisfy ruff checks

How was this tested (or how to run locally)

  • Ran pre-commit on changed flow-matching files in conda env lerobot (including gitleaks) — all checks passed.
  • Ran:
    • PYTHONPATH= PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 conda run -n lerobot python -m pytest -q tests/policies/flow_matching/test_flow_matching.py
    • Result: 2 passed, 1 warning in 0.57s

Checklist (required before merge)

  • Linting/formatting run (pre-commit)
  • Relevant tests pass locally (pytest)
  • Documentation updated
  • CI is green

Reviewer notes

Please focus on:

  1. src/lerobot/policies/flow_matching/modeling_flow_matching.py (objective + Euler sampling path)
  2. src/lerobot/policies/factory.py (registration and processor integration)
  3. tests/policies/flow_matching/test_flow_matching.py (targeted behavioral coverage)

Copilot AI review requested due to automatic review settings April 11, 2026 16:22
@github-actions github-actions bot added documentation Improvements or fixes to the project’s docs policies Items related to robot policies tests Problems with test coverage, failures, or improvements to testing labels Apr 11, 2026
@DeepforThink
Copy link
Copy Markdown
Author

Thanks for reviewing! I can quickly address any CI or design feedback

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new flow_matching policy implementation to LeRobot and wires it into the existing policy factory + processor pipeline so it can be instantiated via the standard configuration/factory entrypoints.

Changes:

  • Added FlowMatchingConfig, FlowMatchingPolicy, and a flow-matching processor module under src/lerobot/policies/flow_matching/.
  • Integrated flow_matching into make_policy_config and make_pre_post_processors in src/lerobot/policies/factory.py, and exported FlowMatchingConfig from src/lerobot/policies/__init__.py.
  • Added targeted unit tests for config factory creation and a basic forward/select_action path.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
src/lerobot/policies/flow_matching/configuration_flow_matching.py Introduces the FlowMatchingConfig dataclass and feature validation/delta index definitions.
src/lerobot/policies/flow_matching/modeling_flow_matching.py Implements the Flow Matching model (vector field net), Euler sampling, and PreTrainedPolicy interface.
src/lerobot/policies/flow_matching/processor_flow_matching.py Adds pre/post-processing pipeline factory for Flow Matching integration with LeRobot processors.
src/lerobot/policies/flow_matching/README.md Documents the new policy module layout.
src/lerobot/policies/factory.py Registers the new config type and processor factory selection.
src/lerobot/policies/__init__.py Exports FlowMatchingConfig in the public policies module.
tests/policies/flow_matching/test_flow_matching.py Adds initial tests for config factory instantiation and basic policy behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lerobot/policies/flow_matching/processor_flow_matching.py Outdated
Comment thread src/lerobot/policies/flow_matching/processor_flow_matching.py Outdated
Comment thread src/lerobot/policies/flow_matching/processor_flow_matching.py Outdated
Comment thread src/lerobot/policies/flow_matching/processor_flow_matching.py Outdated
Comment thread src/lerobot/policies/flow_matching/modeling_flow_matching.py Outdated
Comment thread tests/policies/flow_matching/test_flow_matching.py
Comment thread src/lerobot/policies/flow_matching/modeling_flow_matching.py
Comment thread src/lerobot/policies/flow_matching/modeling_flow_matching.py
Comment thread src/lerobot/policies/flow_matching/modeling_flow_matching.py Outdated
Comment thread src/lerobot/policies/flow_matching/modeling_flow_matching.py Outdated
@DeepforThink
Copy link
Copy Markdown
Author

Thanks! All review threads are resolved on my side. Could a maintainer please approve workflows so required checks can run?

@DeepforThink DeepforThink force-pushed the feature/flow-matching branch from 624610d to e6c4003 Compare April 15, 2026 02:29
@DeepforThink
Copy link
Copy Markdown
Author

Thanks for the follow-up review 🙏

I just pushed the latest updates, and the PR is currently blocked by branch protection:

  • “New changes require approval from someone other than the last pusher”
  • Workflow approval may also be required to run all required checks

Could a maintainer please help with:

  1. approving the workflow run (if pending), and
  2. providing an approval review from someone other than the last pusher?

All review comments have been addressed on my side. Thank you!

DeepforThink and others added 8 commits April 17, 2026 13:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pierson Dong <149588243+DeepforThink@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pierson Dong <149588243+DeepforThink@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pierson Dong <149588243+DeepforThink@users.noreply.github.com>
@DeepforThink DeepforThink force-pushed the feature/flow-matching branch from 694a946 to bc2403d Compare April 17, 2026 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or fixes to the project’s docs policies Items related to robot policies tests Problems with test coverage, failures, or improvements to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants