Skip to content

Commit a4847ba

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/wavlm
2 parents bccfd43 + e786a90 commit a4847ba

33 files changed

Lines changed: 965 additions & 245 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ jobs:
167167
CIBW_BEFORE_ALL_MACOS: python/tools/prepare_build_environment_macos.sh
168168
CIBW_BEFORE_ALL_WINDOWS: bash python/tools/prepare_build_environment_windows.sh
169169
CIBW_BEFORE_BUILD: pip install -r python/install_requirements.txt
170-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
171-
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
170+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
171+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
172172
CIBW_ARCHS: ${{ matrix.arch }}
173173
CIBW_SKIP: "*-musllinux_*"
174174

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44

55
### Fixes and improvements
66

7+
## [v4.6.3](https://github.com/OpenNMT/CTranslate2/releases/tag/v4.6.3) (2026-01-XX)
8+
9+
### New features
10+
11+
* T5Gemma model conversion and inference (#1962) by [@jordimas](https://github.com/jordimas)
12+
* Support for CUDA 12.8 (#1937, #1940) by [@Purfview](https://github.com/Purfview)
13+
* Conv1d pure CUDA implementation (#1949), makes cuDNN an optional dependency by [@jordimas](https://github.com/jordimas)
14+
* Add CUDA implementation for median filter (#1917) by [@ja2d8a4v](https://github.com/a2d8a4v)
15+
16+
### Fixes and improvements
17+
18+
* Fix issue- tokens batch_type may exceed max_batch_size (#1948) by [@anterart](https://github.com/anterart)
19+
* Fixes AWQ support for Qwen 2.5/3 and Phi3 (#1951, #1952, #1953) by [@BBC-Esq](https://github.com/BBC-Esq)
20+
721
## [v4.6.2](https://github.com/OpenNMT/CTranslate2/releases/tag/v4.6.2) (2025-12-05)
822

923
### New features
@@ -29,7 +43,7 @@
2943
Note: The Ctranslate2 Python package now supports python 3.13, drop the support for python 3.8.
3044

3145
### New features
32-
* Pyhton 3.13 support (#1858)
46+
* Python 3.13 support (#1858)
3347
* Support returning hidden vector in Wav2Vec2 and Wav2Vec2Bert Models (#1867)
3448
* Add noexecstack linker flags (#1852 + #1861)
3549
* Support Qwen2 (#1820)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The project implements a custom runtime that applies many performance optimizati
88

99
The following model types are currently supported:
1010

11-
* Encoder-decoder models: Transformer base/big, M2M-100, NLLB, BART, mBART, Pegasus, T5, Whisper
11+
* Encoder-decoder models: Transformer base/big, M2M-100, NLLB, BART, mBART, Pegasus, T5, Whisper T5Gemma
1212
* Decoder-only models: GPT-2, GPT-J, GPT-NeoX, OPT, BLOOM, MPT, Llama, Mistral, Gemma, CodeGen, GPTBigCode, Falcon, Qwen2
1313
* Encoder-only models: BERT, DistilBERT, XLM-RoBERTa
1414

docker/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 as builder
1+
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04 AS builder
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends \
@@ -77,21 +77,21 @@ RUN cd python && \
7777
python3 -m pip --no-cache-dir install -r install_requirements.txt && \
7878
python3 setup.py bdist_wheel --dist-dir $CTRANSLATE2_ROOT
7979

80-
FROM nvidia/cuda:12.4.1-base-ubuntu22.04
80+
FROM nvidia/cuda:12.8.1-base-ubuntu22.04
8181

8282
# We remove the cuda-compat package because it conflicts with the CUDA Enhanced Compatibility.
8383
# See e.g. https://github.com/NVIDIA/nvidia-docker/issues/1515
8484
RUN apt-get update && \
8585
apt-get install -y --no-install-recommends \
86-
libcublas-12-4 \
87-
libcudnn9-cuda-12 \
88-
libnccl2 \
86+
libcublas-12-8=12.8.4.1-1 \
87+
libcudnn9-cuda-12=9.10.2.21-1 \
88+
libnccl2=2.26.2-1+cuda12.8 \
8989
libopenmpi3=4.1.2-2ubuntu1 \
9090
openmpi-bin \
9191
libgomp1 \
9292
python3-pip \
9393
&& \
94-
apt-get purge -y cuda-compat-12-4 && \
94+
apt-get purge -y cuda-compat-12-8 && \
9595
apt-get clean && \
9696
rm -rf /var/lib/apt/lists/*
9797

docs/guides/transformers.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ CTranslate2 supports selected models from Hugging Face's [Transformers](https://
2525
* Qwen 2.5
2626
* Qwen 3
2727
* T5
28+
* T5Gemma
2829
* Whisper
2930
* XLM-RoBERTa
3031

@@ -557,6 +558,46 @@ output_text = tokenizer.decode(tokenizer.convert_tokens_to_ids(output_tokens))
557558
print(output_text)
558559
```
559560

561+
## T5Gemma
562+
563+
[T5Gemma](https://deepmind.google/models/gemma/t5gemma/) is collection of Google encoder-decoder models that provide a strong quality-inference efficiency tradeoff.
564+
565+
To convert a model:
566+
567+
```bash
568+
ct2-transformers-converter --model google/t5gemma-b-b-prefixlm-it --output_dir t5gemma_b_b_prefixlm_it.ct2
569+
```
570+
571+
Usage:
572+
573+
```python
574+
import ctranslate2
575+
import transformers
576+
577+
translator = ctranslate2.Translator("t5gemma_b_b_prefixlm_it.ct2")
578+
tokenizer = transformers.AutoTokenizer.from_pretrained("google/t5gemma-b-b-prefixlm-it")
579+
580+
sentences = ["Question: Why is the sky blue? Answer:"]
581+
582+
# Tokenize each sentence
583+
tokenized_sentences = [
584+
tokenizer.convert_ids_to_tokens(tokenizer.encode(sentence))
585+
for sentence in sentences
586+
]
587+
588+
translated_batches = translator.translate_batch(tokenized_sentences, beam_size=1, repetition_penalty=1.2, max_decoding_length=50)
589+
590+
591+
# Decode results
592+
translations = [
593+
tokenizer.decode(tokenizer.convert_tokens_to_ids(t.hypotheses[0]))
594+
for t in translated_batches
595+
]
596+
final_translation = " ".join(translations)
597+
print(final_translation)
598+
```
599+
600+
560601
## Whisper
561602

562603
[Whisper](https://huggingface.co/docs/transformers/model_doc/whisper) is a multilingual speech recognition model published by OpenAI.

include/ctranslate2/devices.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <stdexcept>
44
#include <string>
55
#include <vector>
6+
#include <cstdint>
67
#ifdef CT2_WITH_TENSOR_PARALLEL
78
# include <nccl.h>
89
#endif

include/ctranslate2/layers/attention.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ namespace ctranslate2 {
4747
virtual bool has_positional_embeddings() const override {
4848
return _relative_position_keys || _relative_attention_bias || _rotary_embeddings || _alibi;
4949
}
50+
51+
protected:
52+
void process_cross_attention(const StorageView& queries,
53+
const StorageView& values,
54+
StorageView& fused_proj,
55+
StorageView& queries_proj,
56+
StorageView& keys_proj,
57+
StorageView& values_proj,
58+
StorageView* cached_keys,
59+
StorageView* cached_values,
60+
const Padder* queries_padder,
61+
const Padder* values_padder,
62+
dim_t& beam_size) const;
63+
5064
private:
5165
static void split_heads(StorageView& x,
5266
dim_t num_heads,
@@ -57,6 +71,10 @@ namespace ctranslate2 {
5771
dim_t num_heads,
5872
const Padder* padder = nullptr,
5973
dim_t beam_size = 1);
74+
75+
void apply_qk_norm(StorageView& queries_proj,
76+
StorageView& keys_proj) const;
77+
6078
const StorageView* _relative_attention_bias;
6179
const StorageView* _relative_position_keys;
6280
const StorageView* _relative_asymmetric_position_keys;

include/ctranslate2/layers/transformer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ namespace ctranslate2 {
6868

6969
private:
7070
std::unique_ptr<AttentionLayer> _self_attention;
71+
const std::unique_ptr<const LayerNorm> _input_layer_norm;
72+
const std::unique_ptr<const LayerNorm> _post_attention_layer_norm;
73+
const std::unique_ptr<const LayerNorm> _pre_feedforward_layer_norm;
74+
const std::unique_ptr<const LayerNorm> _post_feedforward_layer_norm;
7175
const FeedForwardNetwork _ff;
7276
};
7377

@@ -123,6 +127,8 @@ namespace ctranslate2 {
123127
const std::unique_ptr<const LayerNorm> _post_feedforward_layer_norm;
124128
const std::unique_ptr<const AttentionLayer> _encoder_attention;
125129
const FeedForwardNetwork _ff;
130+
const std::unique_ptr<const LayerNorm> _external_pre_encoder_attention_layer_norm;
131+
const std::unique_ptr<const LayerNorm> _external_post_encoder_attention_layer_norm;
126132
};
127133

128134
class TransformerEncoder : public Encoder

include/ctranslate2/layers/wav2vec2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace ctranslate2 {
2727
dim_t _stride;
2828
dim_t _padding;
2929
const Conv1D _conv;
30-
const LayerNorm _output_norm;
3130
const ops::Transpose _transpose;
31+
const LayerNorm _output_norm;
3232
const ops::GELU _gelu;
3333
};
3434

include/ctranslate2/models/model.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ namespace ctranslate2 {
171171
virtual void initialize(ModelReader&) {}
172172

173173
virtual std::unique_ptr<Model> clone() const = 0;
174+
175+
void set_compute_type(ComputeType type, Device device, int device_index, bool update_weight=true);
176+
174177

175178
private:
176179
void process_linear_weights();
177-
void set_compute_type(ComputeType type, Device device, int device_index, bool update_weight=true);
178180
void ensure_dtype(const std::string& name,
179181
StorageView& variable,
180182
const DataType target_dtype);

0 commit comments

Comments
 (0)