|
Download docs/REPORT.md from Anupam-Rawat-IITB/code-switch-mtp: direct link, hf CLI and curl.
- Browser
- Download file 36.9 kB
-
https://huggingface.co/Anupam-Rawat-IITB/code-switch-mtp/resolve/main/docs/REPORT.md
- Command line
-
hf download hf://Anupam-Rawat-IITB/code-switch-mtp/docs/REPORT.md
-
curl -L -o REPORT.md https://huggingface.co/Anupam-Rawat-IITB/code-switch-mtp/resolve/main/docs/REPORT.md
36.9 kB
| # Multi-Token Prediction and Tokenizer Fertility: Stage 1 Report | |
| This report explains, from scratch, what this project asked, what was built, | |
| what was measured, and what the numbers mean. It assumes no prior knowledge of | |
| the project. Every number reported here comes from a CSV in `results/`; the | |
| file is named next to each table. | |
| --- | |
| ## 1. The basics | |
| ### 1.1 Tokens and tokenizers | |
| A language model does not read text as letters. It reads *tokens*: chunks of | |
| text from a fixed vocabulary the model was built with. A tokenizer is the | |
| component that cuts text into those chunks. | |
| Different tokenizers cut differently. The English word `cat` is usually one | |
| token. The Hindi word `नमस्ते` might be five. Nothing is wrong in either case; | |
| the tokenizer's vocabulary simply covers some text better than other text. | |
| ### 1.2 Fertility | |
| **Fertility** = the average number of tokens it takes to write one word. | |
| - Low fertility (~1.3): most words are a single token. Typical for English | |
| under an English-centric tokenizer. | |
| - High fertility (~5, or ~15): each word is chopped into many pieces. | |
| Typical for scripts the tokenizer's vocabulary does not cover well, and for | |
| byte-level tokenizers, which use one token per raw byte of text. | |
| Fertility is a property of the *pairing* of a text and a tokenizer, not of the | |
| text alone. The same Hindi sentence has different fertility under different | |
| tokenizers. | |
| ### 1.3 Next-token prediction (NTP) | |
| The standard way a language model is trained: given all the text so far, | |
| predict the next token. One prediction per step. | |
| ### 1.4 Multi-token prediction (MTP) | |
| Instead of predicting only the next token, the model has several output | |
| "heads". Head 1 predicts the next token (t+1), head 2 predicts the one after | |
| (t+2), head 3 predicts t+3, and so on. | |
| Why do this: if the extra heads are usually right, you can accept several | |
| tokens per forward pass instead of one, which makes generation faster. This is | |
| the basis of *speculative decoding*. | |
| The catch: each head makes its own separate guess. The model learns several | |
| independent predictions, not one joint prediction of the whole span. Real text | |
| is not independent — what token t+2 is depends heavily on what token t+1 turned | |
| out to be. Independent heads cannot represent that dependence. | |
| ### 1.5 The puzzle this project is about | |
| Published work found: | |
| - Gloeckle et al. (ICML 2024): MTP helps most when predicting raw **bytes**. | |
| They guessed subword tokens already carry more meaning per token, making | |
| independent prediction of several of them harder. They did not test that | |
| guess. | |
| - Aynetdinov & Akbik (ACL 2025): at 1.3B and 3B parameters, subword MTP is | |
| **worse** than plain next-token prediction (1.19 vs 1.08 bits-per-byte). | |
| Byte-level MTP is better. | |
| - All of this work is English-only. | |
| So MTP helps at byte level and hurts at subword level. Two possible reasons: | |
| 1. **Fertility.** Subword tokens are bigger, denser chunks. Guessing several | |
| of them independently is a worse approximation than guessing several bytes. | |
| 2. **Morphological complexity.** Maybe it is not chunk size but grammar | |
| density — how much grammatical information (tense, case, agreement) is | |
| packed into each token. | |
| **The question this project asks: which one is it?** | |
| ### 1.6 Why this is hard to answer, and the trick used | |
| You cannot answer it by comparing two languages. Switching from English to | |
| Hindi changes fertility *and* morphology at the same time. When both move | |
| together you cannot tell which caused the effect. That is a confound. | |
| The trick: **romanization**. Write the same Hindi sentence in Roman letters | |
| instead of Devanagari script. Same words, same grammar, same meaning — only | |
| the spelling system changed. But a Llama-style tokenizer, whose vocabulary is | |
| mostly Latin text, cuts Roman-script Hindi into fewer pieces than Devanagari. | |
| So fertility changes while morphology stays fixed. That is the one thing | |
| comparing two different languages can never give you. | |
| ### 1.7 The conditions ("the fertility ladder") | |
| Same Hindi content, different tokenization setups: | |
| | Label | Text | Tokenizer | | |
| |---|---|---| | |
| | L1 | Devanagari | Sarvam-1 | | |
| | L2 | ITRANS Roman (machine romanization) | Llama-3.2 | | |
| | L3 | Natural Roman (human romanization) | Llama-3.2 | | |
| | L4 | Devanagari | Llama-3.2 | | |
| | L5 | Devanagari | byte-level | | |
| | E1 | English (control) | Llama-3.2 | | |
| | E2 | English (control) | byte-level | | |
| L2 vs L3 was intended as the key pair: same fertility, but human romanization | |
| is inconsistent (the same word gets spelled `kiya`, `kiyaa`, `kia`), so it is | |
| more ambiguous. If L3 is worse than L2 at equal fertility, fertility alone | |
| does not explain the difficulty. | |
| ### 1.8 The hypotheses | |
| - **H1 (Dissociation).** Plot `D = BPB(MTP) − BPB(NTP)` against fertility for | |
| all conditions. One curve fitting both languages means fertility is the | |
| mechanism. Hindi sitting off the English curve means morphology contributes | |
| separately. | |
| - **H2 (Script-switch).** In code-mixed text, acceptance should dip *before* a | |
| script switch, because a fixed prediction horizon straddles two regimes it | |
| cannot see coming. | |
| - **H3 (Ambiguity).** L3 shows higher D and lower acceptance than L2 at | |
| matched fertility. | |
| ### 1.9 Two measurements to know | |
| **BPB (bits per byte).** How many bits the model needs, on average, to encode | |
| one *byte* of the original text. Per-byte, not per-token, because different | |
| tokenizers produce different token counts for the same text — comparing | |
| per-token loss across tokenizers is not a fair comparison, but per-byte always | |
| is. | |
| `D = BPB(MTP) − BPB(NTP)` is therefore "how much worse does the model get at | |
| predicting the next token when you also ask it to predict t+2, t+3, t+4?" | |
| Positive D = MTP costs something. | |
| **D_indep.** A cheaper measurement that needs no training. It asks: how far | |
| is the true joint probability of a span of k tokens from the product of the | |
| individual independent probabilities? Formally a KL divergence. Large D_indep | |
| = lots of joint structure that independent heads must throw away. It is a | |
| *proxy*: it predicts where MTP should hurt, without paying to train anything. | |
| --- | |
| ## 2. Hardware and why it constrained everything | |
| Four Pascal-generation NVIDIA GPUs: | |
| | GPU | Model | Memory | | |
| |---|---|---| | |
| | 0, 1, 2 | GTX 1080 Ti | 11 GB each | | |
| | 3 | Quadro P6000 | 24 GB | | |
| Driver 580.178.04. Pascal is old (2016-era), and that ruled several things out: | |
| - **No tensor cores.** Those arrived with Volta. So the fp16 speedups modern | |
| code assumes do not apply. Everything runs in fp32. | |
| - **No bf16.** Needs Ampere. | |
| - **No FlashAttention.** FlashAttention-2 needs Ampere, FlashAttention-1 needs | |
| Turing. Attention goes through | |
| `torch.nn.functional.scaled_dot_product_attention` instead, which picks a | |
| memory-efficient or plain-math backend. | |
| ### 2.1 Measured hardware behaviour | |
| fp32 matrix multiply, 4096×4096, 20 warmup + 100 timed iterations: | |
| | GPU | fp32 throughput | | |
| |---|---| | |
| | 0 (1080 Ti) | 8.40 TFLOP/s | | |
| | 1 (1080 Ti) | 9.86 TFLOP/s | | |
| | 2 (1080 Ti) | 9.78 TFLOP/s | | |
| | 3 (P6000) | 9.53 TFLOP/s | | |
| Running all four at once: 9.61 / 9.35 / 8.76 / 9.23 TFLOP/s — no meaningful | |
| slowdown, so four independent single-GPU jobs work fine. | |
| **A result that contradicted the expectation.** The project brief predicted | |
| fp16 would be about 64× slower than fp32 on this hardware. Measured on GPU 0: | |
| fp16 8.11 TFLOP/s vs fp32 8.40 TFLOP/s — essentially the same, not 64× slower. | |
| The likely reason is that cuBLAS routes fp16 matrix multiplies through an | |
| fp32-accumulate path, avoiding the crippled native fp16 arithmetic that only | |
| shows up in raw instruction-level benchmarks. The practical conclusion did not | |
| change (fp32 stays the default, since fp16 buys nothing here and costs | |
| precision), but the stated reason for it was wrong. | |
| ### 2.2 A trap worth knowing about | |
| `torch.cuda.get_arch_list()` does **not** contain `sm_61` (the Pascal | |
| architecture code) in the torch build used here. It lists | |
| `sm_50, sm_60, sm_70, sm_75, sm_80, sm_86, sm_90`. | |
| Despite that, every GPU reports capability `(6, 1)` and real kernels run | |
| correctly. The mechanism: the wheel ships PTX (portable intermediate code) for | |
| `sm_60`, and the driver recompiles it for the actual `sm_61` device on first | |
| use. Consequence: the first use of any new kernel shape pays a one-time | |
| compile cost, cached afterwards. | |
| **Decision taken:** proceed on cu121 with PTX JIT rather than downgrade torch, | |
| after confirming empirically that real matmuls produce correct results on all | |
| four cards. | |
| ### 2.3 A second trap | |
| By default PyTorch orders GPUs fastest-first, so `torch.cuda:0` was the | |
| **P6000**, not GPU 0 from `nvidia-smi`. Any code pinning GPUs by index would | |
| have silently used the wrong card. | |
| **Decision taken:** set `CUDA_DEVICE_ORDER=PCI_BUS_ID` before importing torch | |
| in every script, so torch's numbering matches `nvidia-smi`'s. | |
| ### 2.4 Baseline throughput | |
| Llama-3.2-1B, fp32, GPU 0: | |
| - Forward pass: 4769.1 MiB peak memory, 28.1–28.5 ms/iteration | |
| - Training step (frozen backbone + one MTP head, batch 4 × seq 512): | |
| **~2500 tokens/sec**, ~818 ms/step | |
| This was faster than the brief's planning assumption of ~3 TFLOP/s per card. | |
| --- | |
| ## 3. Phase 1 — building the data | |
| ### 3.1 Sources | |
| - **Hindi corpus:** `ai4bharat/sangraha`, verified Hindi split. Streamed and | |
| subsampled rather than downloaded whole. | |
| - **Parallel romanization:** the Dakshina dataset — 10,000 Hindi sentences | |
| that have both a Devanagari original and a human-written Roman version, plus | |
| a lexicon of words with their attested romanizations. | |
| - **English control:** `wikimedia/wikipedia`, English. | |
| **Problem found:** Dakshina is not on the Hugging Face Hub despite having a | |
| Hub-style name (`google-research-datasets/dakshina`). It is only distributed | |
| as a ~2 GB tar from a Google Cloud Storage bucket linked in its GitHub README. | |
| **Decision taken:** download the tar directly, extract only the Hindi | |
| subdirectory (276 MB), delete the rest. | |
| ### 3.2 Corpus built | |
| Streamed sangraha verified Hindi: | |
| | | | | |
| |---|---| | |
| | Documents seen | 119,542 | | |
| | Documents kept | 117,517 | | |
| | Duplicates dropped | 2,019 | | |
| | Too short, dropped | 6 | | |
| | Tokens | 50,000,203 | | |
| Took ~35 seconds. (An earlier small-sample extrapolation had predicted ~60 | |
| minutes; that estimate was dominated by connection startup, not real | |
| throughput. Small-sample extrapolations were treated with more caution | |
| afterwards.) | |
| ### 3.3 The romanization problem — the first real blocker | |
| The whole L2 condition rests on the claim that ITRANS romanization is | |
| *reversible*: romanize a sentence, un-romanize it, and get the exact original | |
| back. If it is not reversible, information was lost, and L2 is no longer "same | |
| content, different fertility" — the confound the design exists to remove comes | |
| back in through the side door. | |
| The brief set the bar at **99%** exact round-trip on 1000 random sentences. | |
| **Result with `indic-nlp-library` (the tool the brief specified): 65.9%.** | |
| Far below the bar. The pipeline stopped there, as instructed. | |
| Diagnosis of the failures: | |
| | Check | Rate | | |
| |---|---| | |
| | Exact match | 0.659 | | |
| | After ignoring nukta marks, digit script (18 vs १८), and end punctuation (. vs ।) | 0.778 | | |
| So even ignoring everything cosmetic, ~22% failed for structural reasons: | |
| - **Nukta loss.** `बाज़ार` → `baajaaara` → `बाजाअर`. The nukta (a dot marking | |
| sounds borrowed from Persian/Arabic) disappears. Common in real Hindi. | |
| - **Vowel ambiguity.** `गई` comes back as `गैइ`. The library's own source | |
| comments acknowledge this ambiguity class and do not resolve it. | |
| - **String collisions.** `ld` is registered both as an alternate spelling of | |
| the letter `ळ` and as the literal transliteration of `ल्द्`. So `हल्द्वानी` | |
| comes back as `हळ्वानी` — the un-romanizer cannot tell which was meant. | |
| An earlier, separate discovery: `indic-nlp-library`'s pip package ships | |
| **without its own data files**. Calling the transliterator without first | |
| downloading a companion repository and running a specific init sequence does | |
| not raise an error — it silently returns corrupted output (`नमस्ते` → `नमे`). | |
| That is a silent-failure mode, not a loud one. | |
| ### 3.4 The fix | |
| Rather than accept a lossy L2, the fix had three parts: | |
| 1. **Switched to `aksharamukha`** instead of `indic-nlp-library`. This alone | |
| took the rate from 65.9% to 77.6%. | |
| 2. **Principled normalization before comparison.** Some differences are | |
| genuinely the same content written differently, and treating them as | |
| failures is wrong: | |
| - Unicode NFC normalization (a nukta character can be stored as one | |
| codepoint or as base + combining mark; these are canonically identical) | |
| - Digit script (the corpus uses both `18` and `१८` for the same number) | |
| - Sentence-final punctuation (`.`, `।`, `॥`, and a bare `|` all appear as | |
| sentence enders in this corpus) | |
| - Zero-width joiners (affect rendering, not content) | |
| This took it to 95.2%. | |
| 3. **Latin-span masking.** The remaining failures were dominated by embedded | |
| English words and acronyms (`Amex`, `UAVs`, `Shell`) common in | |
| Wikipedia-derived Hindi, which the transliterator tried to convert | |
| phonetically and mangled. Detecting Latin runs and routing them around the | |
| transliterator fixed this. | |
| **Final: 99.0% (990/1000).** Bar cleared. | |
| Applied to the full pool: 9,908 unique sentences (92 were exact duplicates), | |
| **9,815 pass**, producing 9,907 verified triples. | |
| ### 3.5 A design limitation this exposed | |
| The public `romanize()` / `deromanize()` functions cannot round-trip embedded | |
| Latin text on their own. Going Devanagari→Roman, a Latin run is unmistakably | |
| foreign and can be left alone. Coming back, ITRANS output is *itself* Latin | |
| letters, so there is no way to distinguish "transliterated Hindi" from "an | |
| English word that was left alone". The reversibility checker uses an internal | |
| marker-tagged variant; the public functions keep this documented as a known | |
| limitation rather than hidden. | |
| ### 3.6 Romanization ambiguity (H3's mechanism) | |
| From the Dakshina lexicon, counting distinct attested romanizations per Hindi | |
| word: | |
| | | | | |
| |---|---| | |
| | Distinct word types | 30,000 | | |
| | Mean romanizations per type | 1.7688 | | |
| Histogram: 12,935 types have 1 spelling, 11,967 have 2, 4,376 have 3, 595 have | |
| 4, 92 have 5, and a long thin tail up to 9. | |
| *(`results/phase1_romanization_ambiguity.csv`)* | |
| --- | |
| ## 4. Phase 2 — measuring without training | |
| Three models were used: | |
| | Model | Type | Used for | | |
| |---|---|---| | |
| | Sarvam-1 (~2B) | causal decoder-only | L1 | | |
| | Llama-3.2-1B | causal decoder-only | L2, L3, L4, E1 | | |
| | ByT5-large (1.228B) | encoder-decoder, byte-level | L5, E2 | | |
| ### 4.1 A gap in the original plan | |
| The brief named only Sarvam-1 and Llama-3.2-1B. But L5 and E2 are *byte-level* | |
| conditions, and neither of those is a byte-level model. Four of the six | |
| planned measurements need actual model probabilities, so those two conditions | |
| had nothing to run on. | |
| Forcing Llama into byte mode was considered and rejected: it has never seen | |
| text split into single bytes, so its predictions there would be noise, not a | |
| measurement of byte-level difficulty. | |
| **Decision taken (with sign-off):** source a real byte-level model. EvaByte | |
| (~6–7B, custom kernels) and MambaByte were rejected as too large for fp32 on | |
| these GPUs and carrying kernel-compatibility risk. **ByT5-large** was chosen: | |
| standard Transformer, no custom kernels, 1.228B parameters, multilingual | |
| pretraining including Hindi. | |
| **Problem:** Google ships ByT5 only as a pickle `.bin` checkpoint, which | |
| current `transformers` refuses to load unless torch ≥ 2.6 (a security guard, | |
| CVE-2025-32434). Our torch is pinned at 2.5.1 for Pascal support. | |
| **Decision taken:** do not touch the torch pin. Convert the checkpoint locally | |
| with `torch.load(..., weights_only=True)` — which is the actual mitigation for | |
| that CVE — and re-save as safetensors. This is a standard remediation, not a | |
| bypass. | |
| ### 4.2 A caveat that stays with every byte result | |
| ByT5 is **encoder-decoder**; the other two models are **decoder-only**. That | |
| is a genuine architecture difference, not a detail. Any L5/E2 vs L1–L4 | |
| comparison carries it. | |
| ### 4.3 Fertility (sanity check) | |
| | Condition | Expected by brief | Measured (n=100) | Measured on full 9,907 set | | |
| |---|---|---|---| | |
| | L1 Devanagari + Sarvam | ~1.5 | 1.737 | 1.608 | | |
| | L2 ITRANS + Llama | ~2.5 | 3.139 | 2.938 | | |
| | L3 natural Roman + Llama | ~2.5 | 2.303 | 2.170 | | |
| | L4 Devanagari + Llama | ~5 | 3.107 | 2.925 | | |
| | L5 Devanagari + byte | ~15 | 14.742 | 14.340 | | |
| | E1 English + Llama | ~1.3 | 1.500 | — | | |
| | E2 English + byte | ~5 | 6.256 | — | | |
| **Two mismatches worth flagging.** | |
| 1. **L4 came in at ~2.9, not ~5.** Llama-3.2's tokenizer (128k vocabulary, | |
| heavily multilingual) covers Devanagari far better than the estimate | |
| assumed. This matters: L4 was supposed to be a clearly separated | |
| high-fertility rung, and instead it sits close to L2. | |
| 2. **L2 and L3 are not fertility-matched.** The brief's design assumed they | |
| were, with L3 differing only in ambiguity — that is the whole basis of the | |
| H3 test. Measured, L2 is 2.938 and L3 is 2.170, a 26% gap. Natural | |
| romanization drops vowels and compresses spelling (`kiya`, `km`, `yah`) | |
| relative to the more phonetically complete ITRANS (`kiyaa`, `kama`, | |
| `yaha`), so it is *shorter*, not just more ambiguous. Any L2 vs L3 | |
| difference is therefore entangled with a real fertility gap. | |
| ### 4.4 Word-boundary alignment | |
| Fraction of token boundaries that land on whitespace: | |
| | Condition | Alignment | | |
| |---|---| | |
| | L1 | 0.637 | | |
| | L2 | 0.322 | | |
| | L3 | 0.446 | | |
| | L4 | 0.326 | | |
| | L5 | 0.141 | | |
| | E1 | 0.733 | | |
| | E2 | 0.316 | | |
| Byte conditions are lowest, which is expected: with many tokens per word, the | |
| within-word boundaries vastly outnumber the real word boundaries. | |
| ### 4.5 D_indep — the strongest signal in the project | |
| KL divergence between the true joint over a span and the product of | |
| independent marginals. Higher = more joint structure that independent MTP | |
| heads must discard. | |
| | Condition | D_indep k=2 | D_indep k=3 | | |
| |---|---|---| | |
| | L1 Devanagari + Sarvam | 2.49 | 10.01 | | |
| | L2 ITRANS + Llama | 2.60 | 8.89 | | |
| | L3 natural Roman + Llama | 2.70 | 9.49 | | |
| | L4 Devanagari + Llama | 2.84 | 8.92 | | |
| | **L5 Devanagari + byte** | **0.41** | **2.94** | | |
| | E1 English + Llama | 2.84 | 10.81 | | |
| | **E2 English + byte** | **0.34** | **1.01** | | |
| *(`results/phase2_measurements.csv`, 100 sentences/condition)* | |
| **Byte-level spans are far closer to independent than subword spans, in both | |
| languages.** This is exactly what the published literature would predict: | |
| there is simply less joint structure for independent heads to lose at byte | |
| level, so MTP costs less there. This is the clearest and most consistent | |
| result in the project. | |
| ### 4.6 Scope decision | |
| The entropy and D_indep estimators have no KV-caching — every Monte Carlo | |
| rollout re-runs the whole prefix from scratch. Measured at ~7 seconds per | |
| sentence, the full 9,907-sentence pool would have taken many hours per | |
| condition. | |
| **Decision taken:** run **100 sentences per condition**, logged explicitly as | |
| a proof-of-concept scope reduction, not a publication-grade sample. Fertility | |
| on the 100-sentence subsample reproduced the full-set numbers closely (L1 1.74 | |
| vs 1.61, L5 14.74 vs 14.34), which is some evidence the subsample is not | |
| wildly unrepresentative. | |
| All seven conditions ran concurrently across all four GPUs in ~33.5 minutes. | |
| --- | |
| ## 5. Phase 2b — two things that turned out to be wrong | |
| Two findings from Phase 2 did not survive scrutiny. Both were checked before | |
| committing GPU time to Phase 3, and **both overturned an earlier conclusion.** | |
| ### 5.1 The L1 anomaly was mostly a model artifact | |
| Phase 2 showed L1 with the *lowest* fertility (1.74) but the *highest* D_indep | |
| (10.01). If fertility drove D_indep, that ordering should not happen. It | |
| looked like evidence for morphology mattering independently. | |
| But L1 was also the only condition running on Sarvam-1. Model identity and | |
| script were confounded. | |
| **Test: a 2×2 factorial**, 2000 sentences per cell, all four cells using the | |
| same sentences so the comparison is paired: | |
| | Cell | Fertility | D_indep k=2 | D_indep k=3 | k=3 std. error | | |
| |---|---|---|---|---| | |
| | Sarvam-1 × Devanagari | 1.728 | 2.409 | 9.735 | 0.079 | | |
| | Sarvam-1 × ITRANS Roman | 3.681 | 2.867 | 9.558 | 0.060 | | |
| | Llama-3.2-1B × Devanagari | 3.051 | 2.877 | 8.665 | 0.056 | | |
| | Llama-3.2-1B × ITRANS Roman | 3.065 | 2.614 | 8.925 | 0.062 | | |
| *(`results/phase2b_blockers.csv`)* | |
| Breaking that down at k=3: | |
| - **Model effect (Sarvam − Llama): +0.851** | |
| - **Script effect (Devanagari − Roman): −0.041** | |
| - Interaction: +0.437 | |
| The model effect holds in *both* scripts, as a paired within-sentence | |
| difference: **+1.059 ± 0.098 (10.9σ)** on Devanagari, **+0.632 ± 0.086 | |
| (7.4σ)** on Roman. | |
| **Conclusion: Sarvam-1 simply shows higher D_indep than Llama-3.2-1B whatever | |
| the script.** The L1 anomaly is mostly a model artifact, not a morphology | |
| signal. Any comparison across models on this ladder carries a model effect | |
| about twenty times the size of the script effect. | |
| **A second finding from the same table, arguably more important:** within | |
| either model, **fertility does not move D_indep**. Sarvam's fertility more | |
| than doubles (1.728 → 3.681) while D_indep *falls slightly* (9.735 → 9.558). | |
| Llama's fertility is flat (3.051 vs 3.065) and so is D_indep (8.665 vs 8.925). | |
| Over the subword fertility range reachable here, D_indep tracks *which model* | |
| is being used, not how fertile its tokenizer is. **This does not support H1's | |
| premise.** The one place a large D_indep difference does appear is byte vs | |
| subword. | |
| ### 5.2 A bug that invalidated a reported result | |
| Phase 2 reported that "entropy trough depth" (mean within-word entropy divided | |
| by mean at-boundary entropy) failed to separate L1 from L5 (0.790 vs 0.809), | |
| contrary to the brief's prediction. That was attributed to the ByT5 | |
| architecture mismatch. | |
| **That attribution was wrong and the number was invalid.** | |
| The bug: the code sampled the **first** N token positions of each sentence. | |
| Devanagari characters are 3 bytes in UTF-8, so under byte-level tokenization | |
| the first word boundary sits around byte 11–12 — never inside the first 5 | |
| sampled positions. The byte conditions therefore had zero or near-zero | |
| boundary samples, and the trough depth was computed from a tiny biased subset. | |
| Fixed by sampling positions evenly across the sentence. The old strategy was | |
| kept selectable so the earlier numbers stay reproducible. | |
| Once fixed, the ByT5 driving mode barely matters: | |
| | ByT5 driving mode | first positions (buggy) | spread positions (fixed) | | |
| |---|---|---| | |
| | mirrored (bidirectional encoder) | 0.752 | 1.129 | | |
| | causal decoder-only | 2.141 | 1.212 | | |
| Corrected trough depths, all seven conditions: | |
| | Condition | Phase 2 (buggy) | Corrected | | |
| |---|---|---| | |
| | L1 Devanagari + Sarvam | 0.790 | **0.621** | | |
| | L2 ITRANS + Llama | 0.918 | 0.878 | | |
| | L3 natural Roman + Llama | 0.832 | 0.782 | | |
| | L4 Devanagari + Llama | 0.700 | 0.699 | | |
| | L5 Devanagari + byte | 0.809 | **1.065** | | |
| | E1 English + Llama | 0.688 | 0.647 | | |
| | E2 English + byte | 0.911 | 0.873 | | |
| **With the bug fixed, the brief's original prediction holds.** L1 (0.621) and | |
| L5 (1.065) are the two extremes of the Hindi ladder — a clear separation, not | |
| the near-identical pair originally reported. The earlier "trough depth does | |
| not separate L1 from L5" claim is **retracted**. | |
| Note this bug biased *all seven* conditions, not only the byte ones. The | |
| `entropy_trough_depth` rows in `results/phase2_measurements.csv` are superseded | |
| by the corrected rows in `results/phase2b_blockers.csv`. | |
| --- | |
| ## 6. Phase 3 — training MTP heads | |
| ### 6.1 The scope decision | |
| The original Phase 3 plan was to train heads for all seven conditions and | |
| regress D on fertility. Phase 2b's results made that unsound: | |
| - The model effect (+0.851) dwarfs the script effect (−0.041), so any | |
| multi-model ladder confounds the primary comparison. | |
| - Fertility does not move D_indep within a model anyway. | |
| Also, a frozen backbone's embeddings are tied to its own tokenizer's | |
| vocabulary, so **one frozen backbone cannot serve conditions defined by | |
| different tokenizers.** L1 needs Sarvam, L2/L3/L4/E1 need Llama, L5/E2 need | |
| ByT5. The original plan was not implementable as written. | |
| **Decision taken: single backbone — Llama-3.2-1B, frozen — and three | |
| conditions:** | |
| - **L4** (Devanagari), from the sangraha corpus | |
| - **L2** (ITRANS Roman), same corpus, romanized | |
| - **E1** (English), from Wikipedia | |
| This gives zero model confound. **L2 vs L4 is the valuable pair**: same | |
| language, same content, same model, near-identical fertility (3.05 vs 3.07), | |
| differing only in script. E1 is the genuinely different-fertility point | |
| (~1.50). | |
| ### 6.2 L3 was excluded, and H3 cannot be tested at training scale | |
| Human-written romanization exists only in Dakshina's 9,907 sentences — | |
| **~0.38M tokens**, against a 10M-token training budget. That is an order of | |
| magnitude short. | |
| Machine romanization was explicitly **not** substituted: H3 is specifically | |
| about *human* orthographic variation, so a machine-generated stand-in would | |
| look like a test of H3 while testing nothing. | |
| **H3 is untestable at training scale with available data.** Reported as a | |
| limitation, not worked around. | |
| ### 6.3 The architecture problem — the most important finding | |
| The brief specified: frozen backbone, plus `4 × [ResBlock → shared | |
| unembedding]` heads. | |
| Checked before spending GPU hours: with the backbone frozen and each head | |
| having its own ResBlock, **head 1 shares no trainable parameter with heads | |
| 2–4**. Head 1's parameters appear in exactly one loss term. So training all | |
| four heads jointly produces bit-identical head-1 weights to training head 1 | |
| alone. | |
| Which means **D = BPB(MTP) − BPB(NTP) = 0, by construction.** Not | |
| approximately zero — exactly zero. The central quantity of the entire phase | |
| would have been a guaranteed zero, costing ~10 GPU-hours to produce. | |
| Verified two ways: | |
| 1. Analytically: gradient max-absolute-difference between the two setups is | |
| `0.0`. | |
| 2. By a full ablation run: `BPB(MTP) = 0.491096`, `BPB(NTP) = 0.491096`, | |
| `D = 0.000000` — identical to six decimal places after 900 steps. | |
| **Decision taken:** the brief's own description of MTP is "trains a **shared | |
| trunk** with k parallel heads". With the backbone frozen, the only possible | |
| shared trunk is a trainable adapter. So the architecture became: | |
| ``` | |
| frozen backbone → trainable shared trunk → 4 per-head ResBlocks → shared frozen unembedding | |
| ``` | |
| The NTP control gets its own trunk and head, at matched per-path capacity, so | |
| the comparison is fair. Tests assert there is no shared trainable tensor | |
| between the MTP and NTP paths. The degenerate no-trunk case remains | |
| reproducible via `--no-shared-trunk`. | |
| This is a deviation from the literal brief, and it is reported as such. The | |
| underlying point is a real methodological result: **Medusa-1-style heads on a | |
| fully frozen backbone cannot exhibit an MTP-vs-NTP tradeoff at all.** Any | |
| published result using that exact setup and reporting a nonzero MTP cost must | |
| be getting it from somewhere else. | |
| ### 6.4 Training setup | |
| Measured throughput first, then set the budget: | |
| - **~845–860 tokens/sec** with the full 4-head stack | |
| - 10M tokens per condition, 9,765 steps, ~3.2 hours each | |
| - Peak GPU memory 7,188.8 MiB (fits an 11 GB card) | |
| - All conditions trained concurrently, one per GPU | |
| - Seed 0; L4 repeated with seed 1 | |
| Efficiency decision: the MTP stack and the NTP baseline train in the **same | |
| process, sharing one frozen-backbone forward pass**. The backbone is frozen so | |
| its hidden states are identical for both; computing it once and feeding both | |
| head sets halves the backbone compute. Separate optimizers, no gradient | |
| interaction, asserted by test. | |
| ### 6.5 Training losses (nats) | |
| | Condition | NTP | MTP head 1 | head 2 | head 3 | head 4 | | |
| |---|---|---|---|---|---| | |
| | L4 | 1.837475 | 1.853037 | 3.714695 | 4.652925 | 5.124338 | | |
| | L2 | 3.077316 | 3.116774 | 4.960981 | 5.673229 | 5.933773 | | |
| | E1 | 2.438694 | 2.479032 | 5.504016 | 6.622214 | 7.070031 | | |
| | L4 no-trunk | 1.854981 | **1.854981** | 4.513780 | 5.380935 | 5.771061 | | |
| *(`results/phase3_training.csv`)* | |
| Note the last row: with no shared trunk, NTP and MTP head 1 are **identical**. | |
| With a shared trunk, MTP head 1 is consistently slightly worse than NTP — that | |
| is the interference D is meant to capture. | |
| ### 6.6 Main results | |
| | Condition | BPB(MTP) | BPB(NTP) | D | D relative | Accepted tokens/forward | Boundary completion | | |
| |---|---|---|---|---|---|---| | |
| | L4 Devanagari | 0.486695 | 0.482983 | 0.003712 | 0.77% | 2.655 | 0.299 | | |
| | L2 ITRANS Roman | 1.782721 | 1.760392 | 0.022329 | 1.27% | 2.359 | 0.301 | | |
| | E1 English | 0.709532 | 0.694181 | 0.015351 | 2.21% | 2.222 | 0.716 | | |
| | L4 no-trunk (ablation) | 0.491096 | 0.491096 | **0.000000** | 0.00% | 2.485 | 0.315 | | |
| *(`results/phase3_measurements.csv`)* | |
| **D is positive in every trained condition.** The MTP cost reported in the | |
| literature is reproduced here at 1B scale on a frozen backbone. | |
| ### 6.7 Per-head accuracy | |
| Accuracy drops steeply with each head, and is always higher inside a word than | |
| at a word boundary: | |
| **L4 (Devanagari):** | |
| | Head | Overall | Within word | At boundary | | |
| |---|---|---|---| | |
| | 1 | 0.603 | 0.726 | 0.405 | | |
| | 2 | 0.340 | 0.399 | 0.246 | | |
| | 3 | 0.204 | 0.229 | 0.163 | | |
| | 4 | 0.131 | 0.146 | 0.107 | | |
| | NTP baseline | 0.606 | — | — | | |
| **L2 (ITRANS Roman):** | |
| | Head | Overall | Within word | At boundary | | |
| |---|---|---|---| | |
| | 1 | 0.428 | 0.578 | 0.179 | | |
| | 2 | 0.203 | 0.266 | 0.098 | | |
| | 3 | 0.119 | 0.160 | 0.053 | | |
| | 4 | 0.088 | 0.122 | 0.031 | | |
| | NTP baseline | 0.432 | — | — | | |
| **E1 (English):** | |
| | Head | Overall | Within word | At boundary | | |
| |---|---|---|---| | |
| | 1 | 0.512 | 0.705 | 0.447 | | |
| | 2 | 0.185 | 0.200 | 0.180 | | |
| | 3 | 0.096 | 0.114 | 0.090 | | |
| | 4 | 0.066 | 0.083 | 0.060 | | |
| | NTP baseline | 0.520 | — | — | | |
| Word boundaries are consistently the hard positions, in every condition and at | |
| every horizon. | |
| ### 6.8 Does the cheap proxy predict the expensive result? | |
| This was Phase 3's actual payload: D_indep needs no training, D needs hours of | |
| GPU time. If D_indep predicts D, the field gets a cheap substitute. | |
| | Condition | D_indep k=3 (proxy) | D absolute | D relative | | |
| |---|---|---|---| | |
| | L4 | 8.665 | 0.003712 | 0.77% | | |
| | L2 | 8.925 | 0.022329 | 1.27% | | |
| | E1 | 10.813 | 0.015351 | 2.21% | | |
| Orderings: | |
| - By D_indep: **L4 < L2 < E1** | |
| - By absolute D: **L4 < E1 < L2** — **disagrees** | |
| - By relative D: **L4 < L2 < E1** — **agrees** | |
| **This is inconclusive, and should not be reported as a success.** With three | |
| conditions there is a 1-in-6 chance of matching the ordering by luck. One of | |
| the two ways of measuring D agrees and the other does not. | |
| A measurement subtlety explains part of the disagreement: **absolute BPB is | |
| not comparable across L2 and L4.** They hold identical content, but Devanagari | |
| is 3 UTF-8 bytes per character against 1 for Roman, so BPB differs about | |
| fourfold on encoding density alone. Relative D divides that out, which is why | |
| the relative ordering behaves differently. | |
| ### 6.9 Seed variability bounds how finely D can be read | |
| L4 was trained twice: | |
| | | seed 0 | seed 1 | | |
| |---|---|---| | |
| | BPB(MTP) | 0.486695 | 0.486018 | | |
| | BPB(NTP) | 0.482983 | 0.482978 | | |
| | **D** | **0.003712** | **0.003040** | | |
| | Accepted/forward | 2.655 | 2.693 | | |
| | Boundary completion | 0.299 | 0.306 | | |
| **D moved 19.9% of its own mean between seeds.** Against D values in the | |
| 0.004–0.022 range, that bounds how confidently small differences between | |
| conditions can be interpreted. Boundary completion, by contrast, barely moved | |
| (0.299 → 0.306). | |
| ### 6.10 Boundary completion — the clearest result | |
| Boundary-completion rate is the fraction of accepted speculative spans that | |
| end at a word boundary rather than mid-word. It does not appear in the | |
| existing MTP literature and is this project's novel metric. | |
| | Condition | Fertility | Boundary completion | | |
| |---|---|---| | |
| | L4 Devanagari | 3.05 | 0.299 | | |
| | L2 ITRANS Roman | 3.07 | 0.301 | | |
| | E1 English | 1.50 | 0.716 | | |
| **The two Hindi conditions agree to within 0.002 despite using different | |
| scripts**, while matching on fertility. English, at half the fertility, is | |
| more than twice as high. | |
| On these three points, boundary completion **tracks fertility, not script** — | |
| and it separates the conditions far more sharply than D does, while being far | |
| more stable across seeds. It is the cleanest fertility-linked signal the | |
| project produced. | |
| --- | |
| ## 7. Everything that limits these results | |
| **Sample sizes.** | |
| - Phase 2 used 100 sentences per condition (no KV-caching made more | |
| infeasible). Directional, not publication-grade. | |
| - Phase 2b used 2000 sentences per cell for D_indep and 400 for trough depth. | |
| - Phase 3 used 10M training tokens per condition, below the brief's 30M | |
| target, set from measured throughput. | |
| **Seeds.** Only L4 was run twice. L2 and E1 are single-seed, below the brief's | |
| two-seed minimum. | |
| **Speculative decoding protocol.** Used 256 documents × 64 completion tokens, | |
| not the specified 512 × 128. Without a KV cache this costs 15.2 s/document. | |
| 5,600–7,000 scored spans per condition still keeps precision reasonable. | |
| **H1 is not answered.** D differences between conditions are small (0.004–0.022) | |
| relative to seed noise (19.9% of the mean), and three conditions cannot support | |
| a regression of D on fertility. Phase 2b separately showed fertility does not | |
| move D_indep within a model. | |
| **H2 was never tested.** The code-mixed analysis (script-switch discontinuity) | |
| required a code-mixed corpus. LinCE's official loader is script-based and the | |
| installed `datasets` version no longer supports script datasets. This was | |
| deferred and never revisited. **Phase 4 was not done.** | |
| **H3 is untestable at training scale.** Human romanization is ~0.38M tokens. | |
| Separately, L2 and L3 are not fertility-matched (2.94 vs 2.17), so even the | |
| zero-training L2 vs L3 comparison is confounded by a real fertility gap. | |
| **The architecture deviation.** Phase 3's primary results use a trainable | |
| shared trunk, not the brief's literal frozen-backbone-plus-independent-heads | |
| spec. Justified by the brief's own definition of MTP and by the demonstration | |
| that the literal spec yields D = 0 by construction — but it is a deviation, and | |
| D means "cost through a shared trunk", not "cost through the specified | |
| architecture". | |
| **Byte conditions carry an architecture confound.** ByT5 is encoder-decoder; | |
| Sarvam-1 and Llama-3.2-1B are decoder-only. Every L5/E2 comparison inherits | |
| this. | |
| **Superseded numbers.** The `entropy_trough_depth` rows in | |
| `results/phase2_measurements.csv` are wrong for all seven conditions and are | |
| superseded by `results/phase2b_blockers.csv`. | |
| --- | |
| ## 8. What was actually learned | |
| **1. The specified Phase 3 architecture cannot measure what it was meant to | |
| measure.** Frozen backbone plus independent per-head ResBlocks gives | |
| D = 0.000000 exactly, verified analytically and empirically. MTP's cost | |
| requires shared trainable capacity to exist at all. This is a methodological | |
| result that applies beyond this project. | |
| **2. Byte-level spans are far closer to independent than subword spans.** | |
| D_indep at k=3: 2.94 (Hindi byte) and 1.01 (English byte) against 8.7–10.8 for | |
| every subword condition. This is consistent across both languages and is the | |
| strongest empirical signal here. It supports the published finding that MTP | |
| helps more at byte granularity — there is less joint structure to lose. | |
| **3. Fertility does not drive D_indep within the subword range.** Doubling | |
| Sarvam's fertility (1.73 → 3.68) left D_indep essentially unchanged (9.74 → | |
| 9.56). Model identity mattered roughly twenty times more than script. H1's | |
| premise is not supported by these measurements. | |
| **4. Boundary completion is a better-behaved metric than D.** It separates | |
| conditions sharply (0.30 vs 0.72), is stable across seeds, and tracks fertility | |
| rather than script. It is the project's novel contribution and, on this | |
| evidence, more promising than D for future work. | |
| **5. Two reported findings were wrong and were retracted.** The L1 D_indep | |
| anomaly was a model artifact, not morphology. The entropy-trough-depth | |
| "failure" was a position-sampling bug; corrected, the original prediction | |
| holds. Both were caught by explicitly testing the earlier conclusions rather | |
| than building on them. | |
| ### If this becomes a paper | |
| The architectural impossibility result (§6.3) and boundary completion (§6.10) | |
| are the two findings that held up. H1 as originally framed is not answered by | |
| this data, and the honest version of the story leads with what was measured | |
| rather than with the hypothesis that motivated it. | |