Skip to content

Commit

Permalink
fix: generation flipping
Browse files Browse the repository at this point in the history
Signed-off-by: thxCode <[email protected]>
  • Loading branch information
thxCode committed Dec 4, 2024
1 parent ef0fbd8 commit 0dce4db
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
with:
go-version: "1.22.9"
cache-dependency-path: |
**/go.sum
cmd/**/go.sum
- name: Make
run: make build
env:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lint:
if [[ "$(LINT_DIRTY)" == "true" ]]; then \
if [[ -n $$(git status --porcelain) ]]; then \
echo "Code tree is dirty."; \
exit 1; \
git diff --exit-code; \
fi; \
fi

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ $ gguf-parser --hf-repo="gpustack/FLUX.1-dev-GGUF" --hf-file="FLUX.1-dev-FP16.gg
+--------+-----------------+-------------+---------------+----------------+-----------+-----------+-----------+-----------+

$ # Parse FLUX.1-dev Model with Autoencoder tiling
$ gguf-parser --hf-repo="gpustack/FLUX.1-dev-GGUF" --hf-file="FLUX.1-dev-FP16.gguf" --vae-tiling
+----------------------------------------------------------------------------------------------+
| METADATA |
+-------+------+-----------+--------------+---------------+-----------+------------+-----------+
Expand Down
24 changes: 14 additions & 10 deletions gen.regression.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"go/format"

"gonum.org/v1/gonum/mat"
"golang.org/x/exp/maps"
"sort"
)

type LinearRegression struct {
Expand Down Expand Up @@ -100,13 +102,13 @@ import "math"
// {{ .Name }} returns the memory usage in bytes for the given width and height,
// which is calculated by linear regression or polynomial regression.
func {{ .Name }}(width, height uint32, flashAttention bool) uint64 {
coefficients := []float64{ {{ range .PolynomialRegression.Coefficients }}{{ . }}, {{ end }} }
coefficients := []float64{ {{ range $i, $c := .PolynomialRegression.Coefficients }}{{ if eq $i 0 }}{{ printf "%.4f" $c }}{{ else }}{{ printf "%.10f" $c }}{{ end }}, {{ end }} }
degree := {{ .PolynomialRegression.Degree }}
x := float64(width * height)
{{ if .LinearRegression -}}
if flashAttention {
coefficients = []float64{ {{ .LinearRegression.Intercept }}, {{ .LinearRegression.Slope }} }
coefficients = []float64{ {{ printf "%.5f" .LinearRegression.Intercept }}, {{ printf "%.10f" .LinearRegression.Slope }} }
degree = 1
}
{{- end }}
Expand Down Expand Up @@ -407,10 +409,11 @@ func {{ .Name }}(width, height uint32, flashAttention bool) uint64 {
Degree: 2,
}

xs, ys := make([]float64, 0, len(t.x2y)), make([]float64, 0, len(t.x2y))
for x, y := range t.x2y {
xs = append(xs, x)
ys = append(ys, y*1024*1024) // MB to B
xs := maps.Keys(t.x2y)
sort.Float64s(xs)
ys := make([]float64, len(xs))
for j, x := range xs {
ys[j] = t.x2y[x] * 1024 * 1024 // MB to B
}
pr.Fit(xs, ys)

Expand Down Expand Up @@ -440,10 +443,11 @@ func {{ .Name }}(width, height uint32, flashAttention bool) uint64 {

lr := LinearRegression{}

xs, ys := make([]float64, 0, len(t.fax2y)), make([]float64, 0, len(t.fax2y))
for x, y := range t.fax2y {
xs = append(xs, x)
ys = append(ys, y*1024*1024) // MB to B
xs := maps.Keys(t.fax2y)
sort.Float64s(xs)
ys := make([]float64, len(xs))
for j, x := range xs {
ys[j] = t.fax2y[x] * 1024 * 1024 // MB to B
}
lr.Fit(xs, ys)

Expand Down
22 changes: 11 additions & 11 deletions zz_generated.diffusion_model_memory_usage.regression.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0dce4db

Please sign in to comment.