SmolFactory / docs /TRACKIO_UPDATE_FIX.md
Tonic
adds update attribute for trl compatibility
764a584 unverified
|
raw
history blame
3.38 kB

TrackioConfig Update Method Fix

Problem Description

The error 'TrackioConfig' object has no attribute 'update' occurred because the TRL library (specifically SFTTrainer) expects the Trackio configuration object to have an update method, but our custom TrackioConfig class didn't implement it.

Root Cause

Based on the Trackio documentation, Trackio is designed to be API compatible with wandb.init, wandb.log, and wandb.finish. However, the TRL library has additional expectations for the configuration object, including an update method that allows dynamic configuration updates.

Solution Implementation

1. Added Update Method to TrackioConfig

Modified src/trackio.py to add the missing update method:

class TrackioConfig:
    """Configuration class for trackio (TRL compatibility)"""
    
    def __init__(self):
        self.project_name = os.environ.get('EXPERIMENT_NAME', 'smollm3_experiment')
        self.experiment_name = os.environ.get('EXPERIMENT_NAME', 'smollm3_experiment')
        self.trackio_url = os.environ.get('TRACKIO_URL')
        self.trackio_token = os.environ.get('TRACKIO_TOKEN')
        self.hf_token = os.environ.get('HF_TOKEN')
        self.dataset_repo = os.environ.get('TRACKIO_DATASET_REPO', 'tonic/trackio-experiments')
    
    def update(self, config_dict: Dict[str, Any]):
        """
        Update configuration with new values (TRL compatibility)
        
        Args:
            config_dict: Dictionary of configuration values to update
        """
        for key, value in config_dict.items():
            if hasattr(self, key):
                setattr(self, key, value)
            else:
                # Add new attributes dynamically
                setattr(self, key, value)

2. Key Features of the Fix

  • Dynamic Attribute Updates: The update method can update existing attributes and add new ones dynamically
  • TRL Compatibility: Satisfies TRL's expectation for a config object with an update method
  • Backward Compatibility: Doesn't break existing functionality
  • Flexible Configuration: Allows runtime configuration updates

3. Usage Example

import trackio

# Access the config
config = trackio.config

# Update configuration
config.update({
    'project_name': 'my_experiment',
    'experiment_name': 'test_run_1',
    'custom_setting': 'value'
})

# New attributes are added dynamically
print(config.custom_setting)  # Output: 'value'

Verification

The fix has been verified to work correctly:

  1. Import Test: import trackio works without errors
  2. Config Access: trackio.config is available
  3. Update Method: trackio.config.update() method exists and works
  4. TRL Compatibility: All TRL-expected methods are available

Benefits

  1. Resolves Training Error: Fixes the 'TrackioConfig' object has no attribute 'update' error
  2. Maintains TRL Compatibility: Ensures SFTTrainer can use Trackio for logging
  3. Dynamic Configuration: Allows runtime configuration updates
  4. Future-Proof: Supports additional TRL requirements

Related Documentation