Releases: Quantinuum/lambeq
0.5.0
Added:
- A new experimental
lambeq.experimental.discocircmodule that contains an efficientlambeq.experimental.discocirc.DisCoCircReaderand all the required functionality for converting long texts and entire multi-paged documents into quantum circuits, based on theDisCoCircframework. - A new tree representation of a pregroup diagram, termed
pregroup tree, is implemented through thelambeq.text2diagram.pregroup_tree.PregroupTreeNodeclass. This lays the groundwork for drastically improving the parsing and internal processing of diagrams. - A new experimental end-to-end parser class,
lambeq.text2diagram.OncillaParser, that simplifies the process of generating diagrams from text, minimizing or even eliminating exposure of the user to CCG representations and functionality. This parser utilises thepregroup treerepresentation of diagrams. This does not replaceBobcatParseras the default parser. - A new
lambeq.backend.grammar.Framedata structure that allows the recursive grouping oflambeqboxes and diagrams and can be seen as aquantum supermapacting on the enclosed arguments. Frames are used inDisCoCircdiagrams. - A new
lambeq.training.PytorchQuantumModelclass that allows Pytorch autograd to be used on quantum circuits, while so far it was possible to use it only on tensor networks (credit: Kin Ian Lo). - A new native
lambeq.backend.symbol.Symbolclass that eliminates any dependencies with SymPy and improves efficiency. - A new rewrite rule class,
lambeq.rewrite.CollapseDomainRewriteRule, that converts boxes into domain-less boxes by uncurrying (credit: Kin Ian Lo). - New
lambeq.backend.Diagram.remove_snakesandlambeq.backend.Diagram.rigid_normal_formmethods that make the specific rewrites also available outside of the originallambeq.backend.Diagram.normal_formmethod (credit: Kin Ian Lo). - Caching options for fast access to already computed tensor contraction paths for tensor network models, specifically
PytorchModelandPytorchQuantumModel. The constructor of these models now takes atn_path_optimizerargument, which can be aTnPathOptimizerobject, replicating the old un-cached behaviour, or aCachedTnPathOptimizerwhich allows caching of the computed tensor contraction paths for quick lookup. - Support for evaluating mixed-scalar PennyLane circuits, i.e. circuits where all qubits are either discarded or post-selected.
- Two new ansätze from the Sim et al. paper (arXiv:1905.10876),
Sim9AnsatzandSim9CxAnsatz. - Support for ancilla qubits in
lambeq's ansätze.
Changed:
- Significantly improved the efficiency of the
PennyLaneModel. - Refactored all models so that they do not depend on
tketas an intermediate step for their conversions. CircuitAnsatznow acts as a dagger functor (credit: Kin Ian Lo).- Refactored
QuantumModelto be less numpy-specific and easier to extend with other backends. - Made the split tensor ansätze, i.e.
SpiderAnsatzandMPSAnsatz, work on boxes with domains. This utilises the newly-implementedCollapseDomainRewriteRule(credit: Kin Ian Lo). - Changed the
devicekeyword argument for model-based parsers, e.g.BobcatParser, so that it follows PyTorch convention and supports multiple types. - Added the new
lambeq.text2diagram.OncillaParseras a parser option to the CLI via the-p oncillaargument. - Removed the deprecated
lambeq.text2diagram.DepCCGParseras a parser option from the CLI. - Refactored tokeniser loading from
SpacyTokeniserinto a new utility functionlambeq.core.utils.get_spacy_tokeniser. - Significantly extended and restructured the documentation pages, fixed various issues, and added more material and tutorials.
- Made
tketan optional dependency.
Fixed:
- Fixed an enum incompatibility with Python > 3.10.
- Fixed the behaviour of tensoring a type with the identity diagram.
- Fixed a
lambeq.backend.Diagram.lambdifymethod error when used with a daggered tensor box (credit: Kin Ian Lo).
0.4.3
Changed:
- Documentation has now been moved to a dedicated repository and got a new URL (https://cqcl.github.io/lambeq-docs/).
- Changed the landing page and some visuals in the online documentation.
- Updated README to reflect the new docs structure.
Fixed:
- Fixed minor issues on some documentation pages and the README file.
0.4.2
Added:
- Added timing information to training logs and model checkpoints.
Changed:
- Changed theme of online documentation.
- Updated required version of
pytketto 1.31.0.
Fixed:
- Fixed bug in generation of single-legged quantum spiders.
- Fixed bug when evaluating quantum circuits using Tket.
Removed:
- Removed support for Python 3.9.
0.4.1
Added:
- Support for Python 3.12.
- A new
Sim4Ansatzbased on the paper by Sim et al. (arXiv:1905.10876). - A new argument in
Trainer.fitfor specifying anearly_stopping_criterionother than validation loss. - A new argument
collapse_noun_phrasesin methods ofCCGParserandCCGTreeclasses (for example, seeCCGParser.sentence2diagram) that allows the user to maintain noun phrases in the derivation or collapse them into nouns as desired. - Raised meaningful exception when users try to convert to/from DisCoPy 1.1.0.
Changed:
- An internal refactoring of module
backend.drawingin view of planned new features. - Updated random number generation in
TketModelby using the recommendednumpy.random.default_rndmethod.
Fixed:
- Handling of possible empty
Bras andKets during conversion from DisCoPy. - Fixed a bug in JIT compilation of mixed circuit evaluations.
0.4.0
Added:
-
A new integrated backend that replaces
DisCoPy, which until now was providing the low-level functionality oflambeq. The new backend offers better performance, increased stability, faster training speeds, and a simplified high-level interface to the user. The new backend consists of the following sub-modules:lambeq.backend.grammar: Contains the building blocks for creating string diagrams.lambeq.backend.tensor: Contains the necessary classes to create tensor diagrams.lambeq.backend.quantum: Adds quantum-specific functionality to the backend and provides a circuit simulator based on the TensorNetwork library.lambeq.backend.pennylane: Interface with PennyLane.lambeq.backend.tk: Inteface with Tket.lambeq.backend.numerical_backend: Common interface for numerical backends (such as Numpy, Jax, PyTorch, TensorFlow)lambeq.backend.drawing: Contains drawing functionality for diagrams and circuits.
-
lambeq.BobcatParser: Added a special case for adjectival conjunction in tree translation. -
lambeq.TreeReader: Diagrams now are created straight from thelambeq.CCGTree. -
lambeq.CCGRuleapply method: Addedlambeq.CCGRule.applymethod to classlambeq.CCGRule.
Changed:
- Diagram-level rewriters: Rewrite functions
remove_cupsandremove_swapsare now refactored as diagram-level rewriters,lambeq.RemoveCupsRewriterandlambeq.RemoveSwapsRewritercorrespondingly. - Extra whitespace is now ignored in the
lambeq.Tokeniser.
Fixed:
lambeq.UnknownWordsRewriteRule: Fixed rewriting of non-word boxes.
Removed:
- Removed
CCGTree.to_biclosed_diagramand references todiscopy.biclosed. Now CCG trees are directly converted into string diagrams, without the extra step of storing the derivation in a biclosed form. lambeq.CCGRule: Removedreplace_cat_resultand addedlambeq.CCGRule.resolve.
0.3.3
This update features contributions from participants in unitaryHACK 2023:
- Two new optimisers:
- The Nelder-Mead optimiser. (credit: Gopal Dahale)
- The Rotosolve optimiser. (credit: Ahmed Darwish)
- A new rewrite rule for handling unknown words. (credit: WingCode)
Many thanks to all who participated.
This update also contains the following changes:
Added:
DiagramRewriteris a new class that rewrites diagrams by looking at the diagram as a whole rather than by using rewrite rules on individual boxes. This includes an exampleUnifyCodomainRewriterwhich adds an extra box to the end of diagrams to change the output to a specified type. (credit: A.C.E07)- Added an early stopping mechanism to
Trainerusing the parameterearly_stopping_interval.
Fixed:
- In
PennyLaneModel, SymPy symbols are now substituted during the forward pass so that gradients are back-propagated to the original parameters. - A pickling error that prevented CCG trees produced by
BobcatParserfrom being unpickled has been fixed.
0.3.2
Added:
- Support for
DisCoPy>= 1.1.4 (credit: toumix).- replaced
discopy.rigidwithdiscopy.grammar.pregroupeverywhere. - replaced
discopy.biclosedwithdiscopy.grammar.categorialeverywhere. - Use
Diagram.decodeto account for the change in contructor signatureDiagram(inside, dom, cod). - updated attribute names that were previously hidden, e.g.
._databecomes.data. - replaced diagrammatic conjugate with transpose.
- swapped left and right currying.
- dropped support for legacy DisCoPy.
- replaced
- Added
CCGTypeclass for utilisation in thebiclosed_typeattribute ofCCGTree, allowing conversion to and from a discopy categorial object usingCCGType.discopyandCCGType.from_discopymethods. CCGTree: added reference to the original tree from parsing by introducing ametadatafield.
Changed:
- Internalised DisCoPy quantum ansätze in lambeq.
IQPAnsatznow ends with a layer of Hadamard gates in the multi-qubit case and the post-selection basis is set to be the computational basis (Pauli Z).
Fixed:
- Fixed a bottleneck during the initialisation of the
PennyLaneModelcaused by the inefficient substitution of Sympy symbols in the circuits. - Escape special characters in box labels for symbol creation.
- Documentation: fixed broken links to DisCoPy documentation.
- Documentation: enabled sphinxcontrib.jquery extension for Read the Docs theme.
- Fixed disentangling
RealAnsatzin extend-lambeq tutorial notebook. - Fixed model loading in PennyLane notebooks.
- Fixed typo
SPSAOptimizer(credit: Gopal-Dahale)
Removed:
- Removed support for Python 3.8.
0.3.1
Changed:
- Added example and tutorial notebooks to tests.
- Dependencies: pinned the maximum version of Jax and Jaxlib to 0.4.6 to avoid a JIT-compilation error when using the
NumpyModel.
Fixed:
- Documentation: fixed broken DisCoPy links.
- Fixed PyTorch datatype errors in example and tutorial notebooks.
- Updated custom ansätze in tutorial notebook to match new structure of
CircuitAnsatzandTensorAnsatz.
0.3.0
Added:
- Support for hybrid quantum-classical models using the
PennyLaneModel.PennyLaneis a powerful QML library that allows the development of hybrid ML models by hooking numerically determined gradients of parametrised quantum circuits (PQCs) to the autograd modules of ML libraries like PyTorch or TensorFlow. - Add lambeq-native loss functions
LossFunctionto be used in conjunction with theQuantumTrainer. Currently, we support theCrossEntropyLoss,BinaryCrossEntropyLoss, and theMSELossloss functions. - Python 3.11 support.
- An extensive NLP-101 tutorial, covering basic definitions, text preprocessing, tokenisation, handling of unknown words, machine learning best practices, text classification, and other concepts.
Changed:
- Improve tensor initialisation in the
PytorchModel. This enables the training of larger models as all parameters are initialised such that the expected L2 norm of all output vectors is approximately 1. We use a symmetric uniform distribution where the range depends on the output dimension (flow) of each box. - Improve the fail-safety of the
BobcatParsermodel download method by adding hash checks and atomic transactions. - Use type union expression
|instead ofUnionin type hints. - Use
raise fromsyntax for better exception handling. - Update the requirements for the documentation.
Fixed:
- Fixed bug in
SPSAOptimizertriggered by the usage of masked arrays. - Fixed test for
NumpyModelthat was failing due to a change in the behaviour of Jax. - Fixed brittle quote-wrapped strings in error messages.
- Fixed 400 response code during Bobcat model download.
- Fixed bug where
CircuitAnsatzwould add empty discards and postselections to the circuit.
Removed:
- Removed install script due to deprecation.
0.2.8
Changed:
- Improved the performance of
NumpyModelwhen using Jax JIT-compilation. - Dependencies: pinned the required version of DisCoPy to 0.5.X.
Fixed:
- Fixed incorrectly scaled validation loss in progress bar during model training.
- Fixed symbol type mismatch in the quantum models when a circuit was previously converted to tket.