Skip to content

RFDiffusion3 DesignInputSpecification object cannot be passed directly to the inference engine #115

Description

@kjczarne

Hi, I have noticed that when using DesignInputSpecification as an input fed directly to the run method on the RFD3InferenceEngine, the run always crashes when _multiply_specifications is invoked. This is due to the fact that DesignInputSpecification object is not subscriptable, yet example_spec is attempted to be set:

    def _multiply_specifications(
        self, inputs: Dict[str, dict | DesignInputSpecification], n_batches=None
    ) -> Dict[str, Dict[str, Any]]:
        ...
        # Based on inputs, construct the specifications to loop through
        design_specifications = {}
        for prefix, example_spec in inputs.items():
            # Record task name in the specification
            example_spec["extra"]["task_name"] = prefix

It seems like this does not happen when running RFD3 using JSON inputs, since the process_input function in engine.py returns a dictionary. In this case accessing "extra" key works without issues. However, when I attempt to feed a dictionary into .run() method on the engine instance, I get _canonicalize_inputs throwing an error complaining that a dictionary input is not supported.

This issue can be easily mitigated by using a dictionary example_spec_ in _multiply_specifications:

    def _multiply_specifications(
        self, inputs: Dict[str, dict | DesignInputSpecification], n_batches=None
    ) -> Dict[str, Dict[str, Any]]:
        # Find existing example IDS in output directory
        if exists(self.out_dir):
            existing_example_ids = set(
                extract_example_id_from_path(path, CIF_LIKE_EXTENSIONS)
                for path in find_files_with_extension(self.out_dir, CIF_LIKE_EXTENSIONS)
            )
            ranked_logger.info(
                f"Found {len(existing_example_ids)} existing example IDs in the output directory."
            )

        # Based on inputs, construct the specifications to loop through
        design_specifications = {}
        for prefix, example_spec in inputs.items():
            # Record task name in the specification
            example_spec_ = example_spec.model_dump()
            example_spec_["extra"]["task_name"] = prefix

            # ... Create n_batches for example
            for batch_id in range((n_batches) if exists(n_batches) else 1):
                # ... Example ID
                example_id = f"{prefix}_{batch_id}" if exists(n_batches) else prefix

                if (
                    self.skip_existing
                    and exists(self.out_dir)
                    and example_id in existing_example_ids
                ):
                    ranked_logger.info(
                        f"Skipping design specification for example {example_id} | Already exists."
                    )
                    continue
                design_specifications[example_id] = example_spec_
        return design_specifications

Please let me know if such a fix is OK for you, I could submit a PR for this. Or feel free to fix it on your end if you prefer no external contributions 🙂

Many thanks for providing this amazing repository, it's truly impressive how RFDiffusion has evolved!

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