Repository navigation
feat(drug-discovery)!: featurize molecules as AttentiveFP does - #49
Merged
Merged
Conversation
smiles_to_graph and batch_smiles_to_graphs now produce the AttentiveFP featurization (Xiong et al. 2019) as DGL-LifeSci's AttentiveFPAtomFeaturizer and AttentiveFPBondFeaturizer define it: 39 atom features and 10 bond features, against 34 and 4. The graphs gain chirality, CIP labels, radical electrons, conjugation, ring membership and bond stereo, so stereoisomers no longer share one graph. On BBBP as MolNet supplies it, 12 molecules in 6 groups did, 2 of the groups with conflicting labels; none do now. The value sets are tuples matched against RDKit enum names, so the widths are known without importing RDKit, and DEFAULT_ATOM_FEATURES and DEFAULT_BOND_FEATURES are derived from them. AtomFeatureConfig, DEFAULT_ATOM_CONFIG and ATOM_TYPES are removed, and get_atom_features takes no configuration. The ethanol test vectors are the reference's documented output. The API and user-guide pages describe the new features, and their shapes, the removed config row and the example output follow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Molecular graphs carry the AttentiveFP featurization (Xiong et al. 2019), as DGL-LifeSci's
AttentiveFPAtomFeaturizerandAttentiveFPBondFeaturizer(Apache-2.0) define it.DEFAULT_ATOM_FEATURESandDEFAULT_BOND_FEATURESare derived without importing RDKit. Every operator default followsthem (since fix(drug_discovery): operator input widths default to the featurizer's #48).
AtomFeatureConfig,DEFAULT_ATOM_CONFIGandATOM_TYPESare removed;get_atom_featurestakes no configuration. This is a clean break with no alias.
configrow naming the removedclass, and the fingerprint example's shape output.
Evidence
Before: on main,
test_attentivefp_features.pyand the updatedtest_molecular_graphs.pyfail 19 and pass 6 (the padding, x64 and refusal tests).
After: 25 passed.
BBBP identical-graph groups (every split, the shipped builder, all groups stereo-only):
Speed, RTX 4090, jax 0.11.1. Main and the branch alternate, 2 rounds each:
nnx.value_and_gradthroughnnx.vmap, 64 padded BBBP molecules: MolecularPropertyPredictorbatch_smiles_to_graphs, 256 BBBP molecules, CPU backend, best of 15The training steps are within run-to-run noise at these shapes. The host cost per molecule is
about the same (
_host_graphover 256 molecules: 59.6 and 61.3 ms against 66.7 and 71.0 ms). Thebatch is slower because its dense
(B, N, N, F_bond)edge array grows from 41 MB to 102 MB withthe bond width: the NumPy fill goes from 4.4 to about 12 ms, the transfer to the GPU from about 5
to 13 ms. The cost belongs to the dense layout; the padding change that follows works on that
layout.
Gate:
tests/operators/drug_discoveryandtests/operators/test_drug_discovery.py146 passed;the MolNet and DTI benchmark tests and the experimental-boundary test 21 passed; pre-commit
over all files, ruff, ruff format, lint-imports (6 kept), pyright on the changed files, and
mkdocs build --clean --strictall pass.Merge Danger
Door: two-way
A revert restores the 34 and 4 widths. Nothing persists graphs or trained weights at these
widths in the repository.
Blast Radius: featurization
Every graph, and every operator built with default widths, changes width; models trained on the
old graphs need retraining. Code that passed a config to
get_atom_features, or importedAtomFeatureConfig,DEFAULT_ATOM_CONFIGorATOM_TYPES, breaks. Within the repository, thebenchmarks and scripts refer to the widths by symbol only. The random-init numbers printed on
the example pages were already stale on main (the fingerprint page shows 0.4735 where main
computes 0.4362), because
scripts/generate_example_outputs.pyfails at import on the installedmatplotlib (
plt.BarContainer). That defect is left for the docs change.