forked from TensorStack-AI/TensorStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchedulerOptions.cs
More file actions
140 lines (104 loc) · 3.89 KB
/
SchedulerOptions.cs
File metadata and controls
140 lines (104 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System.Text.Json.Serialization;
namespace TensorStack.Python.Common
{
public sealed record SchedulerOptions
{
public int NumTrainTimesteps { get; init; } = 1000;
public int StepsOffset { get; init; } = 0;
// IsTimestep
public float BetaStart { get; init; } = 0.00085f;
public float BetaEnd { get; init; } = 0.012f;
public BetaScheduleType BetaSchedule { get; init; } = BetaScheduleType.ScaledLinear;
public PredictionType PredictionType { get; init; } = PredictionType.Epsilon;
public VarianceType? VarianceType { get; init; }
public TimestepSpacingType TimestepSpacing { get; init; } = TimestepSpacingType.Linspace;
// IsClipSample
public bool ClipSample { get; init; } = false;
public float ClipSampleRange { get; init; } = 1.0f;
//IsThreshold
public bool Thresholding { get; init; } = false;
public float DynamicThresholdingRatio { get; init; } = 0.995f;
public float SampleMaxValue { get; init; } = 1.0f;
// IsKarras
public bool UseKarrasSigmas { get; init; } = false;
public float? SigmaMin { get; init; }
public float? SigmaMax { get; init; }
public float Rho { get; init; } = 7.0f;
// IsMultiStep
public int SolverOrder { get; init; } = 2; // Usually 1–3
public SolverType SolverType { get; init; } = SolverType.Midpoint;
public AlgorithmType AlgorithmType { get; init; } = AlgorithmType.DPMSolverPlus;
public bool LowerOrderFinal { get; init; } = true;
// IsStochastic
public float Eta { get; init; } = 0.0f;
public float SNoise { get; init; } = 1.0f;
public float SChurn { get; init; } = 0.0f;
public float STmin { get; init; } = 0.0f;
public float STmax { get; init; } = 0.0f; // 0 = float.PositiveInfinity;
// IsFlowMatch
public float Shift { get; init; } = 1.0f;
public bool UseDynamicShifting { get; init; } = false;
public float BaseShift { get; init; } = 0.5f;
public float MaxShift { get; init; } = 1.15f;
public bool StochasticSampling { get; init; } = false;
public float FlowShift => Shift;
public int BaseImageSeqLen { get; set; } = 256;
public int MaxImageSeqLen { get; set; } = 4096;
}
public enum TimestepSpacingType
{
[JsonStringEnumMemberName("leading")]
Leading = 0,
[JsonStringEnumMemberName("trailing")]
Trailing = 1,
[JsonStringEnumMemberName("linspace")]
Linspace = 2
}
public enum AlgorithmType
{
[JsonStringEnumMemberName("dpmsolver")]
DPMSolver = 0,
[JsonStringEnumMemberName("dpmsolver++")]
DPMSolverPlus = 1
}
public enum SolverType
{
[JsonStringEnumMemberName("midpoint")]
Midpoint = 0,
[JsonStringEnumMemberName("heun")]
Heun = 1,
[JsonStringEnumMemberName("bh2")]
BH2 = 2
}
public enum BetaScheduleType
{
[JsonStringEnumMemberName("linear")]
Linear = 0,
[JsonStringEnumMemberName("scaled_linear")]
ScaledLinear = 1,
[JsonStringEnumMemberName("cosine")]
Cosine = 2
}
public enum PredictionType
{
[JsonStringEnumMemberName("epsilon")]
Epsilon = 0,
[JsonStringEnumMemberName("v_prediction")]
Variable = 1,
[JsonStringEnumMemberName("sample")]
Sample = 2,
[JsonStringEnumMemberName("flow_prediction")]
FlowPrediction = 3
}
public enum VarianceType
{
[JsonStringEnumMemberName("fixed_small")]
FixedSmall = 0,
[JsonStringEnumMemberName("fixed_large")]
FixedLarge = 1,
[JsonStringEnumMemberName("learned")]
Learned = 2,
[JsonStringEnumMemberName("learned_range")]
LearnedRange = 3
}
}