Skip to main content

Tools for multicopy refinement of crystallographic models

Reason this release was yanked:

Breaking bug in toml not including sub packages

Project description

TorchRef

A PyTorch-based crystallographic refinement library

Python 3.8+ PyTorch License: MIT

TorchRef is a crystallographic refinement package built entirely on PyTorch. By leveraging PyTorch's automatic differentiation and GPU acceleration, TorchRef enables seamless integration with machine learning workflows and provides a flexible, extensible framework for crystallographic structure refinement.

Key Features

  • Native PyTorch Integration: Built on PyTorch's nn.Module architecture, TorchRef integrates naturally with the PyTorch ecosystem, including machine learning models, optimizers, and GPU acceleration.

  • Automatic Differentiation: Dynamic computational graphs eliminate the need for manually implemented gradient calculations. Define new refinement targets directly—PyTorch handles the derivatives automatically.

  • Modular Architecture: Following PyTorch's module pattern, components are easily composable and extensible. Add custom targets, restraints, or optimizers without modifying core code.

  • GPU Acceleration: Leverage CUDA for structure factor calculations, scaling, and optimization—achieving significant speedups for large structures.

  • FFT-based Structure Factors: Efficient structure factor calculation using Fast Fourier Transform (FFT) methods, enabling rapid F_calc computation even for large unit cells.

  • State Management: Full state_dict support enables saving and loading complete refinement states, including model parameters, scaler settings, and restraints.

Installation

# Clone the repository
git clone https://github.com/HatPdotS/TorchRef.git
cd torchref

# Install with pip
pip install -e .

# Or install with development dependencies
pip install -e ".[dev]"

Dependencies

  • Python ≥ 3.8
  • PyTorch ≥ 1.9
  • NumPy ≥ 1.20
  • Gemmi ≥ 0.5
  • reciprocalspaceship ≥ 0.9
  • SciPy ≥ 1.7

Getting Started

For demonstrations and usage examples, see the example notebooks in example_notebooks/:

Testing

# Run all tests
pytest tests/

# Run with coverage
pytest tests/ --cov=torchref

# Run specific test categories
pytest tests/unit/           # Fast unit tests
pytest tests/integration/    # Integration tests
pytest tests/functional/     # Full workflow tests

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Follow the NumPy docstring style
  2. Add tests for new functionality
  3. Ensure all tests pass before submitting

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchref-0.3.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchref-0.3.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file torchref-0.3.0.tar.gz.

File metadata

  • Download URL: torchref-0.3.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for torchref-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f96f7541d15b09c93b513be526fcd1fffc36ec3398d47aa4fb8c47c514f949bb
MD5 29d93baa90a65f151420ba3117ef0b2a
BLAKE2b-256 737f9c1e4112b5dd16c6712d7a8542a20f84bfd290f42c79dbcc4124a4df4ec9

See more details on using hashes here.

Provenance

The following attestation bundles were made for torchref-0.3.0.tar.gz:

Publisher: publish.yml on HatPdotS/TorchRef

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torchref-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: torchref-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for torchref-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9aab291be3d860b38a5b2b21ea1e005f08aee06019c46669158e7a972b13cd9
MD5 0a5fdba1298a3c152f8aa3408cdf637d
BLAKE2b-256 64ac2604e364cc5df69ccdc7f3c9f0cdccaf9c51e96c4d622e64b508ed42d102

See more details on using hashes here.

Provenance

The following attestation bundles were made for torchref-0.3.0-py3-none-any.whl:

Publisher: publish.yml on HatPdotS/TorchRef

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page