Add Docker support and fix benchmark/data pipeline bugs
Containerize the application with ROCm GPU support for AMD Radeon R9700: - Add Dockerfile with PyTorch/PyG ROCm 5.6 wheels - Add docker-compose.yml with dashboard, live-trading, and train services - Add .dockerignore and .env.example for configuration Fix benchmark script to use batch_size instead of num_stocks for variable dimensions, and replace fragile partial model surgery with a standalone MLP for memory estimation. Fix data pipeline to skip dates with no next trading date instead of fabricating zero returns. Add slippage to paper broker, optional mark-to-market prices to broker interface, and health check endpoint for container orchestration.
This commit is contained in:
+11
-19
@@ -106,11 +106,11 @@ def benchmark_model():
|
||||
|
||||
for batch_size in batch_sizes:
|
||||
for seq_len in sequence_lengths:
|
||||
# Create data for this configuration
|
||||
bx = torch.randn(num_stocks, seq_len, num_features).to(config.DEVICE)
|
||||
bei = torch.randint(0, num_stocks, (2, num_edges)).to(config.DEVICE)
|
||||
# Create data for this configuration; batch_size drives num nodes
|
||||
bx = torch.randn(batch_size, seq_len, num_features).to(config.DEVICE)
|
||||
bei = torch.randint(0, batch_size, (2, num_edges)).to(config.DEVICE)
|
||||
bea = torch.randn(num_edges, 1).to(config.DEVICE)
|
||||
by = torch.randn(num_stocks, 1).to(config.DEVICE)
|
||||
by = torch.randn(batch_size, 1).to(config.DEVICE)
|
||||
bdata = Data(x=bx, edge_index=bei, edge_attr=bea, y=by)
|
||||
|
||||
# Benchmark inference
|
||||
@@ -136,34 +136,26 @@ def benchmark_model():
|
||||
f"Inf Tput: {1 / inf_time:.2f} samples/s, Train Tput: {1 / train_time:.2f} samples/s"
|
||||
)
|
||||
|
||||
# Memory benchmark
|
||||
# Memory benchmark — estimate how memory scales with hidden width.
|
||||
# Uses a standalone MLP matching IntradayGNN's feature_processor + output layer
|
||||
# to avoid the dimension mismatches that arise from partial model surgery.
|
||||
logger.info("\nMemory benchmark:")
|
||||
|
||||
# Test different model sizes
|
||||
hidden_channels_list = [64, 128, 256, 512]
|
||||
|
||||
for hidden_channels in hidden_channels_list:
|
||||
# Create a model with this configuration
|
||||
model = IntradayGNN(num_features, config.SEQUENCE_LENGTH)
|
||||
model.feature_processor = nn.Sequential(
|
||||
bench_model = nn.Sequential(
|
||||
nn.Linear(num_features, hidden_channels),
|
||||
nn.SiLU(),
|
||||
nn.Linear(hidden_channels, hidden_channels),
|
||||
nn.LayerNorm(hidden_channels),
|
||||
nn.Linear(hidden_channels, 1),
|
||||
)
|
||||
model.linear = nn.Linear(hidden_channels, 1)
|
||||
|
||||
# Optimize model
|
||||
model = amd_optimizer.optimize_model(model)
|
||||
|
||||
# Estimate memory usage
|
||||
estimated_memory = memory_manager.estimate_model_memory(model)
|
||||
estimated_memory = memory_manager.estimate_model_memory(bench_model)
|
||||
logger.info(
|
||||
f"Hidden Channels: {hidden_channels}, Estimated Memory: {estimated_memory / 1024**3:.2f}GB"
|
||||
)
|
||||
|
||||
# Clean up
|
||||
del model
|
||||
del bench_model
|
||||
memory_manager.empty_cache()
|
||||
|
||||
# Final memory stats
|
||||
|
||||
Reference in New Issue
Block a user