Skip to content

Commit 977ea02

Browse files
authored
Merge pull request #8 from kyo-takano/revision
v0.1.5
2 parents 1deb3ed + 184d0e1 commit 977ea02

16 files changed

Lines changed: 499 additions & 506 deletions

README.md

100644100755
Lines changed: 48 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,11 @@ AlphaCube is a powerful & flexible Rubik's Cube solver that extends [EfficientCu
77
88
## Use Cases
99

10-
- Solve any scrambled Rubik's Cube configuration with ease
11-
- Find efficient algorithms/solutions, optimizing for either computation speed or ergonomics of the move sequence
12-
- Incorporate into Rubik's Cube apps and tools to provide solving capabilities
13-
- Analyze and study the statistical properties and solution space of the Rubik's Cube puzzle
14-
- Illustrate AI/ML concepts to students. Topics include:
15-
- discrete diffusion model
16-
- self-supervised learning
17-
- combinatorial search with probabilities
18-
19-
---
20-
21-
## Table of Contents
22-
23-
- [AlphaCube](#alphacube)
24-
- [Use Cases](#use-cases)
25-
- [Table of Contents](#table-of-contents)
26-
- [Installation](#installation)
27-
- [Usage](#usage)
28-
- [Basic](#basic)
29-
- [Better Solutions](#better-solutions)
30-
- [Applying Ergonomic Bias](#applying-ergonomic-bias)
31-
- [GPU Acceleration](#gpu-acceleration)
32-
- [How It Works](#how-it-works)
33-
- [Contributing](#contributing)
34-
- [License](#license)
10+
- Solve any scrambled Rubik's Cube configuration with ease.
11+
- Find efficient algorithms, optimizing for either solution length or ergonomic move sequences.
12+
- Incorporate solving capabilities into custom Rubik's Cube applications and tools.
13+
- Analyze the statistical properties and solution space of the Rubik's Cube.
14+
- Illustrate AI/ML concepts such as self-supervised learning and heuristic search.
3515

3616
## Installation
3717

@@ -43,15 +23,17 @@ pip install -U alphacube
4323

4424
## Usage
4525

46-
### Basic
26+
The first time you run `alphacube.load()`, the required model data will be downloaded and cached on your system for future use.
27+
28+
### Basic Usage
4729

4830
```python
4931
import alphacube
5032

51-
# Load a trained DNN (default: "small" on cpu, "large" on GPU)
33+
# Load a pre-trained model (defaults to "small" on CPU, "large" on GPU)
5234
alphacube.load()
5335

54-
# Solve the cube using a given scramble sequence
36+
# Solve a scramble
5537
result = alphacube.solve(
5638
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
5739
beam_width=1024, # Number of candidate solutions to consider at each depth of search
@@ -66,14 +48,14 @@ print(result)
6648
> 'solutions': [
6749
> "D L D2 R' U2 D B' D' U2 B U2 B' U' B2 D B2 D' B2 F2 U2 F2"
6850
> ],
69-
> 'num_nodes': 19744, # Total search nodes explored
70-
> 'time': 1.4068585219999659 # Wall-clock time in seconds
51+
> 'num_nodes': 19744, # Total search nodes explored
52+
> 'time': 1.4068585219999659 # Time in seconds
7153
> }
7254
> ```
7355
7456
### Better Solutions
7557
76-
Increasing `beam_width` explores more candidate solutions, producing shorter (better) solve sequences at the cost of increased computation:
58+
Increasing `beam_width` makes the search more exhaustive, yielding shorter solutions at the cost of extra compute:
7759
7860
```python
7961
result = alphacube.solve(
@@ -96,14 +78,42 @@ print(result)
9678
> }
9779
> ```
9880
99-
`beam_width` values between 1024-65536 typically offer a good trade-off between solution quality and speed. Tune according to your needs.
81+
`beam_width` values between 1024 and 65536 typically offer a good trade-off between solution quality and speed. Tune according to your needs.
82+
83+
### GPU Acceleration
84+
85+
For maximal performance, use the `"large"` model on a GPU (or MPS if you have Mac).
86+
87+
```python
88+
alphacube.load("large")
89+
result = alphacube.solve(
90+
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
91+
beam_width=65536,
92+
)
93+
print(result)
94+
```
95+
96+
> **Output**
97+
>
98+
> ```python
99+
> {
100+
> 'solutions': ["D F L' F' U2 B2 U F' L R2 B2 U D' F2 U2 R D'"],
101+
> 'num_nodes': 903448,
102+
> 'time': 20.46845487099995
103+
> }
104+
> ```
105+
106+
> [!IMPORTANT]
107+
> When running on a CPU, the default `"small"` model is recommended. The `"base"` and `"large"` models are significantly slower without a GPU.
108+
109+
Please refer to our [documentation](https://alphacube.dev/docs) for more, especially ["Getting Started"](https://alphacube.dev/docs/getting-started/index.html)
100110
101111
### Applying Ergonomic Bias
102112
103-
The `ergonomic_bias` parameter lets you specify the desirability of each move type, influencing the solver to favor certain moves over others:
113+
The `ergonomic_bias` parameter can influence the solver to prefer certain types of moves, generating solutions that might be easier to perform.
104114
105115
```python
106-
# Desirability scale: 0 (lowest) to 1 (highest)
116+
# Define desirability for each move type (higher is more desirable)
107117
ergonomic_bias = {
108118
"U": 0.9, "U'": 0.9, "U2": 0.8,
109119
"R": 0.8, "R'": 0.8, "R2": 0.75,
@@ -141,48 +151,18 @@ print(result)
141151
> }
142152
> ```
143153
144-
### GPU Acceleration
145-
146-
For maximum performance, use the `"large"` model on a CUDA-enabled GPU (requires [PyTorch](https://pytorch.org/get-started/locally/)):
147-
148-
```python
149-
alphacube.load("large")
150-
result = alphacube.solve(
151-
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
152-
beam_width=65536,
153-
)
154-
print(result)
155-
```
156-
157-
> **Output**
158-
>
159-
> ```python
160-
> {
161-
> 'solutions': ["D F L' F' U2 B2 U F' L R2 B2 U D' F2 U2 R D'"],
162-
> 'num_nodes': 903448,
163-
> 'time': 20.46845487099995
164-
> }
165-
> ```
166-
167-
Using a GPU provides an order of magnitude speedup over CPUs, especially for larger models.
168-
169-
> [!IMPORTANT]
170-
> When running AlphaCube _on a CPU_, it's generally recommended to stick with the `"small"` model, as the larger `"base"` and `"large"` models would take considerably more time to find solutions.
171-
172-
Please refer to our [documentation](https://alphacube.dev/docs) for more, especially ["Getting Started"](https://alphacube.dev/docs/getting-started/index.html)
173-
174154
## How It Works
175155
176-
At the heart of AlphaCube lies a deep learning method described in ["Self-Supervision is All You Need for Solving Rubik's Cube" (TMLR'23)](https://openreview.net/forum?id=bnBeNFB27b), the official code of which is also available as [EfficientCube](https://github.com/kyo-takano/efficientcube).
156+
At its core, AlphaCube uses the deep learning method from ["Self-Supervision is All You Need for Solving Rubik's Cube" (TMLR'23)](https://openreview.net/forum?id=bnBeNFB27b), the official code for which is available at [`kyo-takano/efficientcube`](https://github.com/kyo-takano/efficientcube).
177157
178-
The 3 provided models (`"small"`, `"base"`, and `"large"`) are **_compute-optimally trained_** in the Half-Turn Metric, This means the model sizes are scaled in tandem with the amount of training data to maximize prediction accuracy for a given computational budget. See Section 7 of the above-mentioned paper for details.
158+
The provided models (`"small"`, `"base"`, and `"large"`) are **compute-optimally trained** in the Half-Turn Metric. This means model size and training data were scaled together to maximize prediction accuracy for a given computational budget, as detailed in the paper.
179159
180160
> [!NOTE]
181-
> **📖 Read more: ["How It Works"](https://alphacube.dev/docs/how-it-works/index.html)**
161+
> **📖 Read more: ["How It Works"](https://alphacube.dev/docs/how-it-works)** on our documentation site.
182162
183163
## Contributing
184164
185-
You are more than welcome to collaborate on AlphaCube. Please read our [Contributing Guide](https://github.com/kyo-takano/alphacube/blob/main/CONTRIBUTING.md) to get started.
165+
You are welcome to collaborate on AlphaCube! Please read our [Contributing Guide](https://github.com/kyo-takano/alphacube/blob/main/CONTRIBUTING.md) to get started.
186166
187167
## License
188168

0 commit comments

Comments
 (0)