Skip to content

Add Policy.from_config() method to match documented API #202

@samet-akcay

Description

@samet-akcay

Summary

The documentation (PR #201) describes Policy.from_config(config) as the primary/recommended way to instantiate policies, but this method doesn't exist yet in the codebase. Currently only Model.from_config() exists.

Current State

# What users must do today (2 steps)
config = ACTConfig(hidden_dim=512, chunk_size=100, ...)
model = ACTModel.from_config(config)
policy = ACT(model=model)

Desired State

# What users should be able to do (1 step)
config = ACTConfig(hidden_dim=512, chunk_size=100, ...)
policy = ACT.from_config(config)

Implementation

The implementation is trivial - add FromConfig mixin to Policy classes:

class FromConfig:
    """Mixin that enables Policy.from_config(config) instantiation."""
    model_type: type
    
    @classmethod
    def from_config(cls, config: Config, **kwargs):
        model = cls.model_type.from_config(config)
        return cls(model=model, **kwargs)

Then update each policy:

class ACT(FromConfig, FromCheckpoint, Export, Policy):
    model_type = ACTModel
    # ... rest unchanged

or alternatively, base Policy class could also inherit FromConfig mixin, so it would be supported by all of the policies by default.

Affected Policies

  • ACT
  • Diffusion
  • GROOT
  • Pi0
  • SmolVLA

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions