Repository navigation
Use fixed Diffusers 0.40 shard loader for image and video runtimes #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package imageruntime | ||
|
|
||
| import ( | ||
| "context" | ||
| "image/png" | ||
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| // Set TAPIOCA_DIFFUSERS_SMOKE_MODEL to a locally downloaded Diffusers model | ||
| // directory to exercise the pinned runtime on real hardware. This is opt-in | ||
| // because it installs PyTorch and generates an image. | ||
| func TestDiffusersHardwareSmoke(t *testing.T) { | ||
| modelPath := os.Getenv("TAPIOCA_DIFFUSERS_SMOKE_MODEL") | ||
| if modelPath == "" { | ||
| t.Skip("set TAPIOCA_DIFFUSERS_SMOKE_MODEL for a hardware smoke test") | ||
| } | ||
| backend := "diffusers" | ||
| if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { | ||
| backend = "diffusers-mps" | ||
| } | ||
| output := filepath.Join(t.TempDir(), "smoke.png") | ||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute) | ||
| defer cancel() | ||
| if err := Run(ctx, filepath.Join(t.TempDir(), "runtime"), Request{ | ||
| ModelPath: modelPath, Prompt: "A red sphere on a white table", | ||
| Output: output, Width: 512, Height: 512, Steps: 2, Seed: 1, | ||
| Backend: backend, | ||
| }); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| file, err := os.Open(output) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer file.Close() | ||
| image, err := png.DecodeConfig(file) | ||
| if err != nil || image.Width != 512 || image.Height != 512 { | ||
| t.Fatalf("invalid generated PNG: dimensions=%dx%d, error=%v", image.Width, image.Height, err) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| diffusers==0.39.0 | ||
| diffusers==0.40.0 | ||
| transformers>=4.51 | ||
| accelerate>=1.6 | ||
| safetensors>=0.5 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,22 @@ package imageruntime | |
| import ( | ||
| "path/filepath" | ||
| "slices" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/carlos/tapioca/internal/adapter" | ||
| ) | ||
|
|
||
| func TestDiffusersUsesFixedShardLoader(t *testing.T) { | ||
| requirements, err := source.ReadFile("requirements.txt") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if !strings.Contains(string(requirements), "diffusers==0.40.0\n") { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: set -eu
printf '%s\n' '--- relevant test sections ---'
sed -n '1,80p' internal/imageruntime/runtime_test.go
sed -n '1,90p' internal/videoruntime/runtime_test.go
printf '%s\n' '--- line-ending configuration ---'
if [ -f .gitattributes ]; then
cat -n .gitattributes
else
printf '%s\n' '.gitattributes not present'
fi
printf '%s\n' '--- requirement producers and related policy ---'
rg -n -S 'requirements|diffusers==0\.40\.0|autocrlf|eol=' internal .gitattributes .gitconfig README.md 2>/dev/null || trueRepository: kyndlo/tapioca Length of output: 11556 🏁 Script executed: set -eu
printf '%s\n' '--- source.ReadFile binding ---'
rg -n -S 'func ReadFile|package source|source\.ReadFile' --glob '*.go' .
printf '%s\n' '--- runtime embed declarations ---'
sed -n '1,45p' internal/imageruntime/runtime.go
sed -n '1,45p' internal/videoruntime/runtime.go
printf '%s\n' '--- requirement file bytes ---'
python3 - <<'PY'
from pathlib import Path
for name in ('internal/imageruntime/requirements.txt',
'internal/videoruntime/requirements-diffusers.txt'):
data = Path(name).read_bytes()
print(name, repr(data[:80]))
PYRepository: kyndlo/tapioca Length of output: 3257 Normalize embedded requirement line endings before the assertions. Both tests read embedded requirement files and search for 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| t.Fatalf("image runtime must pin the fixed Diffusers loader: %s", requirements) | ||
| } | ||
| } | ||
|
|
||
| func TestMFluxArgumentsIncludeEditingAndAdapters(t *testing.T) { | ||
| command, args := mfluxArguments(Request{ | ||
| ModelPath: "/models/flux", Prompt: "edit", Output: "/out.png", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| diffusers>=0.38,<0.40 | ||
| diffusers==0.40.0 | ||
| transformers>=4.51 | ||
| accelerate>=1.6 | ||
| safetensors>=0.5 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Decode the complete PNG.
png.DecodeConfigvalidates only image metadata. A truncated or corrupt image payload after a valid header can pass this smoke test. Usepng.Decodeand then checkBounds()to verify generated pixel data.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents