Simplify CLI and rename community commands

CLI improvements for better UX:
- Renamed 'tito community submit' to 'tito community share'
- Removed tito/commands/submit.py (moved to module workflow)
- Updated tito/main.py with cleaner command structure
- Removed module workflow commands (start/complete/resume)
- Updated __init__.py exports for CommunityCommand
- Updated _modidx.py with new module exports

Result: Cleaner CLI focused on essential daily workflows and
clear distinction between casual sharing vs formal competition.
This commit is contained in:
Vijay Janapa Reddi
2025-11-07 20:05:13 -05:00
parent 16660d921d
commit c12ae5f3c2
41 changed files with 127 additions and 570 deletions

4
tinytorch/_modidx.py generated
View File

@@ -59,6 +59,8 @@ d = { 'settings': { 'branch': 'main',
'tinytorch/benchmarking/benchmark.py'), 'tinytorch/benchmarking/benchmark.py'),
'tinytorch.benchmarking.benchmark.TinyMLPerf.run_standard_benchmark': ( '19_benchmarking/benchmarking_dev.html#tinymlperf.run_standard_benchmark', 'tinytorch.benchmarking.benchmark.TinyMLPerf.run_standard_benchmark': ( '19_benchmarking/benchmarking_dev.html#tinymlperf.run_standard_benchmark',
'tinytorch/benchmarking/benchmark.py'), 'tinytorch/benchmarking/benchmark.py'),
'tinytorch.benchmarking.benchmark.calculate_normalized_scores': ( '19_benchmarking/benchmarking_dev.html#calculate_normalized_scores',
'tinytorch/benchmarking/benchmark.py'),
'tinytorch.benchmarking.benchmark.test_unit_benchmark': ( '19_benchmarking/benchmarking_dev.html#test_unit_benchmark', 'tinytorch.benchmarking.benchmark.test_unit_benchmark': ( '19_benchmarking/benchmarking_dev.html#test_unit_benchmark',
'tinytorch/benchmarking/benchmark.py'), 'tinytorch/benchmarking/benchmark.py'),
'tinytorch.benchmarking.benchmark.test_unit_benchmark_suite': ( '19_benchmarking/benchmarking_dev.html#test_unit_benchmark_suite', 'tinytorch.benchmarking.benchmark.test_unit_benchmark_suite': ( '19_benchmarking/benchmarking_dev.html#test_unit_benchmark_suite',
@@ -75,6 +77,8 @@ d = { 'settings': { 'branch': 'main',
'tinytorch/competition/submit.py'), 'tinytorch/competition/submit.py'),
'tinytorch.competition.submit.validate_installation': ( '20_competition/competition_dev.html#validate_installation', 'tinytorch.competition.submit.validate_installation': ( '20_competition/competition_dev.html#validate_installation',
'tinytorch/competition/submit.py'), 'tinytorch/competition/submit.py'),
'tinytorch.competition.submit.validate_submission': ( '20_competition/competition_dev.html#validate_submission',
'tinytorch/competition/submit.py'),
'tinytorch.competition.submit.worked_example_optimization': ( '20_competition/competition_dev.html#worked_example_optimization', 'tinytorch.competition.submit.worked_example_optimization': ( '20_competition/competition_dev.html#worked_example_optimization',
'tinytorch/competition/submit.py')}, 'tinytorch/competition/submit.py')},
'tinytorch.core.activations': { 'tinytorch.core.activations.GELU': ( '02_activations/activations_dev.html#gelu', 'tinytorch.core.activations': { 'tinytorch.core.activations.GELU': ( '02_activations/activations_dev.html#gelu',

Binary file not shown.

Binary file not shown.

View File

@@ -20,8 +20,6 @@ from .status import StatusCommand
from .clean import CleanCommand from .clean import CleanCommand
from .nbgrader import NBGraderCommand from .nbgrader import NBGraderCommand
from .book import BookCommand from .book import BookCommand
from .community import CommunityCommand
from .submit import SubmitCommand
# Command groups # Command groups
from .system import SystemCommand from .system import SystemCommand
@@ -43,8 +41,6 @@ __all__ = [
'CleanCommand', 'CleanCommand',
'NBGraderCommand', 'NBGraderCommand',
'BookCommand', 'BookCommand',
'CommunityCommand',
'SubmitCommand',
# Command groups # Command groups
'SystemCommand', 'SystemCommand',
'ModuleCommand', 'ModuleCommand',

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
""" """
TinyTorch Community Command TinyTorch Community Leaderboard Command
Inclusive community where everyone belongs, regardless of performance level. Inclusive community showcase where everyone belongs, regardless of performance level.
Celebrates the journey, highlights improvements, and builds community through shared learning. Celebrates the journey, highlights improvements, and builds community through shared learning.
""" """
@@ -26,22 +26,22 @@ from ..core.exceptions import TinyTorchCLIError
from .checkpoint import CheckpointSystem from .checkpoint import CheckpointSystem
class CommunityCommand(BaseCommand): class LeaderboardCommand(BaseCommand):
"""Community - Everyone welcome, celebrate the journey together!""" """Community leaderboard - Everyone welcome, celebrate the journey!"""
@property @property
def name(self) -> str: def name(self) -> str:
return "community" return "leaderboard"
@property @property
def description(self) -> str: def description(self) -> str:
return "Join the community, share progress, celebrate achievements together" return "Community showcase - Join, share progress, celebrate achievements together"
def add_arguments(self, parser: ArgumentParser) -> None: def add_arguments(self, parser: ArgumentParser) -> None:
"""Add community subcommands.""" """Add leaderboard subcommands."""
subparsers = parser.add_subparsers( subparsers = parser.add_subparsers(
dest='community_command', dest='leaderboard_command',
help='Community operations', help='Leaderboard operations',
metavar='COMMAND' metavar='COMMAND'
) )
@@ -69,32 +69,31 @@ class CommunityCommand(BaseCommand):
help='Update existing registration' help='Update existing registration'
) )
# Share command (renamed from submit to avoid confusion with tito submit) # Submit command
share_parser = subparsers.add_parser( submit_parser = subparsers.add_parser(
'share', 'submit',
help='Share your progress with the community (baseline or improvements welcome!)', help='Submit your results (baseline or improvements welcome!)'
aliases=['submit'] # Keep 'submit' as alias for backward compatibility
) )
share_parser.add_argument( submit_parser.add_argument(
'--task', '--task',
default='cifar10', default='cifar10',
choices=['cifar10', 'mnist', 'tinygpt'], choices=['cifar10', 'mnist', 'tinygpt'],
help='Task to share results for (default: cifar10)' help='Task to submit results for (default: cifar10)'
) )
share_parser.add_argument( submit_parser.add_argument(
'--accuracy', '--accuracy',
type=float, type=float,
help='Accuracy achieved (any level welcome!)' help='Accuracy achieved (any level welcome!)'
) )
share_parser.add_argument( submit_parser.add_argument(
'--model', '--model',
help='Model description (e.g., "CNN-3-layer", "Custom-Architecture")' help='Model description (e.g., "CNN-3-layer", "Custom-Architecture")'
) )
share_parser.add_argument( submit_parser.add_argument(
'--notes', '--notes',
help='Optional notes about your approach, learnings, challenges' help='Optional notes about your approach, learnings, challenges'
) )
share_parser.add_argument( submit_parser.add_argument(
'--checkpoint', '--checkpoint',
help='Which TinyTorch checkpoint you completed (e.g., "05", "10", "15")' help='Which TinyTorch checkpoint you completed (e.g., "05", "10", "15")'
) )
@@ -161,17 +160,17 @@ class CommunityCommand(BaseCommand):
) )
def run(self, args: Namespace) -> int: def run(self, args: Namespace) -> int:
"""Execute community command.""" """Execute leaderboard command."""
command = getattr(args, 'community_command', None) command = getattr(args, 'leaderboard_command', None)
if not command: if not command:
self._show_community_overview() self._show_leaderboard_overview()
return 0 return 0
if command in ['join', 'register']: if command in ['join', 'register']:
return self._register_user(args) return self._register_user(args)
elif command in ['share', 'submit']: # 'submit' kept as alias elif command == 'submit':
return self._share_results(args) return self._submit_results(args)
elif command == 'view': elif command == 'view':
return self._view_leaderboard(args) return self._view_leaderboard(args)
elif command == 'profile': elif command == 'profile':
@@ -185,11 +184,11 @@ class CommunityCommand(BaseCommand):
else: else:
raise TinyTorchCLIError(f"Unknown leaderboard command: {command}") raise TinyTorchCLIError(f"Unknown leaderboard command: {command}")
def _show_community_overview(self) -> None: def _show_leaderboard_overview(self) -> None:
"""Show community overview and welcome message.""" """Show leaderboard overview and welcome message."""
self.console.print(Panel( self.console.print(Panel(
Group( Group(
Align.center("[bold bright_green]🌟 TinyTorch Community 🌟[/bold bright_green]"), Align.center("[bold bright_green]🌟 TinyTorch Community Leaderboard 🌟[/bold bright_green]"),
"", "",
"[bold]Everyone Welcome![/bold] This is your inclusive community showcase where:", "[bold]Everyone Welcome![/bold] This is your inclusive community showcase where:",
"• [green]Every achievement matters[/green] - 10% accuracy gets the same celebration as 90%", "• [green]Every achievement matters[/green] - 10% accuracy gets the same celebration as 90%",
@@ -199,16 +198,16 @@ class CommunityCommand(BaseCommand):
"", "",
"[bold]Available Commands:[/bold]", "[bold]Available Commands:[/bold]",
" [green]join[/green] - Join our welcoming community (free, inclusive)", " [green]join[/green] - Join our welcoming community (free, inclusive)",
" [green]share[/green] - Share your progress (any level welcome!)", " [green]submit[/green] - Share your progress (any level welcome!)",
" [green]view[/green] - See everyone's journey together", " [green]view[/green] - See everyone's journey together",
" [green]profile[/green] - Your personal achievement story", " [green]profile[/green] - Your personal achievement story",
" [green]progress[/green] - Track your module completion journey", " [green]progress[/green] - Track your module completion journey",
" [green]status[/green] - Quick stats and encouragement", " [green]status[/green] - Quick stats and encouragement",
" [green]help[/green] - Learn about the community system", " [green]help[/green] - Learn about the community system",
"", "",
"[dim]💡 Tip: Start with 'tito community join' to join the community![/dim]", "[dim]💡 Tip: Start with 'tito leaderboard join' to join the community![/dim]",
), ),
title="TinyTorch Community", title="Community Leaderboard",
border_style="bright_green", border_style="bright_green",
padding=(1, 2) padding=(1, 2)
)) ))
@@ -559,13 +558,13 @@ class CommunityCommand(BaseCommand):
"[bold bright_blue]🚀 Your Next Steps:[/bold bright_blue]", "[bold bright_blue]🚀 Your Next Steps:[/bold bright_blue]",
f"1. [green]{next_step}[/green]", f"1. [green]{next_step}[/green]",
"2. [blue]Train your first model and share results[/blue]", "2. [blue]Train your first model and share results[/blue]",
"3. [yellow]Connect with peers: tito community view[/yellow]", "3. [yellow]Connect with peers: tito leaderboard view[/yellow]",
"", "",
"[bold bright_blue]🤝 Community Features Unlocked:[/bold bright_blue]", "[bold bright_blue]🤝 Community Features Unlocked:[/bold bright_blue]",
"• [green]Submit results: tito community share[/green]", "• [green]Submit results: tito leaderboard submit[/green]",
"• [blue]View global progress: tito community view[/blue]", "• [blue]View global progress: tito leaderboard view[/blue]",
"• [yellow]Track your journey: tito community profile[/yellow]", "• [yellow]Track your journey: tito leaderboard profile[/yellow]",
"• [magenta]Get encouragement: tito community status[/magenta]", "• [magenta]Get encouragement: tito leaderboard status[/magenta]",
"", "",
"[dim]💝 Remember: Every step forward is celebrated here![/dim]", "[dim]💝 Remember: Every step forward is celebrated here![/dim]",
), ),
@@ -591,14 +590,14 @@ class CommunityCommand(BaseCommand):
padding=(1, 1) padding=(1, 1)
)) ))
def _share_results(self, args: Namespace) -> int: def _submit_results(self, args: Namespace) -> int:
"""Share progress results with the community (encouraging experience).""" """Submit results with encouraging experience."""
# Check registration # Check registration
profile = self._load_user_profile() profile = self._load_user_profile()
if not profile: if not profile:
self.console.print(Panel( self.console.print(Panel(
"[yellow]Please join our community first![/yellow]\n\n" "[yellow]Please join our community first![/yellow]\n\n"
"Run: [bold]tito community join[/bold]", "Run: [bold]tito leaderboard join[/bold]",
title="📝 Community Membership Required", title="📝 Community Membership Required",
border_style="yellow" border_style="yellow"
)) ))
@@ -700,9 +699,9 @@ class CommunityCommand(BaseCommand):
celebration_message["encouragement"], celebration_message["encouragement"],
"", "",
"[bold bright_blue]🔍 Next:[/bold bright_blue]", "[bold bright_blue]🔍 Next:[/bold bright_blue]",
"• View community: [dim]tito community view[/dim]", "• View community: [dim]tito leaderboard view[/dim]",
"• See your profile: [dim]tito community profile[/dim]", "• See your profile: [dim]tito leaderboard profile[/dim]",
"• Try improving: [dim]tito community share[/dim]", "• Try improving: [dim]tito leaderboard submit[/dim]",
), ),
title=celebration_message["panel_title"], title=celebration_message["panel_title"],
border_style=celebration_message["border_style"], border_style=celebration_message["border_style"],
@@ -733,7 +732,7 @@ class CommunityCommand(BaseCommand):
if not profile: if not profile:
self.console.print(Panel( self.console.print(Panel(
"[yellow]Please join our community first to see your profile![/yellow]\n\n" "[yellow]Please join our community first to see your profile![/yellow]\n\n"
"Run: [bold]tito community join[/bold]", "Run: [bold]tito leaderboard join[/bold]",
title="📝 Community Membership Required", title="📝 Community Membership Required",
border_style="yellow" border_style="yellow"
)) ))
@@ -749,7 +748,7 @@ class CommunityCommand(BaseCommand):
if not profile: if not profile:
self.console.print(Panel( self.console.print(Panel(
"[yellow]Please join our community first![/yellow]\n\n" "[yellow]Please join our community first![/yellow]\n\n"
"Run: [bold]tito community join[/bold]", "Run: [bold]tito leaderboard join[/bold]",
title="📝 Community Membership Required", title="📝 Community Membership Required",
border_style="yellow" border_style="yellow"
)) ))
@@ -763,13 +762,13 @@ class CommunityCommand(BaseCommand):
# Encouraging status message # Encouraging status message
if total_submissions == 0: if total_submissions == 0:
status_message = "[bold bright_blue]🚀 Ready for your first submission![/bold bright_blue]" status_message = "[bold bright_blue]🚀 Ready for your first submission![/bold bright_blue]"
next_step = "Train any model and submit with: [green]tito community share[/green]" next_step = "Train any model and submit with: [green]tito leaderboard submit[/green]"
else: else:
status_message = f"[bold bright_green]🌟 {total_submissions} submission{'s' if total_submissions != 1 else ''} made![/bold bright_green]" status_message = f"[bold bright_green]🌟 {total_submissions} submission{'s' if total_submissions != 1 else ''} made![/bold bright_green]"
if best_cifar10 > 0: if best_cifar10 > 0:
next_step = f"Best CIFAR-10: {best_cifar10:.1f}% - Keep improving! 🚀" next_step = f"Best CIFAR-10: {best_cifar10:.1f}% - Keep improving! 🚀"
else: else:
next_step = "Try CIFAR-10 next: [green]tito community share --task cifar10[/green]" next_step = "Try CIFAR-10 next: [green]tito leaderboard submit --task cifar10[/green]"
self.console.print(Panel( self.console.print(Panel(
Group( Group(
@@ -796,7 +795,7 @@ class CommunityCommand(BaseCommand):
if not profile: if not profile:
self.console.print(Panel( self.console.print(Panel(
"[yellow]Please join our community first to see your progress![/yellow]\n\n" "[yellow]Please join our community first to see your progress![/yellow]\n\n"
"Run: [bold]tito community join[/bold]", "Run: [bold]tito leaderboard join[/bold]",
title="📝 Community Membership Required", title="📝 Community Membership Required",
border_style="yellow" border_style="yellow"
)) ))
@@ -865,8 +864,8 @@ class CommunityCommand(BaseCommand):
self.console.print(Panel( self.console.print(Panel(
f"[bold cyan]🎯 Quick Actions[/bold cyan]\n\n" + f"[bold cyan]🎯 Quick Actions[/bold cyan]\n\n" +
(f"[green]Continue Learning:[/green]\n[dim] tito module view {next_module}[/dim]\n\n" if next_module else "") + (f"[green]Continue Learning:[/green]\n[dim] tito module view {next_module}[/dim]\n\n" if next_module else "") +
f"[yellow]Submit Results:[/yellow]\n[dim] tito community share --task mnist --accuracy XX.X[/dim]\n\n" f"[yellow]Submit Results:[/yellow]\n[dim] tito leaderboard submit --task mnist --accuracy XX.X[/dim]\n\n"
f"[blue]View Community:[/blue]\n[dim] tito community view[/dim]\n\n" f"[blue]View Community:[/blue]\n[dim] tito leaderboard view[/dim]\n\n"
f"[magenta]Track Progress:[/magenta]\n[dim] tito checkpoint status[/dim]", f"[magenta]Track Progress:[/magenta]\n[dim] tito checkpoint status[/dim]",
title="🚀 Next Steps", title="🚀 Next Steps",
border_style="bright_blue" border_style="bright_blue"
@@ -903,10 +902,10 @@ class CommunityCommand(BaseCommand):
"• [magenta]Learn together[/magenta] - Community success > individual ranking", "• [magenta]Learn together[/magenta] - Community success > individual ranking",
"", "",
"[bold bright_blue]🎯 Getting started:[/bold bright_blue]", "[bold bright_blue]🎯 Getting started:[/bold bright_blue]",
"1. [dim]tito community join[/dim] - Join our welcoming community", "1. [dim]tito leaderboard join[/dim] - Join our welcoming community",
"2. Train any model using your TinyTorch implementations", "2. Train any model using your TinyTorch implementations",
"3. [dim]tito community share --accuracy 25.3[/dim] - Share your results", "3. [dim]tito leaderboard submit --accuracy 25.3[/dim] - Share your results",
"4. [dim]tito community view[/dim] - See the community progress", "4. [dim]tito leaderboard view[/dim] - See the community progress",
"", "",
"[bold bright_green]💝 Remember: This is about learning, growing, and supporting each other![/bold bright_green]", "[bold bright_green]💝 Remember: This is about learning, growing, and supporting each other![/bold bright_green]",
), ),
@@ -1081,8 +1080,8 @@ class CommunityCommand(BaseCommand):
"• [blue]All achievers[/blue]: Every percentage point represents real learning", "• [blue]All achievers[/blue]: Every percentage point represents real learning",
"• [yellow]Recent submissions[/yellow]: Fresh progress and new insights", "• [yellow]Recent submissions[/yellow]: Fresh progress and new insights",
"", "",
"[dim]💡 See your progress: tito community profile[/dim]", "[dim]💡 See your progress: tito leaderboard profile[/dim]",
"[dim]🚀 Submit improvements: tito community share[/dim]", "[dim]🚀 Submit improvements: tito leaderboard submit[/dim]",
), ),
title="Community Insights", title="Community Insights",
border_style="bright_blue", border_style="bright_blue",
@@ -1141,7 +1140,7 @@ class CommunityCommand(BaseCommand):
self.console.print(Panel( self.console.print(Panel(
"[yellow]No recent submissions![/yellow]\n\n" "[yellow]No recent submissions![/yellow]\n\n"
"Be the first to share recent progress:\n" "Be the first to share recent progress:\n"
"[bold]tito community share[/bold]", "[bold]tito leaderboard submit[/bold]",
title="🔥 Recent Activity", title="🔥 Recent Activity",
border_style="yellow" border_style="yellow"
)) ))
@@ -1372,7 +1371,7 @@ class CommunityCommand(BaseCommand):
# Submission-based suggestions # Submission-based suggestions
if total_submissions == 0: if total_submissions == 0:
suggestions.append("[yellow]Make your first submission:[/yellow] Any accuracy level welcome!") suggestions.append("[yellow]Make your first submission:[/yellow] Any accuracy level welcome!")
suggestions.append("[dim] tito community share --task mnist --accuracy XX.X[/dim]") suggestions.append("[dim] tito leaderboard submit --task mnist --accuracy XX.X[/dim]")
elif best_accuracy >= 75: elif best_accuracy >= 75:
suggestions.append("[blue]Help others in the community:[/blue] Share your insights!") suggestions.append("[blue]Help others in the community:[/blue] Share your insights!")
elif best_accuracy >= 50: elif best_accuracy >= 50:
@@ -1396,7 +1395,7 @@ class CommunityCommand(BaseCommand):
f" • Connect with other ML learners\n" f" • Connect with other ML learners\n"
f" • Celebrate achievements together\n\n" f" • Celebrate achievements together\n\n"
f"[bold cyan]Ready to join?[/bold cyan]\n" f"[bold cyan]Ready to join?[/bold cyan]\n"
f"[dim] tito community join[/dim]", f"[dim] tito leaderboard join[/dim]",
title="🎆 Join the Community", title="🎆 Join the Community",
border_style="bright_green" border_style="bright_green"
)) ))
@@ -1568,8 +1567,8 @@ class CommunityCommand(BaseCommand):
(f"[bold yellow]🎯 Next Adventure:[/bold yellow] {next_module}\n" if next_module else (f"[bold yellow]🎯 Next Adventure:[/bold yellow] {next_module}\n" if next_module else
f"[bold green]🏆 All modules completed! You're an ML Systems Engineer![/bold green]\n") + f"[bold green]🏆 All modules completed! You're an ML Systems Engineer![/bold green]\n") +
f"\n[bold cyan]View your journey:[/bold cyan]\n" f"\n[bold cyan]View your journey:[/bold cyan]\n"
f"[dim] tito community profile --detailed[/dim]\n" f"[dim] tito leaderboard profile --detailed[/dim]\n"
f"[dim] tito community status[/dim]", f"[dim] tito leaderboard status[/dim]",
title=f"🎆 {username}'s Achievement", title=f"🎆 {username}'s Achievement",
border_style="bright_green" border_style="bright_green"
)) ))
@@ -1581,7 +1580,7 @@ class CommunityCommand(BaseCommand):
f"[bold cyan]🔓 Unlocked Submissions:[/bold cyan]\n\n" + f"[bold cyan]🔓 Unlocked Submissions:[/bold cyan]\n\n" +
"\n".join(f" • [green]{task.upper()}[/green]" for task in eligible_submissions) + "\n".join(f" • [green]{task.upper()}[/green]" for task in eligible_submissions) +
f"\n\n[yellow]Ready to submit your results?[/yellow]\n" f"\n\n[yellow]Ready to submit your results?[/yellow]\n"
f"[dim] tito community share --task cifar10 --accuracy XX.X[/dim]", f"[dim] tito leaderboard submit --task cifar10 --accuracy XX.X[/dim]",
title="🏅 New Opportunities", title="🏅 New Opportunities",
border_style="bright_cyan" border_style="bright_cyan"
)) ))

View File

@@ -1,423 +0,0 @@
"""
TinyTorch Competition Submission Command
Validates and prepares TinyMLPerf competition submissions from Module 20.
"""
import json
import platform
from argparse import ArgumentParser, Namespace
from pathlib import Path
from typing import Dict, Any, Optional
from rich.panel import Panel
from rich.table import Table
from rich.prompt import Prompt, Confirm
from rich.console import Group
from rich.align import Align
from .base import BaseCommand
from ..core.exceptions import TinyTorchCLIError
class SubmitCommand(BaseCommand):
"""Validate and submit TinyMLPerf competition entries"""
@property
def name(self) -> str:
return "submit"
@property
def description(self) -> str:
return "Validate and prepare TinyMLPerf competition submission"
def add_arguments(self, parser: ArgumentParser) -> None:
"""Add submit command arguments."""
parser.add_argument(
'submission_file',
type=str,
default='submission.json',
nargs='?',
help='Path to submission.json file (default: submission.json)'
)
parser.add_argument(
'--github-repo',
type=str,
help='GitHub repository URL (overrides submission file)'
)
parser.add_argument(
'--skip-validation',
action='store_true',
help='Skip validation checks (not recommended)'
)
def run(self, args: Namespace) -> int:
"""Execute submit command."""
submission_file = Path(args.submission_file)
# Check if submission file exists
if not submission_file.exists():
self.console.print(Panel(
f"[red]❌ Submission file not found:[/red] {submission_file}\n\n"
f"[yellow]Expected file:[/yellow] submission.json\n"
f"[cyan]How to generate:[/cyan]\n"
f" 1. Open Module 20 (TinyMLPerf Competition)\n"
f" 2. Run the generate_submission() function\n"
f" 3. This will create submission.json\n\n"
f"[dim]Then run: tito submit submission.json[/dim]",
title="❌ File Not Found",
border_style="red"
))
return 1
# Load submission
try:
with open(submission_file, 'r') as f:
submission = json.load(f)
except json.JSONDecodeError as e:
self.console.print(Panel(
f"[red]❌ Invalid JSON file:[/red] {submission_file}\n\n"
f"[yellow]Error:[/yellow] {str(e)}\n\n"
f"[cyan]Please regenerate submission.json from Module 20[/cyan]",
title="❌ Invalid Submission",
border_style="red"
))
return 1
# Welcome
self._show_welcome()
# Validate submission
if not args.skip_validation:
validation_result = self._validate_submission(submission)
if not validation_result["valid"]:
self.console.print(Panel(
"[red]❌ Submission validation failed[/red]\n\n"
"[yellow]Please fix the errors and regenerate submission.json[/yellow]",
title="Validation Failed",
border_style="red"
))
return 1
# Display scorecard
self._display_scorecard(submission)
# Collect additional info
submission = self._collect_additional_info(submission, args)
# Honor code
if not self._confirm_honor_code():
self.console.print(Panel(
"[yellow]Submission cancelled[/yellow]\n\n"
"Honor code agreement is required for competition submission.",
title="Cancelled",
border_style="yellow"
))
return 1
submission["honor_code"] = True
# Save final submission
final_file = self._save_final_submission(submission)
# Show next steps
self._show_next_steps(final_file, submission)
return 0
def _show_welcome(self) -> None:
"""Show welcome message."""
self.console.print(Panel(
Group(
Align.center("[bold bright_green]🏅 TinyMLPerf Competition Submission 🏅[/bold bright_green]"),
"",
"Welcome to the TinyMLPerf competition submission system!",
"",
"This tool will:",
"• [green]✓ Validate your submission[/green]",
"• [blue]✓ Display your normalized scorecard[/blue]",
"• [yellow]✓ Collect GitHub repository for verification[/yellow]",
"• [magenta]✓ Prepare final submission package[/magenta]",
"",
"[dim]Following MLPerf principles: Reproducible, fair, and transparent[/dim]",
),
title="🔥 Competition Submission",
border_style="bright_green",
padding=(1, 2)
))
def _validate_submission(self, submission: Dict[str, Any]) -> Dict[str, Any]:
"""Validate submission with sanity checks."""
self.console.print("\n🔍 [bold cyan]Validating Submission...[/bold cyan]\n")
checks = []
warnings = []
errors = []
# Extract metrics
normalized = submission.get("normalized_scores", {})
speedup = normalized.get("speedup", 1.0)
compression = normalized.get("compression_ratio", 1.0)
accuracy_delta = normalized.get("accuracy_delta", 0.0)
# Check 1: Speedup is reasonable
if speedup > 50:
errors.append(f"❌ Speedup {speedup:.1f}x seems unrealistic (>50x)")
elif speedup > 20:
warnings.append(f"⚠️ Speedup {speedup:.1f}x is very high - please verify measurements")
else:
checks.append(f"✅ Speedup {speedup:.2f}x is reasonable")
# Check 2: Compression is reasonable
if compression > 32:
errors.append(f"❌ Compression {compression:.1f}x seems unrealistic (>32x)")
elif compression > 16:
warnings.append(f"⚠️ Compression {compression:.1f}x is very high - please verify")
else:
checks.append(f"✅ Compression {compression:.2f}x is reasonable")
# Check 3: Accuracy preservation (Closed Division)
division = submission.get("division", "closed")
if division == "closed" and accuracy_delta > 1.0:
errors.append(f"❌ Accuracy improved {accuracy_delta:.1f}pp - did you train the model?")
elif accuracy_delta > 0.5:
warnings.append(f"⚠️ Accuracy improved {accuracy_delta:.1f}pp - verify no training")
else:
checks.append(f"✅ Accuracy Δ {accuracy_delta:+.2f}pp is reasonable")
# Check 4: Required fields
required = ["division", "event", "athlete_name", "baseline", "optimized", "normalized_scores"]
missing = [f for f in required if f not in submission]
if missing:
errors.append(f"❌ Missing fields: {', '.join(missing)}")
else:
checks.append("✅ All required fields present")
# Check 5: Techniques documented
techniques = submission.get("techniques_applied", [])
if not techniques or "TODO" in str(techniques):
warnings.append("⚠️ No optimization techniques listed")
else:
checks.append(f"✅ Techniques: {', '.join(techniques[:3])}{'...' if len(techniques) > 3 else ''}")
# Display results
for check in checks:
self.console.print(f" {check}")
for warning in warnings:
self.console.print(f" {warning}")
for error in errors:
self.console.print(f" {error}")
if errors:
self.console.print("\n[red]❌ Validation failed - please fix errors above[/red]\n")
elif warnings:
self.console.print("\n[yellow]⚠️ Warnings detected - review before submitting[/yellow]\n")
else:
self.console.print("\n[green]✅ All validation checks passed![/green]\n")
return {
"valid": len(errors) == 0,
"checks": checks,
"warnings": warnings,
"errors": errors
}
def _display_scorecard(self, submission: Dict[str, Any]) -> None:
"""Display MLPerf-style scorecard with normalized metrics."""
normalized = submission.get("normalized_scores", {})
division = submission.get("division", "closed").upper()
event = submission.get("event", "all_around").replace("_", " ").title()
athlete = submission.get("athlete_name", "Unknown")
# Create scorecard table
table = Table(
title=f"🏆 TinyMLPerf Scorecard - {athlete}",
title_style="bold bright_green",
show_header=True,
header_style="bold cyan"
)
table.add_column("Metric", style="bold", width=25)
table.add_column("Value", style="green", justify="right", width=20)
table.add_column("Rating", style="yellow", width=15)
# Division & Event
table.add_row("Division", division, self._get_division_badge(division.lower()))
table.add_row("Event", event, self._get_event_badge(submission.get("event", "")))
table.add_section()
# Normalized scores
speedup = normalized.get("speedup", 1.0)
compression = normalized.get("compression_ratio", 1.0)
accuracy_delta = normalized.get("accuracy_delta", 0.0)
efficiency = normalized.get("efficiency_score", 1.0)
table.add_row(
"Speedup",
f"{speedup:.2f}x faster",
self._get_performance_rating(speedup, "speedup")
)
table.add_row(
"Compression",
f"{compression:.2f}x smaller",
self._get_performance_rating(compression, "compression")
)
table.add_row(
"Accuracy Δ",
f"{accuracy_delta:+.2f}pp",
self._get_accuracy_rating(accuracy_delta)
)
table.add_row(
"Efficiency Score",
f"{efficiency:.2f}",
self._get_efficiency_rating(efficiency)
)
self.console.print(table)
def _collect_additional_info(self, submission: Dict[str, Any], args: Namespace) -> Dict[str, Any]:
"""Collect additional information for submission."""
self.console.print("\n📝 [bold cyan]Additional Information[/bold cyan]\n")
# GitHub repo (required for verification)
current_repo = submission.get("github_repo", "")
if args.github_repo:
github_repo = args.github_repo
elif current_repo:
github_repo = Prompt.ask(
"[bold]GitHub repository URL[/bold] (for code verification)",
default=current_repo
)
else:
github_repo = Prompt.ask(
"[bold]GitHub repository URL[/bold] (required for verification)",
default="https://github.com/YourUsername/TinyTorch"
)
submission["github_repo"] = github_repo
# Environment info (for reproducibility)
submission["environment"] = {
"python_version": platform.python_version(),
"system": platform.system(),
"machine": platform.machine(),
"processor": platform.processor() or "Unknown"
}
return submission
def _confirm_honor_code(self) -> bool:
"""Confirm honor code agreement."""
self.console.print("\n📜 [bold cyan]Honor Code Agreement[/bold cyan]\n")
self.console.print(Panel(
"[bold]TinyMLPerf Honor Code[/bold]\n\n"
"I affirm that:\n"
"• This submission represents my own work\n"
"• All techniques and optimizations are documented\n"
"• Results are reproducible from the provided repository\n"
"• I followed the competition rules for my division\n"
"• Measurements were conducted fairly and honestly\n\n"
"[yellow]Closed Division:[/yellow] No model training, architecture changes, or data modifications\n"
"[blue]Open Division:[/blue] Innovations are documented and reproducible",
title="Honor Code",
border_style="bright_blue"
))
return Confirm.ask("\n[bold]Do you agree to the honor code?[/bold]", default=True)
def _save_final_submission(self, submission: Dict[str, Any]) -> Path:
"""Save final submission with all information."""
final_file = Path("submission_final.json")
with open(final_file, 'w') as f:
json.dump(submission, f, indent=2)
self.console.print(f"\n✅ [green]Final submission saved:[/green] {final_file}")
return final_file
def _show_next_steps(self, final_file: Path, submission: Dict[str, Any]) -> None:
"""Show next steps for submission."""
github_repo = submission.get("github_repo", "")
self.console.print(Panel(
Group(
"[bold bright_green]🎉 Submission Ready![/bold bright_green]",
"",
"[bold]Your submission package:[/bold]",
f"• [green]Submission file:[/green] {final_file}",
f"• [blue]GitHub repo:[/blue] {github_repo}",
f"• [yellow]Honor code:[/yellow] Confirmed ✓",
"",
"[bold bright_blue]📤 Next Steps:[/bold bright_blue]",
"",
"[bold]Option 1: Email Submission[/bold]",
" 1. Email [cyan]submission_final.json[/cyan] to your instructor",
" 2. Include your GitHub repo link in the email",
" 3. Subject: [dim]TinyMLPerf Submission - [YourName][/dim]",
"",
"[bold]Option 2: Platform Upload[/bold]",
" 1. Go to competition platform (if available)",
" 2. Upload [cyan]submission_final.json[/cyan]",
" 3. Verify GitHub repo link is correct",
"",
"[bold green]🔍 Verification:[/bold green]",
"• Instructor will clone your GitHub repo",
"• Reproduce your results using your code",
"• Verify optimizations match documentation",
"",
"[dim]💡 Tip: Make sure your README.md explains how to reproduce your results![/dim]",
),
title="✅ Submission Complete",
border_style="bright_green",
padding=(1, 2)
))
# Helper methods for ratings
def _get_division_badge(self, division: str) -> str:
if division == "closed":
return "🔒 Optimization"
elif division == "open":
return "🔓 Innovation"
return "❓ Unknown"
def _get_event_badge(self, event: str) -> str:
badges = {
"latency_sprint": "🏃 Speed",
"memory_challenge": "🏋️ Size",
"accuracy_contest": "🎯 Accuracy",
"all_around": "🏋️‍♂️ Balanced",
"extreme_push": "🚀 Extreme"
}
return badges.get(event, "📊 Custom")
def _get_performance_rating(self, value: float, metric: str) -> str:
if value >= 10:
return "⭐⭐⭐ Elite"
elif value >= 5:
return "⭐⭐ Strong"
elif value >= 2:
return "⭐ Good"
else:
return "📊 Baseline"
def _get_accuracy_rating(self, delta: float) -> str:
if abs(delta) <= 0.5:
return "⭐⭐⭐ Excellent"
elif abs(delta) <= 2.0:
return "⭐⭐ Good"
elif abs(delta) <= 5.0:
return "⭐ Acceptable"
else:
return "⚠️ High Loss"
def _get_efficiency_rating(self, score: float) -> str:
if score >= 20:
return "⭐⭐⭐ Elite"
elif score >= 10:
return "⭐⭐ Strong"
elif score >= 5:
return "⭐ Good"
else:
return "📊 Baseline"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -22,6 +22,7 @@ from .core.console import get_console, print_banner, print_error, print_ascii_lo
from .core.exceptions import TinyTorchCLIError from .core.exceptions import TinyTorchCLIError
from rich.panel import Panel from rich.panel import Panel
from .commands.base import BaseCommand from .commands.base import BaseCommand
from .commands.notebooks import NotebooksCommand
from .commands.info import InfoCommand from .commands.info import InfoCommand
from .commands.test import TestCommand from .commands.test import TestCommand
from .commands.doctor import DoctorCommand from .commands.doctor import DoctorCommand
@@ -31,6 +32,7 @@ from .commands.jupyter import JupyterCommand
from .commands.nbdev import NbdevCommand from .commands.nbdev import NbdevCommand
from .commands.status import StatusCommand from .commands.status import StatusCommand
from .commands.system import SystemCommand from .commands.system import SystemCommand
from .commands.module_workflow import ModuleWorkflowCommand
from .commands.package import PackageCommand from .commands.package import PackageCommand
from .commands.nbgrader import NBGraderCommand from .commands.nbgrader import NBGraderCommand
from .commands.book import BookCommand from .commands.book import BookCommand
@@ -39,9 +41,8 @@ from .commands.grade import GradeCommand
from .commands.demo import DemoCommand from .commands.demo import DemoCommand
from .commands.logo import LogoCommand from .commands.logo import LogoCommand
from .commands.milestone import MilestoneCommand from .commands.milestone import MilestoneCommand
from .commands.community import CommunityCommand from .commands.leaderboard import LeaderboardCommand
from .commands.olympics import OlympicsCommand from .commands.olympics import OlympicsCommand
from .commands.submit import SubmitCommand
from .commands.setup import SetupCommand from .commands.setup import SetupCommand
# Configure logging # Configure logging
@@ -64,26 +65,23 @@ class TinyTorchCLI:
self.config = CLIConfig.from_project_root() self.config = CLIConfig.from_project_root()
self.console = get_console() self.console = get_console()
self.commands: Dict[str, Type[BaseCommand]] = { self.commands: Dict[str, Type[BaseCommand]] = {
# Core workflow (what students actually use) # Essential commands
'setup': SetupCommand, 'setup': SetupCommand,
'export': ExportCommand, # Hierarchical command groups only
'test': TestCommand,
'submit': SubmitCommand,
# Community features
'community': CommunityCommand,
# System management
'system': SystemCommand, 'system': SystemCommand,
'module': ModuleWorkflowCommand,
'package': PackageCommand, 'package': PackageCommand,
# Assessment tools
'nbgrader': NBGraderCommand, 'nbgrader': NBGraderCommand,
'grade': GradeCommand,
# Progress tracking
'checkpoint': CheckpointCommand, 'checkpoint': CheckpointCommand,
'milestone': MilestoneCommand, 'milestone': MilestoneCommand,
# Special events 'leaderboard': LeaderboardCommand,
'olympics': OlympicsCommand, 'olympics': OlympicsCommand,
# Utilities # Convenience commands
'notebooks': NotebooksCommand,
'export': ExportCommand,
'test': TestCommand,
'book': BookCommand, 'book': BookCommand,
'grade': GradeCommand,
'demo': DemoCommand, 'demo': DemoCommand,
'logo': LogoCommand, 'logo': LogoCommand,
} }
@@ -95,47 +93,32 @@ class TinyTorchCLI:
description="TinyTorch CLI - Build ML systems from scratch", description="TinyTorch CLI - Build ML systems from scratch",
formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=""" epilog="""
Core Workflow (what you'll use daily): Command Groups:
setup First-time environment setup system System environment and configuration commands
export Export module code to tinytorch package module Module development and management commands
test Run module tests package Package management and nbdev integration commands
submit Submit TinyMLPerf competition entry (Module 20) nbgrader Assignment management and auto-grading commands
checkpoint Track ML systems engineering progress through checkpoints
milestone Epic capability achievements and ML systems mastery
leaderboard Join the inclusive community, share progress, celebrate achievements
olympics Special competition events with focused challenges and recognition
Community Features: Convenience Commands:
community Join community, share progress, celebrate achievements export Export modules to package (quick shortcut)
test Run tests (quick shortcut)
book Build and manage Jupyter Book
grade Simplified grading interface (wraps NBGrader)
demo Run AI capability demos (show what your framework can do!)
System Tools: Examples:
system System environment and configuration tito setup First-time environment setup
package Package management and nbdev integration tito module start 01 Start Module 01 (tensors)
checkpoint Track your learning progress tito module complete 01 Complete Module 01 (test + export)
milestone Epic capability achievements tito module resume 02 Resume working on Module 02
tito module status View your learning progress
Assessment: tito system info Show system information
nbgrader Assignment management and auto-grading tito checkpoint timeline Visual progress timeline
grade Simplified grading interface tito book build Build the Jupyter Book locally
Special Events:
olympics Competition events and recognition
Utilities:
book Build and manage Jupyter Book
demo Run AI capability demos
logo Learn about TinyTorch philosophy
Daily Workflow:
# 1. Edit code in your IDE
cd modules/source/05_autograd/
# Edit autograd_dev.py...
# 2. Export and test
tito export 05
tito test 05
# 3. Repeat for next module!
Competition Workflow (Module 20):
# Edit Module 20, run cells → submission.json
tito submit submission.json
""" """
) )
@@ -225,38 +208,36 @@ Competition Workflow (Module 20):
# Show ASCII logo first # Show ASCII logo first
print_ascii_logo() print_ascii_logo()
# Show enhanced help with simplified structure # Show enhanced help with command groups
self.console.print(Panel( self.console.print(Panel(
"[bold bright_cyan]Core Workflow (Daily Use):[/bold bright_cyan]\n" "[bold]Essential Commands:[/bold]\n"
" [bold green]setup[/bold green] - First-time environment setup\n" " [bold cyan]setup[/bold cyan] - First-time environment setup\n\n"
" [bold green]export[/bold green] - Export module code to package\n" "[bold]Command Groups:[/bold]\n"
" [bold green]test[/bold green] - Run module tests\n" " [bold green]system[/bold green] - System environment and configuration\n"
" [bold green]submit[/bold green] - Submit competition entry (Module 20)\n\n" " [bold green]module[/bold green] - Module development and management\n"
"[bold bright_blue]Community:[/bold bright_blue]\n" " [bold green]package[/bold green] - Package management and nbdev integration\n"
" [bold bright_blue]community[/bold bright_blue] - Join, share progress, celebrate together\n\n" " [bold green]nbgrader[/bold green] - Assignment management and auto-grading\n"
"[bold yellow]Progress & Achievements:[/bold yellow]\n" " [bold green]checkpoint[/bold green] - Track ML systems engineering progress\n"
" [bold yellow]checkpoint[/bold yellow] - Track your learning progress\n" " [bold magenta]milestone[/bold magenta] - Epic capability achievements and ML mastery\n"
" [bold yellow]milestone[/bold yellow] - Epic capability achievements\n\n" " [bold bright_blue]leaderboard[/bold bright_blue] - Join the inclusive community, share progress\n"
"[bold magenta]Tools & Utilities:[/bold magenta]\n" " [bold bright_yellow]olympics[/bold bright_yellow] - Special competition events and recognition\n\n"
" [bold magenta]system[/bold magenta] - System tools\n" "[bold]Convenience Commands:[/bold]\n"
" [bold magenta]package[/bold magenta] - Package management\n" " [bold green]export[/bold green] - Export modules to package\n"
" [bold magenta]book[/bold magenta] - Build documentation\n" " [bold green]test[/bold green] - Run tests\n"
" [bold magenta]demo[/bold magenta] - Show capabilities\n\n" " [bold green]book[/bold green] - Build and manage Jupyter Book\n"
"[bold bright_green]📚 Quick Start:[/bold bright_green]\n" " [bold green]logo[/bold green] - Learn about TinyTorch philosophy\n"
" [dim]# 1. Setup (one time)[/dim]\n" "[bold]Quick Start:[/bold]\n"
" [cyan]tito setup[/cyan]\n\n" " [dim]tito setup[/dim] - First-time environment setup\n"
" [dim]# 2. Daily workflow (edit → export → test)[/dim]\n" " [dim]tito module start 01[/dim] - Start building tensors (first time)\n"
" [dim]# Edit modules/source/05_autograd/autograd_dev.py[/dim]\n" " [dim]tito module complete 01[/dim] - Complete Module 01 (test + export)\n"
" [cyan]tito export 05[/cyan]\n" " [dim]tito module start 02[/dim] - Begin activation functions\n"
" [cyan]tito test 05[/cyan]\n\n" " [dim]tito module status[/dim] - View your progress\n"
" [dim]# 3. Competition (Module 20)[/dim]\n"
" [dim]# Edit Module 20, run cells → submission.json[/dim]\n"
" [cyan]tito submit submission.json[/cyan]\n\n"
"[bold]Get Help:[/bold]\n" "[bold]Get Help:[/bold]\n"
" [dim]tito --help[/dim] - Show all commands\n" " [dim]tito system[/dim] - Show system subcommands\n"
" [dim]tito community[/dim] - Community subcommands\n" " [dim]tito module[/dim] - Show module subcommands\n"
" [dim]tito system[/dim] - System subcommands", " [dim]tito package[/dim] - Show package subcommands\n"
title="🔥 Welcome to TinyTorch!", " [dim]tito --help[/dim] - Show full help",
title="Welcome to TinyTorch!",
border_style="bright_green" border_style="bright_green"
)) ))
return 0 return 0