The literature on structured prediction for NLP describes a rich collectionof distributions and algorithms over sequences, segmentations, alignments, andtrees; however, these algorithms are difficult to utilize in deep learningframeworks. We introduce Torch-Struct, a library for structured predictiondesigned to take advantage of and integrate with vectorized,auto-differentiation based frameworks. Torch-Struct includes a broad collectionof probabilistic structures accessed through a simple and flexibledistribution-based API that connects to any deep learning model. The libraryutilizes batched, vectorized operations and exploits auto-differentiation toproduce readable, fast, and testable code. Internally, we also include a numberof general-purpose optimizations to provide cross-algorithm efficiency.Experiments show significant performance gains over fast baselines andcase-studies demonstrate the benefits of the library. Torch-Struct is availableat https://github.com/harvardnlp/pytorch-struct.