Skip to content

CPU bottleneck in taxonomy aggregation for non-species predictions #147

Description

@mitchellxh

When requesting higher taxonomic ranks (genus, family, order, etc.), TreeOfLifeClassifier.predict() seems to aggregate the species-level probabilities up the taxonomy tree. Currently, this aggregation uses CPU loops with dictionary lookups - creating a major bottleneck.

With 10k plant images and the current 350K plantae species in the TOL embeddings, that's 3.5 billion dictionary operations on a single CPU-core. I suggest moving this to the GPU with precomputed species-rank mappings up front and using PyTorch scatter_add for accumulation. In my 10k dataset, this went from ~130 minutes for family-level predictions to ~4.8 minutes.

Happy to submit PR if interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions