docs: add AGENTS.md with T4/LASER encoder notes - #169
Conversation
|
Hi @moduvoice! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Motivation
While reproducing the mining pipeline's
embed_text(LASER sentence encoder) step on a real NVIDIA Tesla T4 (16GB), I ran into a few undocumented gotchas that aren't obvious from the README/configs alone. This PR documents them (no code changes) so the next person hitting them doesn't have to rediscover them from scratch.Changes
Adds a new
AGENTS.mdwith three notes, all verified against the current code/behavior:pip install -e '.[mining]'pulls innumpy==2.2.6, which breaks the numpy/torch interop for torch 2.0.x (_ARRAY_API not found). Needspip install numpy==1.26.4afterward to fix.embed_text=laser3(Transformer) crashes on torch>=2.0:RuntimeError: Mask Type should be defined, caused by fairseq 0.12.2's fused BetterTransformer fastpath being incompatible with torch 2.0's kernel signature.embed_text=laser2(LSTM, the demo default) is unaffected and runs fine.fp16_modelflag is dead code for the LASER text encoder: it's accepted byLaserSentenceEncoder.__init__and exposed inlaser3_encoder.yaml, but never read in the constructor body or forwarded toSentenceEncoder— so setting it has no effect, and the encoder always runs fp32 on GPU. Manually forcing fp16 (.half()) on the T4 gave a measured 3.23x speedup (1.4938s → 0.4622s for the same 3000-sentence batch) with identical output (cosine similarity 1.0 vs the fp32 baseline). Interestingly, the speech-encoder configs already defaultfp16_model: True, suggesting this was meant to work for text too but the wiring is missing.No default behavior, config defaults, or code paths are changed — this is purely documentation of current, verified behavior. The underlying code issues (wiring
fp16_modelthrough, and the laser3/torch2 fastpath incompatibility) are separate code-logic fixes I'm not proposing here; happy to file issues for those if useful.Testing
All three items were reproduced end-to-end on a real Tesla T4 (16GB, driver 550.163.01, CUDA 12.4 runtime, torch 2.0.1+cu118, fairseq 0.12.2, stopes @ current main):
numpy==2.2.6gets installed by.[mining]and breakstorch.Tensor.numpy(); confirmednumpy==1.26.4restores interop.laser3crash verbatim on first run; confirmedlaser2runs correctly out of the box.grepthatfp16_modelis never referenced inLaserSentenceEncoder's body, only in the constructor signature and configs.cuda.synchronize()-gated timing) on the same 3000-sentence input, and compared output embeddings by cosine similarity.nvidia-smishowed sustained 100% utilization and ~1.8GB VRAM during encoding, vs. a ~15x slower CPU-only run for the same batch.