Pytorch graph serialization
Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/pytorch-graph-serialization
Use when you have constructed molecular graphs with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) from SMILES or MOL files using RDKit, and need to feed them into a PyTorch-based GNN training pipeline without memory overhead or I/O.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill pytorch-graph-serializationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.4 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
PyTorch Graph Serialization for GNN Input
Summary
Serialize molecular graph representations into PyTorch-compatible formats (pickle or HDF5) to enable efficient consumption by Graph Neural Network training pipelines. This skill bridges the gap between RDKit molecular graph construction and PyTorch DataLoader ingestion for retention time prediction models.
When to use
You have constructed molecular graphs with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) from SMILES or MOL files using RDKit, and need to feed them into a PyTorch-based GNN training pipeline without memory overhead or I/O bottlenecks during model training and transfer learning phases.
When NOT to use
- Input is already in PyTorch Tensor or graph object format (Data or HeteroData from PyG)
- Molecular graphs are extremely large (>10 million atoms per structure) and serialization overhead exceeds memory savings
- Training pipeline expects streaming/online data augmentation rather than pre-serialized static batches
Inputs
- Molecular graphs with node-edge representations (constructed via RDKit)
- Atom feature arrays (atomic number, degree, formal charge, hybridization)
- Bond feature arrays (bond type, aromaticity)
- SMILES or MOL format structure files from in-house database
Outputs
- Serialized molecular graphs in pickle format
- Serialized molecular graphs in HDF5 format
- PyTorch-compatible graph batches ready for DataLoader consumption
How to apply
After converting molecular structures into node-edge representations using RDKit's graph construction methods, serialize the molecular graphs into pickle or HDF5 format to create a format compatible with PyTorch's DataLoader. The serialized graphs should retain all atom and bond feature attributes computed during the RDKit preprocessing stage. Store serialized graphs in a structured directory (e.g., the 'data' directory) that the PyTorch training pipeline can discover and batch-load during Train.py and Transferlearning.py execution. Verify serialization by confirming file sizes are reasonable relative to the number of molecules and that DataLoader can iterate over batches without deserialization errors.
Related tools
- RDKit (Construct molecular graphs with atom/bond features before serialization) — https://www.rdkit.org/
- PyTorch (Load and batch-iterate over serialized graphs via DataLoader) — https://pytorch.org/
- Python pickle module (Serialize graph objects into binary format)
- HDF5 (h5py) (Alternative serialization format for large-scale graph storage)
Examples
python Preprocess.py # converts SMILES/MOL files to serialized molecular graphs in data/ directory for consumption by PyTorch DataLoader in Train.py
Evaluation signals
- Serialized files are created and readable by Python pickle or h5py without errors
- PyTorch DataLoader successfully iterates over batches of deserialized graphs without shape or type mismatches
- Graph features (atom features, bond features) are preserved after deserialization and match the original RDKit-constructed representations
- Training pipeline (Train.py, Transferlearning.py) runs without I/O bottlenecks or out-of-memory errors when loading batches
- File sizes scale linearly with the number of molecules and average molecular complexity
Limitations
- Serialization format choice (pickle vs HDF5) affects compatibility across Python versions and platforms; pickle is Python-specific
- Large molecular datasets may require substantial disk space; pre-serialization requires estimating storage and I/O bandwidth
- Graph serialization assumes fixed schema; heterogeneous graph structures or variable feature dimensions may require custom serialization logic
- No changelog or versioning support noted in repository, making it unclear how serialized graphs from older versions interact with updated GNN-RT code
Evidence
- [other] Serialize the molecular graphs into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for consumption by the GNN training pipeline.: "Serialize the molecular graphs into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5)"
- [other] Construct molecular graphs by converting each structure into a node-edge representation with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) using RDKit's graph construction methods.: "Construct molecular graphs by converting each structure into a node-edge representation with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type,"
- [readme] It takes molecular graph as the input, and the predicted retention time as the output.: "It takes molecular graph as the input, and the predicted retention time as the output."
- [readme] put your spectra files in to data directory and run [Preprocess.py], [Train.py] and [Transferlearning.py]: "put your spectra files in to data directory and run [Preprocess.py], [Train.py] and [Transferlearning.py]"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.