# Adding Tamil to a Pretrained Hybrid-Attention Model

Subword initialization, differential step scaling, and compute confounds. A paper by Jayakumar Gopalan, Zhagaram Labs. Preprint, November 2026 (not yet on arXiv).

- Paper (PDF): https://zhagaramlabs.com/papers/qwen-tamil-extension/paper.pdf
- Tokenizer (Hugging Face): https://huggingface.co/zhagaramlabs/qwen3.5-ta-32k
- Code and logs: https://github.com/zhagaramlabs/uraikal (Apache 2.0)

## Abstract

Even mark-aware multilingual tokenizers over-fragment Tamil: Qwen3.5 requires 4.13 tokens per word (0.1687 tokens per UTF-8 byte) on held-out Tamil web text. Extending Qwen3.5's vocabulary with 32,000 Tamil BPE merges cuts Tamil token counts by 2.69× to 1.53 tokens per word (0.0627 tokens per byte) while leaving English and romanized Tamil untouched. We test whether this vocabulary extension pays off in continued pretraining of `Qwen3.5-0.8B-Base`—a hybrid GatedDeltaNet and full-attention model—from 0 to 1B training tokens, evaluating in tokenizer-invariant bits per byte (bpb) across seven slices.

Three findings stand out. First, initialization matters immediately: initializing each added token as the mean of its constituent stock-Qwen subwords starts at step-0 loss 8.20 versus 10.53 for global-mean initialization, which remains worse than the untrained base model (0.7473 vs. 0.6080 bpb) after 26M tokens. Second, at uniform learning rate (1×), the extended model trails the stock control at both 26M (0.5910 vs. 0.4749) and 200M tokens (0.3988 vs. 0.3846); scaling added-row updates by 10× closes the gap at 26M (0.4747), beats stock by 3.5% at 200M (0.3712 vs. 0.3846), and narrows to a 1.3% lead at 1B tokens (0.3391 vs. 0.3435) while retaining the permanent 2.69× inference and context compression.

Third, we document four confounds and systems pitfalls that distort vocabulary-extension comparisons: (i) at equal training tokens, 2.69× compression exposes the extended arm to 1.76× more unique text, explaining why identically tokenized English (−1.5%) and code (−2.3%) improve at least as much as Tamil (−1.3%) at 1B; (ii) resizing embeddings to an unaligned odd size (280,077) drops Hopper Tensor Core efficiency by 43% (24.4 s vs. 17.1 s per step for only +4.3% FLOPs), fixed by 128-multiple padding with logit slicing; (iii) post-step delta scaling amplifies AdamW decoupled weight decay on unseen tail tokens unless embeddings use zero weight decay; and (iv) cosine decay starting at step 0 clips short-warmup trials below peak learning rate. We release the cleaned v2 tokenizer (`qwen3.5-ta-32k`) and all code and logs under Apache 2.0.

## 1. Tokenizer extension and setup

- **Extending Qwen3.5's tokenizer:** Stock `Qwen3.5-0.8B-Base` has 248,077 active tokens padded to 248,320 (3,880 × 64) in its weight matrix, and uses a mark-aware regex pre-tokenizer (`[\p{L}\p{M}]+`). We train 32,000 Tamil BPE merges on top of Qwen3.5's base vocabulary on Sangraha verified Tamil shard `data-0`, yielding `qwen3.5-ta-32k` (280,077 tokens in v1). On held-out FineWeb-2 Tamil (`fresh.web`), tokens per word drop from 4.13 to 1.53 (2.69× compression; 0.1687 to 0.0627 tokens per byte), and mid-letter cuts fall from 63.2% to 7.8%. On D4.web and D4.literature, tokens per word drop from 4.28 to 1.67 and from 4.34 to 1.93. English (0.225 tok/byte) and romanized Tamil (0.375 tok/byte) tokenize identically to stock across all 2,000 test passages each.
- **Post-hoc vocabulary hygiene (v2):** Auditing the 32,000 added v1 tokens revealed 47 defective entries: 41 mixed Latin–Tamil crawl artifacts from literal `\n` escapes (e.g., `nஅ`, `nஇந்த`, `Delhi`), 2 partial-UTF-8 byte tokens, and 4 dependent merges. In addition, 1,810 added tokens begin with a Tamil vowel sign or pulli (`ியில்`, `்கள்`), showing that the remaining 7.8% letter-cut rate arises from both stock-Qwen base merges and learned suffix merges rather than fallback alone. The cleaned v2 release strips all 47 defective entries (31,953 clean Tamil additions, 280,030 total) while preserving 1.67 tokens per word on D4.web and 100% round-trip fidelity across all 10,357 held-out passages.
- **Training corpus and setup:** All continued-pretraining runs use the same 24 GB shuffled text stream: 18 verified Tamil Sangraha shards (`data-0`–`data-18`, skipping `data-5` and holding out `data-52`), Tamil Wikipedia, and Project Madurai (78.8% Tamil), plus English (15.8%), Python code (3.8%), and romanized Tamil (1.7%). Context length 4,096, batch size 128 sequences (524,288 tokens/step), AdamW at peak LR 10⁻⁴ with cosine decay, gradient clipping at 1.0, on single preemptible Nebius H100/H200 GPUs (total study spend ≈$50–$80).
- **Evaluation:** Bits per byte (summed cross-entropy divided by UTF-8 bytes × ln 2) on seven held-out slices: `fresh.web` (2,000 FineWeb-2 Tamil passages deduplicated against the training stream by 8-gram overlap), `D4.web`, `D4.literature`, Thirukkural verse, romanized Tamil, English, and code, plus three Tamil multiple-choice likelihood benchmarks: Belebele (n = 900), XCOPA (n = 600), and Global PIQA (n = 203).

## 2. Initialization and differential step scaling

### Table 1: Continued pretraining of `Qwen3.5-0.8B-Base` from 0 to 1B tokens

One seed per arm. All bit-per-byte scores are lower-is-better; bold marks the best `fresh.web` score at each token budget. Matched H200s ran both 1B arms; 200M stock ran on H100 while extended 10× ran on H200 (a 5-step H100/H200 check matched loss to 4 decimals).

| Tokens (steps) | Tokenizer | Init | New-row step | Step-0 loss | fresh.web | D4.web | lit. | English | FLOPs (10¹⁸) | Step (s) |
|---|---|---|---:|---:|---:|---:|---:|---:|---:|---:|
| 0 (base) | Stock (248k) | — | — | — | 0.6080 | 0.6044 | 0.7350 | 0.9594 | 0 | — |
| 26M (50) | Stock (248k) | — | 1× | 1.86 | 0.4749 | 0.4874 | 0.6415 | 0.9534 | 0.12 | 18.1 |
| 26M (50) | +32k Tamil | mean | 1× | 10.53 | 0.7473 | 0.7847 | 0.9408 | 0.9565 | 0.12 | 24.1 |
| 26M (50) | +32k Tamil | pieces | 1× | 8.20 | 0.5910 | 0.6134 | 0.7787 | 0.9564 | 0.12 | 26.6 |
| 26M (50) | +32k Tamil | pieces | 3× | 8.20 | 0.5322 | 0.5543 | 0.7244 | 0.9553 | 0.12 | 23.7 |
| 26M (50) | +32k Tamil | pieces | 10× | 8.20 | **0.4747** | 0.4953 | 0.6713 | 0.9540 | 0.12 | 23.7 |
| 200M (382) | Stock (248k) | — | 1× | 1.86 | 0.3846 | 0.3940 | 0.5436 | 0.9557 | 0.90 | 18.7 |
| 200M (382) | +32k Tamil | pieces | 1× | 8.20 | 0.3988 | 0.4121 | 0.5703 | 0.9490 | 0.94 | 25.4 |
| 200M (382) | +32k Tamil | pieces | 10× | 8.20 | **0.3712** | 0.3830 | 0.5356 | 0.9472 | 0.94 | 24.5 |
| 1B (1,908) | Stock (248k) | — | 1× | 1.86 | 0.3435 | 0.3485 | 0.4801 | 0.9477 | 4.52 | 17.1 |
| 1B (1,908) | +32k Tamil | pieces | 10× | 8.20 | **0.3391** | 0.3450 | 0.4804 | 0.9335 | 4.71 | 24.4 |

### Table 2: Per-slice bits per byte (↓) and Tamil likelihood task accuracies (↑) at 200M and 1B tokens

Δ₁₀ₓ is the relative change of Extended 10× versus Stock at the same token budget.

| Slice / benchmark | Tok/byte (stock / ext.) | Base (0 tok) | 200M Stock | 200M Ext. 1× | 200M Ext. 10× | 200M Δ₁₀ₓ | 1B Stock | 1B Ext. 10× | 1B Δ₁₀ₓ |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| fresh.web (test) | 0.169 / 0.063 | 0.6080 | 0.3846 | 0.3988 | **0.3712** | −3.5% | 0.3435 | **0.3391** | −1.3% |
| D4.web | 0.173 / 0.068 | 0.6044 | 0.3940 | 0.4121 | **0.3830** | −2.8% | 0.3485 | **0.3450** | −1.0% |
| D4.literature | 0.176 / 0.078 | 0.7350 | 0.5436 | 0.5703 | **0.5356** | −1.5% | **0.4801** | 0.4804 | +0.0% |
| Verse (Kural) | 0.188 / 0.101 | 1.2213 | 0.8828 | 0.9195 | **0.8822** | −0.1% | 0.7857 | **0.7717** | −1.8% |
| Romanized Tamil | 0.375 / 0.375 | 3.7435 | 2.2975 | **2.2721** | 2.2727 | −1.1% | **2.1297** | 2.1322 | +0.1% |
| English | 0.225 / 0.225 | 0.9594 | 0.9557 | 0.9490 | **0.9472** | −0.9% | 0.9477 | **0.9335** | −1.5% |
| Code | 0.290 / 0.272 | 0.8308 | 0.8154 | 0.8159 | **0.8051** | −1.3% | 0.8191 | **0.8001** | −2.3% |
| *Tamil likelihood tasks (accuracy ↑; chance: Belebele 0.250, XCOPA 0.500, Global PIQA ≈0.373)* | | | | | | | | | |
| Belebele (n = 900) | — | 0.352 | 0.306 | 0.330 | 0.321 | +1.6 pp | 0.329 | 0.333 | +0.4 pp |
| XCOPA (n = 600) | — | 0.478 | 0.508 | 0.518 | 0.538 | +3.0 pp | 0.522 | 0.553 | +3.2 pp |
| Global PIQA (n = 203) | — | 0.369 | 0.433 | 0.404 | 0.409 | −2.5 pp | 0.424 | 0.419 | −0.5 pp |

### Key findings

1. **Subword-piece initialization is mandatory.** Initializing each added token as the mean of the stock embeddings of its Qwen3.5 subword decomposition (*pieces*) starts at step-0 loss 8.20 (versus 1.86 for stock and 10.53 for global-mean init). Because `Qwen3.5-0.8B-Base` ties input and output embeddings, initialization immediately shapes the output softmax. After 26M tokens (50 steps), mean init reaches 0.7473 bpb on `fresh.web`—still worse than the untrained base model (0.6080)—while pieces init reaches 0.5910.
2. **Uniform 1× updates leave added rows behind.** Even with pieces init, training all parameters at a uniform learning rate (1×) leaves the extended model behind the stock control at 26M (0.5910 vs. 0.4749) and still behind by +3.7% at 200M tokens (0.3988 vs. 0.3846). Most of the early drop from 0.6080 to 0.3846 comes from adapting the backbone to Tamil prose; at 1× LR, the 32k brand-new rows move too slowly relative to the already-calibrated 248k stock rows.
3. **Differential 10× step scaling flips the comparison.** Scaling added-row parameter updates by 3× and 10× monotonically closes the 50-step gap: 0.5910 (1×) → 0.5322 (3×) → 0.4747 (10×), matching stock's 0.4749 after just 26M tokens. At 200M tokens, Extended 10× beats stock on every Tamil slice as well as English and code (`fresh.web` 0.3712 vs. 0.3846, −3.5%). At 1B tokens, the lead narrows to −1.3% on `fresh.web` (0.3391 vs. 0.3435), −1.0% on D4.web, and −1.8% on Thirukkural verse, while tying on D4.literature (0.4804 vs. 0.4801) and romanized Tamil (2.1322 vs. 2.1297). English (−1.5%) and code (−2.3%) improve without forgetting.

## 3. Four confounds and implementation pitfalls

1. **Equal training tokens ≠ equal text exposure.** Tokenizing the same 24 GB stream yields 4,576M tokens under stock Qwen3.5 versus 2,605M tokens under `qwen3.5-ta-32k`. At a 1B-token budget, the stock arm sees 21.9% of the corpus whereas the extended arm sees 38.4%—1.76× more unique text. Because English and code tokenize identically (or nearly so) across both arms, their 1B improvements (−1.5% English, −2.3% code) measure the extra data exposure rather than better Tamil units. That Tamil's 1B gain (−1.3%) is slightly smaller than English's suggests that at equal bytes (or equal epochs), the extended model has not yet overtaken stock in raw bpb, even though it delivers a permanent 2.69× decoding speedup and context expansion.
2. **Unaligned vocabulary GEMM slowdown (+43% wall-clock).** On matched H200 GPUs at 1B tokens, Extended 10× ran at 24.4 s/step versus 17.1 s/step for stock—a 43% wall-clock slowdown despite adding only 4.3% analytical FLOPs (4.71 vs. 4.52 × 10¹⁸). Stock Qwen3.5 pads its embedding matrix to 248,320 (3,880 × 64), whereas our Phase D script called `resize_token_embeddings(280077)`. Because 280,077 is odd and indivisible by 8/16/64, the `(BT, 1024) × (1024, 280077)` output GEMM fell off vectorized Hopper Tensor Core kernels. Equal wall-clock time would give stock 43% more steps, reversing the 1B bpb lead. The clean fix—shipped in our code and v2 recipe—pads embeddings with `pad_to_multiple_of=128` (280,192) and slices `logits[..., :active_vocab]` before cross-entropy so padding rows receive exact zero probability mass and zero gradient at full Tensor Core speed.
3. **Post-step delta scaling amplifies decoupled weight decay.** Implementing 10× scaling via `e_new ← e_before + 10 (e_after − e_before)` after `AdamW.step()` with global `weight_decay=0.1` applies 10× weight decay (`λ_eff = 1.0`) to all 32,000 new rows on every step—shrinking rare Tamil tail embeddings toward zero even on steps where they do not appear, while also decaying 1D norms and GatedDeltaNet state-space parameters. Separating embeddings, norms, biases, and state-space parameters into a `weight_decay=0.0` parameter group eliminates tail shrinkage completely.
4. **Short-warmup cosine clipping and downstream task noise.** Starting cosine decay at step 0 rather than step `w` (`min((s+1)/w, cos(s/S))`) clipped our 50-step (`w = 25`) ablations at 0.742× peak learning rate (crossing at step 18); fixing decay to start at `s = w` is essential for short hyperparameter sweeps. On downstream Tamil likelihood benchmarks, all 0.8B checkpoints remain near chance on Belebele (0.31–0.35), XCOPA (0.48–0.55), and Global PIQA (0.37–0.43), so bpb remains the primary signal at this scale.

## 4. Limitations and release

This study tests a single model size (0.8B) and one seed per arm at 200M and 1B tokens; a second seed at 200M (≈$10 on spot GPUs) and an equal-byte, 128-aligned rerun at 1B are natural next steps. The untrained stock baseline was scored in fp32 on Apple Silicon while trained runs were scored in bf16 on CUDA, and FineWeb-2 Tamil is a public corpus that Qwen3.5 may have seen during pretraining (affecting both arms equally). All training scripts (incorporating the four fixes above), evaluation harnesses, and raw per-run JSON logs are released in `uraikal` (Apache 2.0, https://github.com/zhagaramlabs/uraikal), and the cleaned v2 extended tokenizer is released as `zhagaramlabs/qwen3.5-ta-32k` (https://huggingface.co/zhagaramlabs/qwen3.5-ta-32k).

## Citation

```bibtex
@misc{gopalan2026qwentamilextension,
  title  = {Adding Tamil to a Pretrained Hybrid-Attention Model: Subword Initialization, Differential Step Scaling, and Compute Confounds},
  author = {Gopalan, Jayakumar},
  year   = {2026},
  note   = {Preprint. Zhagaram Labs},
  url    = {https://zhagaramlabs.com/papers/qwen-tamil-extension/}
}
```
