fix: correct auto ntk scaling_factor for 4k ctx case - #101
Conversation
|
Thanks for the contribution! Please run |
|
Alright it's done. I had a lot of trouble running the formatting.sh script on Kubuntu 23 btw. It demanded very specific versions of dependencies, and it threw an error like this: |
|
Ah sorry, I forgot to mention you'll need to run |
|
LGTM, thanks for the contribution |
|
@sandwichdoge sorry to dig this up from the grave, but are you sure this is implemented correctly? I have a user situation where 4x scaling is breaking with this automatic implementation but not with dynamic alpha 2 being manually set. For context, dynamic NTK doesn't work quite the same way as standard NTK alpha scaling. I had just assumed that this was suboptimal when i decided to rescind my concerns. https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/ |
|
I add my findings to get to 16k: On a full context I get non coherent outputs, stories ending abruptly, output asking me how to continue, gibberish, misplaced words and double quotes in dialogues. When I change the config.json to |
|
Perhaps we can only use this scaling for when the user-specified max-model-len is 8192. |
|
@Pyroserenus I see, looks like we're using the dynamically-scaled NTK version and not the standard NTK RoPE. I dug a little deeper and indeed we're using the DynamicNTKScalingRotaryEmbedding method, which already dynamically calculates the alpha value for us. And the target length calculation was made as simple as the original max position multiplied by the scaling factor parameter in the implementation! For standard NTK scaling, if you scale the factor a little too high, your general perplexity will suffer a bit but you won't get total gibberish. For dynamic NTK becomes a problem indeed. I can at least confirm the scaling factor is as simple as target_max_len / max_position_embeddings now. @AlpinDale I think github supports easy PR reverse. Please revert this change. |
|
Opened #149 |
* stuff * move to sampling_metadata * stuff again (i forgot what i did last night * calculate max_prompt_len locally * slot_mapping expects an int. SequenceGroupMetadata has data, not metadata. Naming is hard. * make persistent metadata persist * fix mirostat for logprobs and new persistence * chore: KoboldAI/koboldcpp updates (#48) * chore: update kobold lite * chore: koboldcpp compatibility updates * fix: disable koboldcpp gen_cache on SSE endpoint to avoid memory leak on client abort * Revert "fix: correct auto ntk scaling_factor for 4k ctx case" (#149) * readme: add dev branch notice * add deprecation warning for ooba API * Revert "fix: correct auto ntk scaling_factor for 4k ctx case (#101)" This reverts commit 99293aa. * feat: AMD ROCm support (#95) * feat: add ROCM kernels * WIP integration into aphrodite * fix compatibility layer * fix kernels * add xformers rocm patch * update setup.py and add requirements-rocm.txt * update engine args and ray utilities * modify attention and quantization code * formatting pt1 * manual merge and format fixes * patch script * rocm dockerfile * simplify operations * add custom DevFuncAttribute * use custom function instead of torch.version * it's 74 for amd * no fp32 and fp16 for rocm * clean up args * get rid of torch * partially support mistral for now * fix formatting * finishing touches * revert back to rocm FA2 * why was that cpp * fix: quant TP (#129) * fix AWQ TP * scaled activation for no parallel input * formatting * formatting --------- Co-authored-by: doesntmatter <temp@ta5srf4.com> Co-authored-by: 50h100a <all_awful@proton.me> Co-authored-by: g4rg <139017707+g4rg@users.noreply.github.com>
* chore: tensor parallel refactors part 2 (#116) * tensor parallel refactors part 2 * fix: max_model_len int to str comparison * gptq stuff * remove gptq * prevent linking to the gptq kernels * fix awq for llama * fix linting * fix typo * empty tensor fix * readme: update for dev branch * parse torch.dtype properly (#119) * fix: duplication in engine step (#120) * fix: GH actions for dev branch * feat: phi 1.5 support (#121) * add phi 1.5 support * add phi modeling code * fix import * feat: usage stats for OpenAI endpoint (#122) * feat: add usage stats for openai streaming requests * fix linting * fix yapf * chore: read from quantization_config (#123) * fix: get_tensor instead of pysafeslice * feat: awq for all models (#124) * support AWQ for all model classes * formatting * feat: fused add RMSNorm kernels (#125) * add fused kernels and llama support * mistral support * formatting * fix: scheduler hang with long prompts (#126) * allocate status class * formatting * fix: cpu sync delay fix (#127) * cpu sync delay fix * formatting * fix: CPU OOM for large models (#128) * feat: speedup compilation times by 3x (#130) * refactor kernel builds * correct the imports * formatting * chore: initialize model on GPU (#132) * fix: `SequenceOutputs` -> `SequenceOutput` (#133) * fix: -> * formatting * fix: blocktable definition (#134) * blocktable * formatting * chore: attention rewrite + models (#135) * properly disable log requests * fix: make llama2 the default sep style (#137) * feat: SqueezeLLM support (#140) * add kernels * fix squeezellm * formatting * feat: re-implement GPTQ (#141) * bring back GPTQ * fix awq and add gptq to registry * formatting * fix: rope duplication (#142) * avoid duplication in rope init * formatting * chore: KoboldAI/koboldcpp updates (#48) * chore: update kobold lite * chore: koboldcpp compatibility updates * fix: disable koboldcpp gen_cache on SSE endpoint to avoid memory leak on client abort * Revert "fix: correct auto ntk scaling_factor for 4k ctx case" (#149) * readme: add dev branch notice * add deprecation warning for ooba API * Revert "fix: correct auto ntk scaling_factor for 4k ctx case (#101)" This reverts commit 99293aa. * feat: AMD ROCm support (#95) * feat: add ROCM kernels * WIP integration into aphrodite * fix compatibility layer * fix kernels * add xformers rocm patch * update setup.py and add requirements-rocm.txt * update engine args and ray utilities * modify attention and quantization code * formatting pt1 * manual merge and format fixes * patch script * rocm dockerfile * simplify operations * add custom DevFuncAttribute * use custom function instead of torch.version * it's 74 for amd * no fp32 and fp16 for rocm * clean up args * get rid of torch * partially support mistral for now * fix formatting * finishing touches * revert back to rocm FA2 * why was that cpp * fix: quant TP (#129) * fix AWQ TP * scaled activation for no parallel input * formatting * chore: rewrite InputMetadata (#143) * stuff * move to sampling_metadata * stuff again (i forgot what i did last night * calculate max_prompt_len locally * slot_mapping expects an int. SequenceGroupMetadata has data, not metadata. Naming is hard. * make persistent metadata persist * fix mirostat for logprobs and new persistence * chore: KoboldAI/koboldcpp updates (#48) * chore: update kobold lite * chore: koboldcpp compatibility updates * fix: disable koboldcpp gen_cache on SSE endpoint to avoid memory leak on client abort * Revert "fix: correct auto ntk scaling_factor for 4k ctx case" (#149) * readme: add dev branch notice * add deprecation warning for ooba API * Revert "fix: correct auto ntk scaling_factor for 4k ctx case (#101)" This reverts commit 99293aa. * feat: AMD ROCm support (#95) * feat: add ROCM kernels * WIP integration into aphrodite * fix compatibility layer * fix kernels * add xformers rocm patch * update setup.py and add requirements-rocm.txt * update engine args and ray utilities * modify attention and quantization code * formatting pt1 * manual merge and format fixes * patch script * rocm dockerfile * simplify operations * add custom DevFuncAttribute * use custom function instead of torch.version * it's 74 for amd * no fp32 and fp16 for rocm * clean up args * get rid of torch * partially support mistral for now * fix formatting * finishing touches * revert back to rocm FA2 * why was that cpp * fix: quant TP (#129) * fix AWQ TP * scaled activation for no parallel input * formatting * formatting --------- Co-authored-by: doesntmatter <temp@ta5srf4.com> Co-authored-by: 50h100a <all_awful@proton.me> Co-authored-by: g4rg <139017707+g4rg@users.noreply.github.com> * feat: OpenAI chat completions templates (#138) * alpaca template * add chatml and fix alpaca * chat completions api * fix stuff * rename templates * formatting * feat: re-write GPTQ and refactor exllama kernels (#152) * refactor exllama kernels * modify the linear layers * awq fixes * update gptq * the useless quant * skip bias init in models * add acknowledgements and minor fixes * fix mistral (finally) * formatting * things are fine, pylint * abolish pylint * pylintgit add .! * feat: add prometheus production metrics (#154) * feat: Mixtral 8x7B support (#155) * add mixtral support * add modeling code * clean up code * bump transformers * remove megablocks and stk as deps for now * fix this thing * formatting --------- Co-authored-by: g4rg <139017707+g4rg@users.noreply.github.com> Co-authored-by: doesntmatter <temp@ta5srf4.com> Co-authored-by: 50h100a <all_awful@proton.me>
* chore: tensor parallel refactors part 2 (#116) * tensor parallel refactors part 2 * fix: max_model_len int to str comparison * gptq stuff * remove gptq * prevent linking to the gptq kernels * fix awq for llama * fix linting * fix typo * empty tensor fix * readme: update for dev branch * parse torch.dtype properly (#119) * fix: duplication in engine step (#120) * fix: GH actions for dev branch * feat: phi 1.5 support (#121) * add phi 1.5 support * add phi modeling code * fix import * feat: usage stats for OpenAI endpoint (#122) * feat: add usage stats for openai streaming requests * fix linting * fix yapf * chore: read from quantization_config (#123) * fix: get_tensor instead of pysafeslice * feat: awq for all models (#124) * support AWQ for all model classes * formatting * feat: fused add RMSNorm kernels (#125) * add fused kernels and llama support * mistral support * formatting * fix: scheduler hang with long prompts (#126) * allocate status class * formatting * fix: cpu sync delay fix (#127) * cpu sync delay fix * formatting * fix: CPU OOM for large models (#128) * feat: speedup compilation times by 3x (#130) * refactor kernel builds * correct the imports * formatting * chore: initialize model on GPU (#132) * fix: `SequenceOutputs` -> `SequenceOutput` (#133) * fix: -> * formatting * fix: blocktable definition (#134) * blocktable * formatting * chore: attention rewrite + models (#135) * properly disable log requests * fix: make llama2 the default sep style (#137) * feat: SqueezeLLM support (#140) * add kernels * fix squeezellm * formatting * feat: re-implement GPTQ (#141) * bring back GPTQ * fix awq and add gptq to registry * formatting * fix: rope duplication (#142) * avoid duplication in rope init * formatting * chore: KoboldAI/koboldcpp updates (#48) * chore: update kobold lite * chore: koboldcpp compatibility updates * fix: disable koboldcpp gen_cache on SSE endpoint to avoid memory leak on client abort * Revert "fix: correct auto ntk scaling_factor for 4k ctx case" (#149) * readme: add dev branch notice * add deprecation warning for ooba API * Revert "fix: correct auto ntk scaling_factor for 4k ctx case (#101)" This reverts commit 99293aa. * feat: AMD ROCm support (#95) * feat: add ROCM kernels * WIP integration into aphrodite * fix compatibility layer * fix kernels * add xformers rocm patch * update setup.py and add requirements-rocm.txt * update engine args and ray utilities * modify attention and quantization code * formatting pt1 * manual merge and format fixes * patch script * rocm dockerfile * simplify operations * add custom DevFuncAttribute * use custom function instead of torch.version * it's 74 for amd * no fp32 and fp16 for rocm * clean up args * get rid of torch * partially support mistral for now * fix formatting * finishing touches * revert back to rocm FA2 * why was that cpp * fix: quant TP (#129) * fix AWQ TP * scaled activation for no parallel input * formatting * chore: rewrite InputMetadata (#143) * stuff * move to sampling_metadata * stuff again (i forgot what i did last night * calculate max_prompt_len locally * slot_mapping expects an int. SequenceGroupMetadata has data, not metadata. Naming is hard. * make persistent metadata persist * fix mirostat for logprobs and new persistence * chore: KoboldAI/koboldcpp updates (#48) * chore: update kobold lite * chore: koboldcpp compatibility updates * fix: disable koboldcpp gen_cache on SSE endpoint to avoid memory leak on client abort * Revert "fix: correct auto ntk scaling_factor for 4k ctx case" (#149) * readme: add dev branch notice * add deprecation warning for ooba API * Revert "fix: correct auto ntk scaling_factor for 4k ctx case (#101)" This reverts commit 99293aa. * feat: AMD ROCm support (#95) * feat: add ROCM kernels * WIP integration into aphrodite * fix compatibility layer * fix kernels * add xformers rocm patch * update setup.py and add requirements-rocm.txt * update engine args and ray utilities * modify attention and quantization code * formatting pt1 * manual merge and format fixes * patch script * rocm dockerfile * simplify operations * add custom DevFuncAttribute * use custom function instead of torch.version * it's 74 for amd * no fp32 and fp16 for rocm * clean up args * get rid of torch * partially support mistral for now * fix formatting * finishing touches * revert back to rocm FA2 * why was that cpp * fix: quant TP (#129) * fix AWQ TP * scaled activation for no parallel input * formatting * formatting --------- Co-authored-by: doesntmatter <temp@ta5srf4.com> Co-authored-by: 50h100a <all_awful@proton.me> Co-authored-by: g4rg <139017707+g4rg@users.noreply.github.com> * feat: OpenAI chat completions templates (#138) * alpaca template * add chatml and fix alpaca * chat completions api * fix stuff * rename templates * formatting * feat: re-write GPTQ and refactor exllama kernels (#152) * refactor exllama kernels * modify the linear layers * awq fixes * update gptq * the useless quant * skip bias init in models * add acknowledgements and minor fixes * fix mistral (finally) * formatting * things are fine, pylint * abolish pylint * pylintgit add .! * feat: add prometheus production metrics (#154) * feat: Mixtral 8x7B support (#155) * add mixtral support * add modeling code * clean up code * bump transformers * remove megablocks and stk as deps for now * fix this thing * formatting * update readme * chore: implement torch native layers (#156) * implement torch native layers * formatting * feat: implement Deci-LM (#158) * feat: implement deci-lm * add to init and loader * formatting * fix: fractional gpus (#157) * fix: llama keyerror (#159) * fix: OpenAI chat - reference before assignment (#160) * reference before assignment * formatting * fix: replace head_mapping with num_kv_heads (#161) * fix: prompt logprobs (#162) * fix: sliding window for mistral/mixtral (#163) * chore: force pt for mixtral (#164) * chore: force pt for mixtral * formatting * chore: implement lazy module loader for models (#165) * implement ModelRegistry * update mixtral import errors * update model loader to use ModelRegistry * whoops * formatting * fix: memory profiling (#166) * fix peak memory profiling * formatting * fix formatting again * fix: GPTQ warnings and exllama states (#171) * fix the warnings for gptq * minor fix * typo * chore: fix Python 3.8+ compatibility (#170) * fix python3.9 compat * fix python3.8 compat * chore: include stop strings in output (#168) * include stop str in output * formatting * typo * typo again * add to api * yapf * feat: mixtral HF with expert parallelism (#167) * mixtral HF implementation * update init and config * fix gptq * formatting * simplify weight loading logic * fixes * Revert "fixes" This reverts commit 75b864f. * feat: CUDA graphs (#172) * implement CUDA graph * all-reduce memory usage * torch already supports cuda graphs with envvar * enforce eager mode for GPTQ * pylint * trailing whitespaces * God save me from pylint * yapf * minor fix * typo * maybe a fix? * some fixes, perhaps * bring back cupy * fix slot mapping dtype in kernels * remove cupy again * fix logger * fix comments * pylint * yapf * disable squeezellm for cuda graph * add warning about mem usage * typo in warning * feat: add rope scaling to mixtral (#174) * chore: make openai api key optional (#176) --------- Co-authored-by: g4rg <139017707+g4rg@users.noreply.github.com> Co-authored-by: doesntmatter <temp@ta5srf4.com> Co-authored-by: 50h100a <all_awful@proton.me>
The correct NTK alpha (at least for llama2) isn't actually that linear. For example if you want 8192 context size, the most optimal value is around 2.6, not 2.