Skip to content

[staging CI] unslothai/unsloth#13593 - #385

Closed
danielhanchen wants to merge 30 commits into
upstream-mainfrom
pr-13593-ci
Closed

danielhanchen wants to merge 30 commits into
upstream-mainfrom
pr-13593-ci

Conversation

@danielhanchen

Copy link
Copy Markdown
Collaborator

Disposable CI run for unslothai#13593. Do not merge; closed after CI.

danielhanchen and others added 30 commits October 11, 2026 15:57
…p for diffusion, keep max_length on unpatched TRL
…mbedding learning rate, refuse MLX training of text-diffusion models
…les, refuse MLX chat for text-diffusion models, turn layer offloading off before the VRAM budget
…rs, refuse an autoregressive load in diffusion chat, resolve Hub LoRA bases before the MLX refusal, keep the denied-credential sentinel in detection
…be export limits with the caller's credential
…ed diffusion Studio tests without unsloth_zoo
…ar exists, classify a Hub LoRA by its base before the vision loader
# Conflicts:
#	studio/backend/core/training/trainer.py
…eam and SDAR

Their output-head rows for <|im_end|>, <tool_call>, <|fim_pad|> and the other special tokens are near-duplicates,
so at 2e-4 a LoRA run swaps them: replies end in <tool_call> or come back empty. Clean at 5e-5. Only the
untouched Studio default is lowered; any other value is kept.
Forward per-step canvas frames from FastDiffusionModel.generate_text(on_frame=...)
as the existing diffusion_frame SSE event, only for streaming single-reply chats
with X-Unsloth-Events: 1. The relay throttles to one frame per 100 ms, renders
masked positions as a placeholder glyph and never raises into the sampler. An
older core without on_frame is never passed one.
…uences, zero-based steps

The base-vs-LoRA compare path now asks for diffusion frames like the plain path.
Each rendered frame is cut at the request's stop sequences, as the final reply
is, and the sampler's block-end step (step == total) is sent as the zero-based
step the canvas renders as step + 1 of total.
time.monotonic() can be smaller than the relay interval right after boot, so a
zero start time dropped the first canvas frame.
# Conflicts:
#	studio/backend/core/inference/inference.py
#	studio/backend/core/training/trainer.py
# Conflicts:
#	studio/backend/core/inference/inference.py
#	studio/backend/tests/test_diffusion_lm_studio.py
@danielhanchen
danielhanchen deleted the pr-13593-ci branch October 13, 2026 18:51
danielhanchen added a commit that referenced this pull request Oct 18, 2026
…4058)

## Summary

Two install-cell smoke legs fail on main's scheduled `Notebooks CI`
(2026-10-17 06:39, run 39010742438):
- `nb/Nemotron-3-Nano-30B-A3B_A100.ipynb`
- `nb/Qwen3_5_(4B)_Vision.ipynb`

Both fail like this:

```
error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment
FileNotFoundError: [Errno 2] No such file or directory: 'unsloth'
```

Their install cells use `!uv pip install`, and the next line is
`!unsloth install-kernels` (unslothai/notebooks #385). On Colab the uv
lines work because Colab sets `UV_SYSTEM_PYTHON=true`. I checked this on
a live `release-colab-external-images_20261014` runtime, along with its
`COLAB_*` keys. The smoke job installs into the runner's system
interpreter as a stand-in for Colab's, but its install step set neither:
- uv refused to run.
- The notebooks also took their non-Colab branch, since they choose the
branch on any environment key containing `COLAB_`.

Setting only `UV_SYSTEM_PYTHON` is not enough, which I tried first while
working on unslothai#14056. The non-Colab branch then left `transformers==4.57.6`
(installed `--no-deps`) beside `huggingface_hub` 1.29, which it refuses
to import with, and the gpt-oss leg lost `triton`. Colab's own branch
reinstalls with dependencies, so the job has to take that branch to test
what Colab users run.

## Change

- **`notebooks-ci.yml`:** the `Run install cell` step sets
`UV_SYSTEM_PYTHON: 'true'` and a `COLAB_SMOKE_SHAPED: '1'` marker, with
a comment explaining why.
- The marker is scoped to that one step, which stops before `from
unsloth import`.
- Its name matches none of the specific `COLAB_*` keys Unsloth reads
(`COLAB_ENVIRONMENT`, `COLAB_IFRAME_HEIGHT`, ...).
  - `disk_utils`' generic `COLAB_` scan never runs inside that step.
- **`tests/notebooks/test_smoke_install_contract.py`:**
`test_the_install_cell_runs_the_way_colab_does` requires a `COLAB_*` key
and `UV_SYSTEM_PYTHON` on every step that runs the converted install
cell.

## Testing

- **`Notebooks CI` with `include_smoke=true` on this branch (run
39017258647):** all eight smoke legs pass, including Nemotron-3-Nano and
Qwen3_5 Vision, which fail on main. GRPO and gpt-oss also still pass.
- **The Nemotron leg did real work rather than skipping:**
  - It printed no `No virtual environment found`.
  - uv installed and uninstalled packages.
- `unsloth install-kernels` ran and chose its torch fallback for
causal_conv1d and mamba_ssm on CPU torch.
  - `OK: imports pass under CUDA spoof`.
- **Contract test:** `test_smoke_install_contract.py` gives 39 passed.
With the workflow change reverted, the new test fails.

The `static + transitive resolve` job is still red in that run. That is
the Colab oracle snapshot drift that has failed on every scheduled run
since at least 2026-09-27, and it is unrelated to this change.
danielhanchen pushed a commit that referenced this pull request Nov 20, 2026
…llama.cpp prebuild (unslothai#18692)

> **Note:** this targets the next llama.cpp prebuild, not the one
shipped today (`b12572-mix-8eebad4`). It assumes the pin set on
`unslothai/llama.cpp` master, which adds unslothai/llama.cpp#385
(chunked dense bias) and unslothai/llama.cpp#386 (banded flash
attention), plus unslothai/llama.cpp#389 at `3b34f4f`. On today's build
the dense rate from unslothai#18689 is the right one.

## Problem

unslothai#18689 sized the Inkling 2 compute buffer for the dense
relative-position bias (`512 * (8 * n_head + 4 + 2)` bytes per context
token at ub=512). The next llama.cpp prebuild replaces that path in the
common case:

- #386 runs the relative bias through banded flash attention when flash
attention is on, the cache is f16/bf16/f32, the head size is 64 or 128,
there is one stream and the ubatch is above 32 tokens. Studio's default
launch (flash attention, f16 cache, `--kv-unified`, ub=512) takes this
path.
- #385 chunks the dense bias over query rows once it passes 2^29
elements, for the configurations that still take the dense path.

With the dense rate, Studio would overestimate the banded buffer by
about 11x (77531 vs 7236 MiB at 800K) and pick a much shorter context
than fits.

## Fix

In `_compute_buffer_ctx_bytes`, the `inkling2` branch now:

- takes the banded path when it applies: 18 bytes per cell and
micro-batch token, plus a flat f32 `[ub, ub, n_head]` block;
- keeps the dense rate for the rest (quantized cache, flash attention
off, ubatch of 32 or less). With #385's chunking that rate is exact up
to the first split (32K at ub=512 for 24 heads) and an upper bound after
it.

## Verification

CUDA0 compute buffer of llama-server from the shipped mix source plus
#385, #386 and #389 at `3b34f4f`, on an RTX 6000 Ada, Inkling-2-Mini
UD-Q4_K_XL, `--kv-unified`, compared with Studio's estimate:

| n_ctx | ubatch | slots | cache | flash attn | measured (MiB) |
estimate (MiB) |
|---|---|---|---|---|---|---|
| 65536 | 512 | 4 | f16 | on | 781 | 786 |
| 262144 | 512 | 4 | f16 | on | 2509 | 2514 |
| 800000 | 512 | 4 | f16 | on | 7236 | 7241 |
| 65536 | 256 | 4 | f16 | on | 387 | 389 |
| 65536 | 2048 | 4 | f16 | on | 3350 | 3428 |
| 262144 | 2048 | 4 | f16 | on | 10236 | 10340 |
| 65536 | 512 | 1 | f16 | on | 672 | 781 |
| 65536 | 512 | 4 | q8_0 | on | 4574 | 6522 |
| 131072 | 512 | 4 | q8_0 | on | 6175 | 12858 |
| 262144 | 512 | 4 | q8_0 | on | 12191 | 25530 |
| 32768 | 512 | 4 | f16 | off | 4936 | 4922 |
| 65536 | 512 | 4 | f16 | off | 5159 | 9658 |
| 131072 | 512 | 4 | f16 | off | 5543 | 19130 |

On the banded path the estimate is 0.1% to 2.3% above the measurement
with 4 slots, and 16% above with 1. The dense fallback stays at or above
the measurement, except at 32K without flash attention, where it is 14
MiB (0.3%) below. Above that it is 1.4x to 3.5x high. It only applies to
non-default configurations.

Tests: `test_compute_buffer.py` checks the banded table (at or up to 20%
above the measurement), the dense fallback staying above the chunked
buffer, the two rates, which configurations take the dense path, and the
layer-split delta on both paths. `test_compute_buffer.py` and
`test_kv_cache_estimation.py` pass locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant