bigscience-workshop / bigscience-workshop/Megatron-DeepSpeed

Calling IndexedDatasetBuilder directly with a best_fit datatype fails

Aperta
#67 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
1.4k
Fork
226
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I don't know whether this is intended to work or not, but I found the following program:
```
from megatron.data.indexed_dataset import IndexedDatasetBuilder, best_fitting_dtype

best_dtype = best_fitting_dtype(10_000)
IndexedDatasetBuilder("testfile", dtype=best_dtype)
```
leads to an error like:
```
File "/path/to/Megatron-DeepSpeed.git/megatron/data/indexed_dataset.py", line 284, in __init__
self.element_size = self.element_sizes[self.dtype]
KeyError:
```
This shows up because ``best_fitting_dtype`` will return ``numpy.uint16`` for small vocabs:

https://github.com/bigscience-workshop/Megatron-DeepSpeed/blob/c680954e0b13232abd5b72711f2032bea1ad65c9/megatron/data/indexed_dataset.py#L25-L27

but that particular type is missing from the ``element_sizes`` table.

https://github.com/bigscience-workshop/Megatron-DeepSpeed/blob/c680954e0b13232abd5b72711f2032bea1ad65c9/megatron/data/indexed_dataset.py#L268-L276

which is used in the ``IndexedDatasetBuilder`` constructor here:

https://github.com/bigscience-workshop/Megatron-DeepSpeed/blob/c680954e0b13232abd5b72711f2032bea1ad65c9/megatron/data/indexed_dataset.py#L284

Should something like this work?

If so, it seems like either the ``best_fitting_dtype`` function should return a different type or ``uint16`` should be added to the ``element_sizes`` table like https://github.com/bigscience-workshop/Megatron-DeepSpeed/pull/55/commits/f706108acadb2d97dc77f066930accfbdde4942f.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Riproduci l'esempio e analizza megatron/data/indexed_dataset.py, in particolare best_fitting_dtype, la tabella element_sizes e il costruttore di IndexedDatasetBuilder. Determina se il costruttore debba accettare il dtype restituito per vocabolari piccoli, quindi verifica che la correzione scelta impedisca il KeyError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
numpy, python
Ambito
data
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.