facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
29.75k stars 6.3k forks source link

'TranslationTask' object has no attribute 'args' #5488

Open whiteSteelRain opened 2 months ago

whiteSteelRain commented 2 months ago

Stuck an afternoon almost....

i was using lightseq to accerlate fairseq.it support fairseq0.10.2,and i want to keep my fairseq0.12.2.

so when running lightseq's criterion's init,error bumped:'TranslationTask' object has no attribute 'args'

after seeing the error,i found where it took place:

    config = LSCrossEntropyLayer.get_config(
        max_batch_tokens=task.args.max_tokens,
        padding_idx=self.padding_idx,
        epsilon=label_smoothing,
        fp16=task.args.fp16,
        local_rank=task.args.device_id,
    )
    self.ls_cross_entropy = LSCrossEntropyLayer(config)

so i thought it must because version,the 0.12.2 remove task.args.

so i went to fairseq_criterion.py,find that current version use cfg instead of args and i also see an legacy fairseq class warning that dont use args use cfg instead(sth like that)

so the dumbest idea and also direct est idea,print it dir out and i didnt find the cfg have "max_tokens,","device_id","fp16"....

so i am really seeking help that if anyone know in fairseq0.12.2,where is the'args'?any similar that contains those args above?

i'll be really appreciated.