floydnet 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: floydnet
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Floyd Multi-Head Attention: a drop-in variant of PyTorch MHA with module and function APIs
5
5
  Project-URL: Homepage, https://github.com/ocx-lab/FloydNet
6
6
  Project-URL: Repository, https://github.com/ocx-lab/FloydNet
@@ -230,49 +230,162 @@ Requires-Dist: pytest>=7.4; extra == 'dev'
230
230
  Requires-Dist: ruff>=0.5; extra == 'dev'
231
231
  Description-Content-Type: text/markdown
232
232
 
233
- # floyd-net
233
+ # FloydNet
234
234
 
235
- Floyd Multi-Head Attention (F-MHA) is a drop-in variant of PyTorch's attention stack. It provides:
235
+ Official implementation of an ICLR paper (TODO: add paper title, authors, and links/arXiv).
236
236
 
237
- - Module API: `FloydMultiheadAttention` mirroring `torch.nn.MultiheadAttention`
238
- - Functional API: `floyd_scaled_dot_product_attention` mirroring `torch.nn.functional.scaled_dot_product_attention`
237
+ ![Figure Pivotal Attention Mechanism for 2-Floyd/3-Floyd.](misc/pivotalattn2&3.png)
239
238
 
240
- Install and manage with `uv` for a modern Python workflow.
239
+ This repository serves two audiences:
241
240
 
242
- ## Quick start
241
+ - **Engineering users**: reusable PyTorch components (functional attention APIs and Transformer-style blocks) under `src/`.
242
+ - **Research users**: scripts/configs to reproduce paper experiments under `example/`.
243
243
 
244
+ ---
245
+
246
+ ## Introduction
247
+
248
+ FloydNet is the official PyTorch implementation accompanying an ICLR paper (TODO).
249
+ The repository provides:
250
+
251
+ 1. **Reusable components**: a drop-in attention/Transformer-block interface intended for integration into existing projects.
252
+ 2. **Reproduction code**: end-to-end training/evaluation pipelines to reproduce the benchmarks reported in the paper.
253
+
254
+ For algorithmic details, hyperparameter choices, and analysis, please refer to the paper (TODO: link).
255
+
256
+ ---
257
+
258
+ ## Repository Structure
259
+
260
+ - `src/floydnet/`
261
+ **Library code for reuse**
262
+ Contains the functional attention API and module/block implementations.
263
+
264
+ - `example/`
265
+ **Experiment reproduction code**
266
+ Includes benchmark-specific scripts, configs, and data preparation utilities.
267
+
268
+ ---
269
+
270
+ ## Using the Attention / Transformer Block
271
+
272
+ This section targets **engineering users** who want to import FloydNet as a dependency.
273
+
274
+ ### Installation
275
+
276
+ #### Option A: Install from PyPI
244
277
  ```bash
245
- # Install with uv (recommended)
246
- uv venv --python 3.10
247
- source .venv/bin/activate
248
- uv pip install -e .[dev]
278
+ pip install floydnet
249
279
  ```
250
280
 
251
- ```python
252
- import torch
253
- from floyd_net import FloydMultiheadAttention
281
+ #### Option B: Install from source
282
+ ```bash
283
+ git clone git@github.com:ocx-lab/FloydNet.git
284
+ cd FloydNet
285
+ pip install -e .
286
+ ```
254
287
 
255
- m = FloydMultiheadAttention(embed_dim=64, num_heads=8, batch_first=True)
256
- x = torch.randn(2, 16, 64)
257
- out, attn = m(x, x, x)
258
- print(out.shape)
288
+ > Requirements: Python `>= 3.9`, PyTorch `>= 2.1` (see `pyproject.toml`).
289
+
290
+ ### Public API
291
+
292
+ FloydNet re-exports the public API from `src/floydnet/__init__.py`, so you can import from the top-level package:
293
+
294
+ - **Functional API**:
295
+ - `pivotal_attention` (see `src/floydnet/functional.py`)
296
+ - **Module / block API**:
297
+ - `PivotalAttentionBlock` (see `src/floydnet/transformer.py`)
298
+
299
+ ```python
300
+ from floydnet import pivotal_attention, PivotalAttentionBlock
259
301
  ```
260
302
 
261
- ### Functional API
303
+ ### Minimal usage example
304
+
262
305
  ```python
263
306
  import torch
264
- import torch.nn.functional as F
265
- from floyd_net import floyd_scaled_dot_product_attention
307
+ from floydnet import pivotal_attention, PivotalAttentionBlock
308
+
309
+ # -------------------------
310
+ # Module API (Transformer-style block)
311
+ # Input is a 2D grid: (B, N, N, C)
312
+ # -------------------------
313
+ B, N, C = 2, 16, 64
314
+ x = torch.randn(B, N, N, C)
266
315
 
267
- q = torch.randn(2, 8, 16, 64) # (B, H, L, D)
268
- k = torch.randn(2, 8, 16, 64)
269
- v = torch.randn(2, 8, 16, 64)
270
- out = floyd_scaled_dot_product_attention(q, k, v)
316
+ m = PivotalAttentionBlock(embed_dim=C, num_heads=8, dropout=0.0)
317
+ out = m(x) # (B, N, N, C)
271
318
  print(out.shape)
319
+
320
+ # -------------------------
321
+ # Functional API
322
+ # All inputs are 5D: (B, H, N, N, D)
323
+ # -------------------------
324
+ B, H, N, D = 2, 8, 16, 64
325
+ q_ik = torch.randn(B, H, N, N, D)
326
+ k_ij = torch.randn(B, H, N, N, D)
327
+ k_jk = torch.randn(B, H, N, N, D)
328
+ v_ij = torch.randn(B, H, N, N, D)
329
+ v_jk = torch.randn(B, H, N, N, D)
330
+
331
+ y = pivotal_attention(q_ik, k_ij, k_jk, v_ij, v_jk) # (B, H, N, N, D)
332
+ print(y.shape)
272
333
  ```
273
334
 
274
- ## Paper reproductions
275
- See `paper/` for dataset preparation, configs, and experiment templates to reproduce the results in the paper.
335
+ ---
336
+
337
+ ## Reproducing Paper Results
338
+
339
+ This section targets **research users** who want to reproduce the experiments in the paper.
340
+
341
+ See `example/README.md` For detailed description.
342
+
343
+ ### Environment setup
344
+
345
+ We recommend using `uv` to create an isolated environment for the reproduction code under `example/`.
346
+
347
+ ```bash
348
+ cd /path/to/FloydNet
349
+
350
+ # 1) Create a uv virtual environment with Python 3.12
351
+ uv venv --python 3.12
352
+
353
+ # 2) Activate it
354
+ source .venv/bin/activate
355
+
356
+ # 3) Install extra dependencies for reproducing paper experiments
357
+ uv pip install -r example/requirements.txt
358
+
359
+ # 4) Install FloydNet (editable) for local development / imports
360
+ uv pip install -e .
361
+ ```
362
+
363
+ ## Changelog (latest)
364
+
365
+ - Full release with training and evaluation scripts for Graph Count, BREC, and TSP.
366
+ - Added `pivotal_attention3` functional API for 3-Floyd attention.
367
+ - Added additional configuration options in `PivotalAttentionBlock`.
368
+
369
+ The full changelog is in [CHANGELOG.md](CHANGELOG.md).
370
+
371
+ ## Citation
372
+
373
+ If you use this code in your research, please cite the paper:
374
+
375
+ ```bibtex
376
+ @inproceedings{TODO,
377
+ title = {TODO},
378
+ author = {TODO},
379
+ booktitle = {International Conference on Learning Representations (ICLR)},
380
+ year = {TODO},
381
+ url = {TODO}
382
+ }
383
+ ```
384
+
385
+ (Alternatively, see [CITATION.cff](CITATION.cff).)
386
+
387
+ ---
276
388
 
277
389
  ## License
278
- MIT
390
+
391
+ This project is licensed under the **Apache License 2.0**. See [LICENSE](LICENSE).
@@ -0,0 +1,4 @@
1
+ floydnet-0.1.1.dist-info/METADATA,sha256=NRDtZp6xWpO3XK2Sm4ZUUZ1XzaWlic7Q936GizgI12s,18525
2
+ floydnet-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
3
+ floydnet-0.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
4
+ floydnet-0.1.1.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- floydnet-0.1.0.dist-info/METADATA,sha256=CEiEOoK6xaTHx3JaiDTML-D28Fu4f1lqcKykJyRjAhs,15507
2
- floydnet-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
3
- floydnet-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
4
- floydnet-0.1.0.dist-info/RECORD,,