Skip to main content

A library for computational algebra using Transformers

Project description

CALT: Computer ALgebra with Transformer

This project is currently in its initial development phase. The file structure and content are subject to significant changes. Please ensure you are referring to the latest version when using it.

Environment Setup using Docker

This guide explains how to set up the development environment using Docker.

Prerequisites

  • Docker installed on your system.
  • NVIDIA GPU drivers installed if you plan to use GPU acceleration (--gpus all option).

Build the Docker Image

To build the Docker image, navigate to the calt directory and run the following command:

make build

Alternatively, you can use the direct Docker command:

docker build -t ta-sage .

Run the Docker Container

To run the Docker container in detached mode with GPU support, execute:

make run

The direct Docker command is:

docker run --gpus all -d --name ta-sage-container -v "$(pwd)":/app ta-sage tail -f /dev/null

Note: When running this command directly in your terminal, $(pwd) will resolve to your current working directory. The Makefile uses $(CURDIR) which serves the same purpose within the Makefile context.

Access the Container

Once the container is running, you can access it using:

docker exec -it ta-sage-container bash

Stop and Remove the Container

To stop and remove the container, you can use:

make stop

Or manually:

docker stop ta-sage-container
docker rm ta-sage-container

Local Setup (without Docker)

This section describes how to set up the environment locally without using Docker. This assumes you have SageMath installed on your system.

1. Install SageMath

You can install SageMath using apt on Debian/Ubuntu-based systems. It's not necessary to have the absolute latest version.

Install SageMath:

sudo apt-get install -y sagemath

2. Install Dependencies

Once SageMath is installed, you can install the required Python packages using sage -pip.

First, upgrade pip:

sage -pip install --upgrade pip

Next, install the Python dependencies:

sage -pip install --break-system-packages \
    "torch==2.6.0" \
    "transformers>=4.49.0" \
    "omegaconf>=2.3.0" \
    "wandb>=0.15.11" \
    "accelerate>=0.29.0" \
    "joblib>=1.5.0"

For GPU support with PyTorch: If you need GPU support, replace the torch installation line with the one that specifies the CUDA version compatible with your system. For example, for CUDA 12.4:

sage -pip install --break-system-packages \
    --extra-index-url https://download.pytorch.org/whl/cu124 \
    "torch==2.6.0"

3. Install transformer_algebra (Editable)

Finally, install the transformer_algebra package in editable mode. Navigate to the root of the calt project directory (where this README.md and the pyproject.toml for transformer_algebra are located) and run:

sage -pip install -e .

This command assumes that the necessary setup files for transformer_algebra are in the current directory (.). If transformer_algebra is a subdirectory (e.g., /app as in the Dockerfile context), you would run sage -pip install -e /path/to/transformer_algebra_directory.

Generating Datasets

To generate the default dataset, run the following command from the project root:

sage scripts/generate.py

To generate datasets using a different ProblemGenerator class, you will need to modify scripts/generate.py by uncommenting the desired ProblemGenerator class and commenting out others.

Running Training

To start training with the default configuration, execute the following command from the project root:

sage scripts/train.py

Weights & Biases (wandb) Setup

If you are using Weights & Biases (wandb) for the first time to log training progress, you will need to create an account on their website and set up your API key. When you run the training script for the first time, you will be prompted to enter your API key.

https://wandb.ai/site/

Configuration

Training parameters can be modified by editing the configuration file located at config/train_example.yaml.

Demonstrations

Simple demonstrations for data generation and training are available as Jupyter Notebook files. You can find them in the notebook directory (please create this directory and add your notebooks if it doesn't exist yet).

To run these notebooks, you need to start SageMath's Jupyter server using the command sage -n and then select the SageMath kernel in the notebook interface.

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

calt_x-0.1.0.post2.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

calt_x-0.1.0.post2-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file calt_x-0.1.0.post2.tar.gz.

File metadata

  • Download URL: calt_x-0.1.0.post2.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for calt_x-0.1.0.post2.tar.gz
Algorithm Hash digest
SHA256 34e00bf8b51b3cea46001708a184d62abaaeab39f8cab6eb8ba0326487d7f8ff
MD5 208945f4d2532c4daa1071d443a3de1e
BLAKE2b-256 06f1030dd5465634e399ec0a7ee6be8a26e010e0ac93147f7f8120b5c0421a84

See more details on using hashes here.

File details

Details for the file calt_x-0.1.0.post2-py3-none-any.whl.

File metadata

  • Download URL: calt_x-0.1.0.post2-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for calt_x-0.1.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 6feb90e72fa9d34c567a6af7de6c541dad17989b72629bf57f2a54ba26de11f7
MD5 c8a5ef4c27c837ca0c8ee2b31c44cb81
BLAKE2b-256 367447b16a0fcb5e4abc348c38bce3546f9d304c91801ebd11eaca567b19a71e

See more details on using hashes here.

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