unsloth/studio
Konstantin Azizov c875dc17e4
Studio: use (gguf) context length before max seq length (#5111)
* fix: use (gguf) context length before max seq length

For GGUF models context length is used instead of `maxSeqLength`

Fixes #4893

* Studio: split rollback max_seq_length from target load/validate

Restore params.maxSeqLength as the value passed to the target model's
validateModel and effectiveMaxSeqLength fallback, and introduce a
separate rollbackMaxSeqLength used only in the rollback loadModel call.
Without the split, switching from a GGUF model with a large native
context to a non-GGUF target polluted the new load via the
effectiveMaxSeqLength else-branch.

Also:
- Detect a previous GGUF via isGguf, activeGgufVariant, or a .gguf
  suffix on the checkpoint, so local/LM Studio paths not present in
  the models catalog still take the GGUF rollback path.
- Use 0 as the GGUF rollback fallback to match the sentinel used at
  the normal GGUF load site (ggufContextLength fallback to 0); 4096
  would reintroduce the original truncation bug when both
  customContextLength and ggufContextLength are null.
- Reuse the captured stateBeforeUnload for modelRequiresTrustRemoteCode
  and drop the now-unused DEFAULT_INFERENCE_PARAMS value import.

* Studio: drop pending customContextLength from GGUF rollback

rollbackMaxSeqLength previously preferred customContextLength over
ggufContextLength, but customContextLength is a pending, not-yet-applied
slider edit: chat-settings-sheet.tsx treats it as the "dirty" marker
(ctxDirty = customContextLength !== null) and use-chat-model-runtime.ts
clears it to null on every successful load. Rollback exists to restore
the previously-loaded model at its confirmed running context, so leaking
a pending slider value can load the rollback target at a context the
user never validated against VRAM, potentially causing the rollback
itself to fail.

---------

Co-authored-by: Lee Jackson <130007945+Imagineer99@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
2026-04-24 11:53:10 +01:00
..
backend Studio: detect reasoning_effort and preserve_thinking in chat templates (#5149) 2026-04-23 06:57:36 -07:00
frontend Studio: use (gguf) context length before max seq length (#5111) 2026-04-24 11:53:10 +01:00
src-tauri Add tauri (#5144) 2026-04-23 04:50:10 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
install_llama_prebuilt.py Add tauri (#5144) 2026-04-23 04:50:10 -07:00
install_python_stack.py Add tauri (#5144) 2026-04-23 04:50:10 -07:00
LICENSE.AGPL-3.0 Add AGPL-3.0 license to studio folder 2026-03-09 19:36:25 +00:00
setup.bat Final cleanup 2026-03-12 18:28:04 +00:00
setup.ps1 Add tauri (#5144) 2026-04-23 04:50:10 -07:00
setup.sh Add tauri (#5144) 2026-04-23 04:50:10 -07:00
Unsloth_Studio_Colab.ipynb Allow install_python_stack to run on Colab (#4633) 2026-03-27 00:29:27 +04:00