Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise error when running registered config with incompatible recipe #1550

Open
felipemello1 opened this issue Sep 12, 2024 · 1 comment
Open
Labels
better engineering Tasks which help improve eng productivity e.g. building tools, cleaning up code, writing docs

Comments

@felipemello1
Copy link
Contributor

Running the code below raises errors about parameters missing, instead of saying that "lora config is not compatible with full finetune recipe"

tune run --nnodes 1 --nproc_per_node 8 full_finetune_distributed --config gemma/2B_lora
@felipemello1 felipemello1 added the better engineering Tasks which help improve eng productivity e.g. building tools, cleaning up code, writing docs label Sep 12, 2024
@Ankur-singh
Copy link
Contributor

It would be helpful to have a consistent way to validate the config file across all recipes, not just in the example above.

One idea is to define a _validate_config method for each recipe and call it in the setup method. This method could check for required keys and return True if everything is correct, or raise an error with a clear, user-friendly message if any required key is missing.

Sample code:

def validate_config(config, required_fields):
    for field in required_fields:
        # Handle nested keys by splitting them and navigating through the structure
        keys = field.split('.')
        current_config = config

        for key in keys:
            # If the key is a dictionary, check if it exists
            if isinstance(current_config, dict) and key in current_config:
                current_config = current_config[key]
            else:
                raise ValueError(f"Missing required field: '{field}'")

# Example usage with nested config:
required_fields = ['field1', 'nested.field2', 'nested.subnested.field3']
config = OmegaConf.create({
    'field1': 'value1',
    'nested': {
        'field2': 'value2'
        # 'subnested' and 'field3' are missing
    }
})

try:
    validate_config(config, required_fields)
except ValueError as e:
    print(e)

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better engineering Tasks which help improve eng productivity e.g. building tools, cleaning up code, writing docs
Projects
None yet
Development

No branches or pull requests

2 participants